Java : Boosting web application development using (embedded) Jetty
This page last changed on Jan 09, 2008 by Kees de Kooter
Intro
Setting up tomcat to run from Eclipse is quite cumbersome (see Boosting web application development - running Tomcat from Eclipse). There is an easier way.
Jetty embedded server
With only three lines of code and two maven dependencies you can start a webserver running from Eclipse.
public class JettyStarter {
public static void main(String[] args) throws Exception {
init();
}
private static void init() throws Exception {
WebAppContext webAppContext = new WebAppContext("src/main/webapp", "/avr");
Server server = new Server(8080);
server.setHandler(webAppContext);
server.start();
}
}
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>6.1.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1</artifactId>
<version>6.1.5</version>
<scope>test</scope>
</dependency>