Last active
December 19, 2015 16:19
-
-
Save vanjikumaran/5983322 to your computer and use it in GitHub Desktop.
JAX RS example Hello World
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.area51.rest</groupId> | |
<artifactId>RESTfulExample</artifactId> | |
<packaging>war</packaging> | |
<version>1.0-SNAPSHOT</version> | |
<name>RESTfulExample Maven Webapp</name> | |
<url>http://maven.apache.org</url> | |
<dependencies> | |
<dependency> | |
<groupId>junit</groupId> | |
<artifactId>junit</artifactId> | |
<version>3.8.1</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>com.sun.jersey</groupId> | |
<artifactId>jersey-bundle</artifactId> | |
<version>1.8</version> | |
</dependency> | |
<dependency> | |
<groupId>asm</groupId> | |
<artifactId>asm</artifactId> | |
<version>3.3.1</version> | |
</dependency> | |
</dependencies> | |
<build> | |
<finalName>RESTfulExample</finalName> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>3.1</version> | |
<configuration> | |
<source>1.6</source> | |
<target>1.6</target> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
<repositories> | |
<repository> | |
<id>maven2-repository.java.net</id> | |
<name>Java.net Repository for Maven</name> | |
<url>http://download.java.net/maven/2/</url> | |
<layout>default</layout> | |
</repository> | |
</repositories> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created with IntelliJ IDEA. | |
* User: vanji | |
* Date: 7/12/13 | |
* Time: 1:37 PM | |
* To change this template use File | Settings | File Templates. | |
*/ | |
package com.area51.rest; | |
import javax.ws.rs.GET; | |
import javax.ws.rs.Path; | |
import javax.ws.rs.PathParam; | |
import javax.ws.rs.core.Response; | |
@Path("/hello") | |
public class HelloJaxRsService { | |
@GET | |
@Path("world/{param}") | |
public Response getMsg(@PathParam("param") String msg) { | |
String output = "JAX-RS say Hello to: " + msg; | |
return Response.status(200).entity(output).build(); | |
} | |
@GET | |
@Path("home/{param}") | |
public Response getHomeMsg(@PathParam("param") String msg) { | |
String output = "JAX-RS say Hello to: " + msg +" from home"; | |
return Response.status(200).entity(output).build(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<h1>Hello World from JAX-RS</h1> | |
<br/> | |
<h2>Sample JAX RS With 1G</h2> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE web-app PUBLIC | |
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" | |
"http://java.sun.com/dtd/web-app_2_3.dtd" > | |
<web-app id="WebApp_ID" version="2.4" | |
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee | |
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> | |
<display-name>Restful Web Application</display-name> | |
<servlet> | |
<servlet-name>jersey-serlvet</servlet-name> | |
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> | |
<init-param> | |
<param-name>com.sun.jersey.config.property.packages</param-name> | |
<param-value>com.area51.rest</param-value> | |
</init-param> | |
<load-on-startup>1</load-on-startup> | |
</servlet> | |
<servlet-mapping> | |
<servlet-name>jersey-serlvet</servlet-name> | |
<url-pattern>/rest/*</url-pattern> | |
</servlet-mapping> | |
</web-app> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment