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
DOCUMENTATION: Jetty 6 - this wiki. Jetty 7 - at Eclipse. Jetty8 - at Eclipse. Jetty 9 - at Eclipse.
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

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.

Labels
  • None
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