Add your Java web application to Jetty Server


What is Jetty Server ?

Jetty  is a pure Java-based HTTP server and servlet container (application server). Jetty is a free and open source project under the Apache 2.0 License. Jetty deployment focuses on creating a simple, efficient, embeddable and pluggable web server. Jetty’s small size makes it suitable for providing web services in an embedded Java application. It also offers support for Web Sockets, OSGi, JMX, JNDI, JASPI, AJP, and other Java technologies. ( Wikipedia).

Lets first create a sample web app using maven. Then deploy it to jetty server using maven-jetty plugin.

Generate the testWebApp using following command in the cmd.

mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp -DartifactId=testWebApp -DgroupId=net.supun.maven -Dversion=1.0-SNAPSHOT -Dpackage=net.supun.maven

Here is the output.

Then open the pom.xml file and add the following lines to it.



Then compile and install the project using Maven.
mvn compile
mvn test
mvn install

Then the file named index.jsp has created with the following content.

<h2>Hello World!</h2>

Now, add the jetty plugin in your pom.xml.


Now run the jetty server
mvn jetty:run
Then go to localhost:8080/testWebApp in your browser. The following will be the output.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s