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

3 ways in creating custom error pages

1. web.xml located in <webapp>/WEB-INF/web.xml

  Edit web.xml and add the <error-page> element. This element creates a mapping between the error-code or exception type to the path of a resource in the web application.
  error-code - integer value
  exception - fully qualified class name of a Java Exception type
  location - location of the resource in webapp relative to the root of the web application. Value should start with "/".

  a. Error code

  b. Exception type

2. context file located in <jetty.home>/contexts/?.xml (any filename as long as its extension is xml)

   A basic context xml configured the class ErrorHandler to map error pages by code, exception, and range.

3) New class extends ErrorHandler
Here are the methods that you need to override:

  • public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException
    Optional to override:
  • void handleErrorPage(HttpServletRequest request, Writer writer, int code, String message) throws IOException
  • void writeErrorPage(HttpServletRequest request, Writer writer, int code, String message, boolean showStacks) throws IOException
  • void writeErrorPageHead(HttpServletRequest request, Writer writer, int code, String message) throws IOException
  • void writeErrorPageBody(HttpServletRequest request, Writer writer, int code, String message, boolean showStacks) throws IOException
  • void writeErrorPageMessage(HttpServletRequest request, Writer writer, int code, String message,String uri) throws IOException
  • void writeErrorPageStacks(HttpServletRequest request, Writer writer) throws IOException
  • 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