java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.bzdev.net.servlets.EncapsulatingServlet
- All Implemented Interfaces:
Serializable,Servlet,ServletConfig
Servlet implemented by encapsulating an instance of
ServletAdapter.
Subclasses are expected to provide a constructor with no arguments
that creates an instance of ServletAdapter and passes it to
the constructor of this class. For example,
public class OurServlet extends EncapsulatingServlet { public OurServlet() { super(new OurAdapter()); } }
To use this class, A JAR file containing the servlet API must be on the classpath or accessible via the module path. For releases whose manifest does not contain an AUTOMATIC-MODULE-NAME declaration, the file name must be servlet-api.jar. This of course is subject to change.
ServletAdapter states are handled internally by setting and getting
a session attribute named "state", so the attribute name "state" should
be treated a reserved name. Servlet adapters use a subset of the
servlet API. If more of the API is needed (e.g., for logins),
methods such as
doPost(HttpServletRequest,HttpServletResponse)
should be overridden to add additional functionality.
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedEncapsulatingServlet(ServletAdapter adapter) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal voiddestroy()Destroy a servlet.protected voiddoDelete(HttpServletRequest req, HttpServletResponse res) Called by the server (via a service method) to allow a servlet to handle a DELETE request.protected voiddoGet(HttpServletRequest req, HttpServletResponse res) Called by the server (via a service method) to allow a servlet to handle a GET request.protected voiddoPost(HttpServletRequest req, HttpServletResponse res) Called by the server (via a service method) to allow a servlet to handle a POST request.protected voiddoPut(HttpServletRequest req, HttpServletResponse res) Called by the server (via a service method) to allow a servlet to handle a PUT request.voidinit()Initialize a servlet's adapter.Methods inherited from class javax.servlet.http.HttpServlet
doHead, doOptions, doTrace, getLastModified, service, serviceMethods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Constructor Details
-
EncapsulatingServlet
Constructor.- Parameters:
adapter- the servlet adapter to encapsulate.
-
-
Method Details
-
doGet
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException Called by the server (via a service method) to allow a servlet to handle a GET request. Please see the HttpServlet method doGet for a full description.- Overrides:
doGetin classHttpServlet- Parameters:
req- anHttpServletRequestobject that contains the request the client has made to the servlet.res- anHttpServletResponseobject that contains the response the client has made to the servlet.- Throws:
IOException- an IO error occurred during processingServletException- if the request for the GET could not be handled.
-
doPost
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException Called by the server (via a service method) to allow a servlet to handle a POST request. Please see the HttpServlet method doPost for a full description.- Overrides:
doPostin classHttpServlet- Parameters:
req- anHttpServletRequestobject that contains the request the client has made to the servlet.res- anHttpServletResponseobject that contains the response the client has made to the servlet.- Throws:
IOException- an IO error occurred during processingServletException- if the request for the POST could not be handled.
-
doPut
protected void doPut(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException Called by the server (via a service method) to allow a servlet to handle a PUT request. Please see the HttpServlet method doPut for a full description.- Overrides:
doPutin classHttpServlet- Parameters:
req- anHttpServletRequestobject that contains the request the client has made to the servlet.res- anHttpServletResponseobject that contains the response the client has made to the servlet.- Throws:
IOException- an IO error occurred during processingServletException- if the request for the PUT could not be handled.
-
doDelete
protected void doDelete(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException Called by the server (via a service method) to allow a servlet to handle a DELETE request. Please see the HttpServlet method doDelete for a full description. for a full description.- Overrides:
doDeletein classHttpServlet- Parameters:
req- anHttpServletRequestobject that contains the request the client has made to the servlet.res- anHttpServletResponseobject that contains the response the client has made to the servlet.- Throws:
IOException- an IO error occurred during processingServletException- if the request for the PUT could not be handled.
-
init
Initialize a servlet's adapter. Please see the GenericServlet method init() for the official description. The servlet method init(ServletConfig) will typically be called to initialize the servlet. That method stores the servlet configuration object and then calls this method - init() - to perform the initialization.- Overrides:
initin classGenericServlet- Throws:
ServletException- if the initialization fails.
-
destroy
public final void destroy()Destroy a servlet. Please seeGenericServlet.destroy()for a full description.- Specified by:
destroyin interfaceServlet- Overrides:
destroyin classGenericServlet
-