Deploy Web Application in Jetty Container in Embedded Mode

What is this tutorial all about ?

This tutorial is all about to deploy an web application in embedded Jetty web container. You do not need to deploy it manually into the web server.

Why do we need to deploy it in embedded mode ?

We sometimes need to deploy it in embedded mode, because during unit testing or integration testing we have to deploy the web application manually every time before we start the testing; so we want to deploy the application into embedded mode so that it starts up automatically and we perform unit testing or integration testing without taking care of deployment.

Eclipse Kepler
Maven 3.x
Spring 4

Step 1. Create a maven based web project from Eclipse IDE.

Select File -> New -> Other -> Maven -> Maven Project. Click on Next. Browse project location. Next select an Archetype from the list. Select Artifact Id – maven-archetype-webapp. Click on Next.

Now input Group Id: com.roytuts, Artifact Id: embedded-jetty-web

Click on Finish.

Step 2. Modify pom.xml to configure various dependencies

Step 3. Create an XML file for Jetty web container configuration

Step 4. Modify index.jsp file under src/main/webapp

Step 5. Create a test class which will deploy the web application into Jetty web container.

Step 6. Change the display name in web.xml file.

Step 7. Run the test class. You will see the below output in the console.


Step 8. Now open a browser and hit the URL http://localhost:9090/EmbeddedJettyWeb you will get the below output in the browser.

Jetty Spring Web Application in Embedded Mode

That’s all. Thank you for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.