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 4 Next »

Embedding Jetty

Using Jetty as an embedded server is far more different this time compared to version 5.   The code have been overlhauled at least and uses the org.mortbay.jetty.Server against org.mortbay.http.HttpServer. If you have plans porting Jetty in your application, you may need these two important jars:

  • jetty.jar
  • servlet-api.jar

These are the ones needed for servlet. But if you're running with jsp's, you may need these jars:

  • ant.jar
  • jasper-compiler.jar
  • jasper-compiler-jdt.jar
  • jasper-runtime.jar
  • jcl-over-slf4j.jar
  • slf4j-simple.jar
  • xercesImpl.jar
  • xmlParserAPI.jar
  • commons-el.jar

You may find these resources in the jetty_home\lib\jsp folder.  You can call the Server class to serve for web applications. You can configure your own jetty.xml or call it in your Server class similar to this:

If you don't want to do webapps, then you can still use the Server class, and the various Connector implementations,  but just use different Handler implementations. 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 as you can see. The DefaultServlet impl is being 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.

  • 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