com.mortbay.Servlets
Class LookAndFeelServlet

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--com.mortbay.Servlets.LookAndFeelServlet

public class LookAndFeelServlet
extends javax.servlet.http.HttpServlet

LookAndFeel Servlet

The LookAndFeel Servlet serves resources as the body of html pages which it wraps in a certain LookAndFeel. The LookAnd Feel it uses is given in the "PageType" init parameter, but each individual request must supply a "Heading" query parameter at the minimum. All other query parameters given in the request are passed to the Page as Page parameters.

The LookAndFeel Servlet is thus good for using for formatting help pages in their proper LookAndFeel, since a particular instance of the LookAndFeel Servlet can be configured with the correct LookAndFeel for the referring pages and then the individual requests override parameters with the settings from the referring page.

Notes

The resource is described in the request pathInfo, prefixed with a path given in the "ResourceBase" init parameter. The page heading is in the "Heading" query parameter.

Version:
$Id: LookAndFeelServlet.java,v 2.6 1999/10/09 15:07:27 gregw Exp $
Author:
Greg Wilkins
See Also:
Serialized Form

Constructor Summary
LookAndFeelServlet()
           
 
Method Summary
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Receives an HTTP GET request from the protected service method and handles the request.
 void init(javax.servlet.ServletConfig config)
          Initializes this servlet.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doOptions, doPost, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LookAndFeelServlet

public LookAndFeelServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Description copied from class: javax.servlet.GenericServlet
Initializes this servlet.

The servlet engine calls this method once, automatically, each time it loads the servlet. This method is guaranteed to finish before the servlet accepts any requests to its service method. If a fatal error occurs while the servlet is being initialized, the servlet engine should throw an UnavailableException, rather than calling the System.exit method.

The init method stores the ServletConfig object it receives from the servlet engine. If you override init, you should either call super.init or store the ServletConfig object in the new init method. If you decide to store the ServletConfig object in a different location, you should also override the GenericServlet.getServletConfig() method.

Overrides:
init in class javax.servlet.GenericServlet
Tags copied from class: javax.servlet.GenericServlet
Parameters:
config - the ServletConfig object that contains initialization parameters for this servlet
Throws:
javax.servlet.ServletException - if an exception occurs that interrupts the servlet's normal operation
See Also:
UnavailableException

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws javax.servlet.ServletException,
                  java.io.IOException
Description copied from class: javax.servlet.http.HttpServlet
Receives an HTTP GET request from the protected service method and handles the request. The GET method allows a client to read information from the Web server, passing a query string appended to an URL to tell the server what information to return.

Overriding this method to support a GET request also automatically supports an HTTP HEAD request. A HEAD request is a GET request that returns no body in the response, only the request header fields.

If you override this method, you should read data from the request, set entity headers in the response, access the writer or output stream object, and finally, write the response data. When you set headers, be sure to include content type and encoding. If you use a PrintWriter object to return the response, you must set the content type before you access the PrintWriter object.

The servlet engine must write the headers before the response data, because the headers can be flushed at any time after the data is written.

If you can set the Content-Length header (with the javax.servlet.ServletResponse.#contentType method), the servlet can use a persistent connection to return its response to the client, improving performance dramatically. If you cannot set Content-Length, you can sometimes avoid the performance penalty if the response fits in an internal buffer.

The GET method should be safe, that is, without any side effects for which users are held responsible. For example, most form queries have no side effects. If a client request is intended to change stored data, the request should use some other HTTP method.

The GET method should also be idempotent, meaning that it can be safely repeated. Sometimes making a method safe also makes it idempotent. For example, repeating queries is both safe and idempotent, but buying a product online or modifying data is neither safe nor idempotent.

If the request is incorrectly formatted, doGet returns an HTTP BAD_REQUEST message.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Tags copied from class: javax.servlet.http.HttpServlet
Parameters:
req - an HttpServletRequest object that contains the request the client has made of the servlet
resp - an HttpServletResponse object that contains the response the servlet sends to the object
Throws:
java.io.IOException - if an input or output error is detected when the servlet handles the GET request
javax.servlet.ServletException - if the request for the GET could not be handled
See Also:
ServletResponse.setContentType(java.lang.String)