fc.web.servlet
Class PathServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by fc.web.servlet.PathServlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public abstract class PathServlet
extends javax.servlet.http.HttpServlet

A convenient base class for servlets that use path info (must be path mapped; extension mapped servlets (like *.mp) do not have any path info associated with them.

If the request has a non-null non-empty path, then that path is sent to the doPathInfo method, which a subclass should implement. A request with an empty or null path info results in sending a 404 error back to the client.

See Also:
Serialized Form

Constructor Summary
PathServlet()
           
 
Method Summary
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
           
abstract  void doPathInfo(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, String pathinfo)
          The pathinfo parameter is not intern()'ed but can be if/as needed in this method.
 void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
           
 void error(javax.servlet.http.HttpServletResponse res, String msg)
          Sends a 404 (page not found) error to the client.
 void init(javax.servlet.ServletConfig conf)
           
 
Methods inherited from class javax.servlet.http.HttpServlet
service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathServlet

public PathServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig conf)
          throws javax.servlet.ServletException
Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException

doPost

public void doPost(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse res)
            throws javax.servlet.ServletException,
                   IOException
Overrides:
doPost in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
IOException

doGet

public void doGet(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse res)
           throws javax.servlet.ServletException,
                  IOException
Overrides:
doGet in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
IOException

error

public void error(javax.servlet.http.HttpServletResponse res,
                  String msg)
           throws IOException
Sends a 404 (page not found) error to the client. Invoke this method if there is missing/bad path info and return from the servlet.

Throws:
IOException

doPathInfo

public abstract void doPathInfo(javax.servlet.http.HttpServletRequest req,
                                javax.servlet.http.HttpServletResponse res,
                                String pathinfo)
                         throws javax.servlet.ServletException,
                                IOException
The pathinfo parameter is not intern()'ed but can be if/as needed in this method.

Throws:
javax.servlet.ServletException
IOException