Jetty has moved!
Jetty is a project at the Eclipse Foundation.
Homepage:http://www.eclipse.org/jetty
Downloads: http://download.eclipse.org/jetty/
Documentation:http://www.eclipse.org/jetty/documentation/current/
About:http://www.eclipse.org/jetty/about.php
Jetty Powered:http://www.eclipse.org/jetty/powered/
Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

Embedding Jetty

Setting up the classpath

To run Jetty, you need only these jars:

  • jetty.jar
  • servlet-api-2.5.jar
  • jetty-util.jar

Those jars give you the ability to serve web applications.

If you wish to use JSPs, then you will need a couple of additional jars.

JSP2.0

JSP 2.0 is used with version 2.4 of the servlet specification. Depending on the functionality you require, you may be able to use this version rather than the newer JSP2.1 jars.

JSP2.1

Remember!

Icon

You need to use J2SE5 (aka jdk 1.5) if you wish to use JSP2.1.

This is the jsp version mandated by servlet specification 2.5. You will need these jars:

Code

The jetty configuration files (eg jetty.xml) have an xml syntax that is a straightforward mapping of the java API. Take a look at the files in etc/ for some hints on what calls to make in your own code. Here's the minimal code to set up a Jetty server and webapp:

Using Jetty with Servlets (but not webapps)

Have a look at what is going on near the bottom of the etc/jetty.xml file where it says: "Configure a context directly - no XML parser required". This is setting up a ContextHandler that can serve servlets and static content. The servlet setup isn't done by a web.xml file, but rather in API calls instead. The DefaultServlet impl is used to serve static content. If you just want to serve static content, then you might have to create your own Handler using the DefaultServlet implementation as a guide.

Using Jetty with lightweight Handlers instead of Servlets

  • No labels
Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery