Wednesday, August 7, 2013

Jetty Server : How to deploy a war file?

Jetty is an open-source project providing an HTTP server, HTTP client, and javax.servlet container.Jetty implements aspects of the Java EE specification, primarily the Servlet Specification.

Downloading the Jetty Distribution
The standalone Jetty distribution is available for download from the Eclipse Foundation:
It is available in both zip and gzip formats; download the one most appropriate for your system. When you download and unpack the binary, it is extracted into a directory called jetty-distribution-VERSION. Put this directory in a convenient location.

jetty [JETTY_HOME]

Now extract the application war example.war to jetty/webapps/example.

Create a file example.xml in jetty/webapps.demo with following content

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "">
<configure class="org.mortbay.jetty.webapp.WebAppContext">
<set name="contextPath">/example</set>
<set name="example"><systemproperty name="jetty.home" default="."/>/webapps/example</set>

save it &amp; start the jetty server with command: java –jar start.jar
Now done.Open the web browser type the address as http://localhost:8080/example/