| | Hello, world in Jersey
This is
a very simple, GET-only web application built with Jersey. It has two purposes:
- Illustrate some of the
basics of setting up a Jersey-based servlet and returning responses with it
- Serve as a test that
you are able to deploy a Jersey-based web app in your environment
You can download hello-jersey.war
directly into your GlassFish's autodeploy directory. It also contains source
code. It has been deployed on einstein. The following links exercise its
capabilities
Note also the WEB-INF/web.xml
in this demo. It tells the container to use a general-purpose ServletContainer
class supplied by Jersey. That class knows how to scan your code for JAX-RS-annotated
classes and methods, and invoke them when necessary. You should be able to use
this same web.xml
for all of your Jersey-based servlets, unless you want to change the display
name to fit your web app. The content is below.
<?xml version="1.0"
encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>Hello world with Jersey</display-name>
<servlet>
<servlet-name>JerseyServlet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JerseyServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
|