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

Serving static content

If you just want to serve simple static content without needing to have an entire web application, there are a couple of alternatives.

Using a servlet Context and DefaultHandler

There is an example of doing this in the jetty distribution in the $JETTY-HOME/contexts/javadoc.xml file. Here it is:

The Context is used to match urls of the form /javadoc/*, and to set up the location of the static resources, which in this case is the directory $JETTY-HOME/javadoc. The DefaultHandler serves the resources.

You would choose this method of serving static content if you want to be able to use Servlets and/or take advantage of the other features of the DefaultServlet.

Using a ContextHandler and a ResourceHandler

Alternatively, for a slightly more lightweight and simple solution you can use a ContextHandler and a ResourceHandler. Here is an example:

The ContextHandler is used to match urls of the form /javadoc/*, and to set up the location of the static resources (again $JETTY-HOME/javadoc). The ResourceHandler serves the resources.

  • 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