Class PathServlet

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

public abstract class PathServlet extends jakarta.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:
  • Field Summary

    Fields inherited from class jakarta.servlet.http.HttpServlet

    LEGACY_DO_HEAD
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    doGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res)
     
    abstract void
    doPathInfo(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, String pathinfo)
    The pathinfo parameter is not intern()'ed but can be if/as needed in this method.
    void
    doPost(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res)
     
    void
    error(jakarta.servlet.http.HttpServletResponse res, String msg)
    Sends a 404 (page not found) error to the client.
    void
    init(jakarta.servlet.ServletConfig conf)
     

    Methods inherited from class jakarta.servlet.http.HttpServlet

    service

    Methods inherited from class jakarta.servlet.GenericServlet

    destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • init

      public void init(jakarta.servlet.ServletConfig conf) throws jakarta.servlet.ServletException
      Specified by:
      init in interface jakarta.servlet.Servlet
      Overrides:
      init in class jakarta.servlet.http.HttpServlet
      Throws:
      jakarta.servlet.ServletException
    • doPost

      public void doPost(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) throws jakarta.servlet.ServletException, IOException
      Throws:
      jakarta.servlet.ServletException
      IOException
    • doGet

      public void doGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) throws jakarta.servlet.ServletException, IOException
      Throws:
      jakarta.servlet.ServletException
      IOException
    • error

      public void error(jakarta.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(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, String pathinfo) throws jakarta.servlet.ServletException, IOException
      The pathinfo parameter is not intern()'ed but can be if/as needed in this method.
      Throws:
      jakarta.servlet.ServletException
      IOException