bb.servlet
Class RequestEcho

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by bb.servlet.RequestEcho
All Implemented Interfaces:
Serializable, Servlet, ServletConfig

public class RequestEcho
extends HttpServlet

This servlet echoes back information about the request that was sent to it. This is useful in debugging.

This class is multithread safe: it is immutable (both its immediate state, as well as the deep state of its fields).

Author:
Brent Boyer
See Also:
doPost, doGet, Serialized Form

Field Summary
private static long serialVersionUID
           
 
Constructor Summary
RequestEcho()
           
 
Method Summary
 void doGet(HttpServletRequest request, HttpServletResponse response)
          This method simply calls doPost.
 void doPost(HttpServletRequest request, HttpServletResponse response)
          This method echoes back information about the request's metadata, headers, URL info, parameters, and content.
protected  void printContentInfo(HttpServletRequest request, PrintWriter out)
          Prints to out information about the request's content.
protected  void printHeaders(HttpServletRequest request, PrintWriter out)
          Prints to out any name/value header pairs in the request.
protected  void printMetadata(HttpServletRequest request, PrintWriter out)
          Prints to out metadata about the request.
protected  void printNetworkInfo(HttpServletRequest request, PrintWriter out)
          Prints to out the network information (local and remote) involved in the request.
protected  void printParameters(HttpServletRequest request, PrintWriter out)
          Prints to out any name/value parameter pairs in the request.
protected  void printUrlInfo(HttpServletRequest request, PrintWriter out)
          Prints to out information about the URL used by the request.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

RequestEcho

public RequestEcho()
Method Detail

doGet

public void doGet(HttpServletRequest request,
                  HttpServletResponse response)
           throws ServletException,
                  IOException
This method simply calls doPost.

Overrides:
doGet in class HttpServlet
Throws:
ServletException
IOException

doPost

public void doPost(HttpServletRequest request,
                   HttpServletResponse response)
            throws ServletException,
                   IOException
This method echoes back information about the request's metadata, headers, URL info, parameters, and content. The response is a plain text format (i.e. "text/plain") description.

Overrides:
doPost in class HttpServlet
Throws:
ServletException
IOException

printNetworkInfo

protected void printNetworkInfo(HttpServletRequest request,
                                PrintWriter out)
Prints to out the network information (local and remote) involved in the request.


printMetadata

protected void printMetadata(HttpServletRequest request,
                             PrintWriter out)
Prints to out metadata about the request.


printUrlInfo

protected void printUrlInfo(HttpServletRequest request,
                            PrintWriter out)
Prints to out information about the URL used by the request.


printHeaders

protected void printHeaders(HttpServletRequest request,
                            PrintWriter out)
Prints to out any name/value header pairs in the request.


printParameters

protected void printParameters(HttpServletRequest request,
                               PrintWriter out)
Prints to out any name/value parameter pairs in the request.


printContentInfo

protected void printContentInfo(HttpServletRequest request,
                                PrintWriter out)
Prints to out information about the request's content.