Class AbstractServlet
- java.lang.Object
-
- jakarta.servlet.GenericServlet
-
- jakarta.servlet.http.HttpServlet
-
- org.apache.felix.webconsole.servlet.AbstractServlet
-
- All Implemented Interfaces:
jakarta.servlet.Servlet
,jakarta.servlet.ServletConfig
,java.io.Serializable
public abstract class AbstractServlet extends jakarta.servlet.http.HttpServlet
This class can be used as a base class for a web console plugin. The plugin (servlet) needs to be registered as a servlet service with at least the label property.Extending this servlet is one way of providing a plugin. The other is to simply direclty implement the servlet interface. In both cases requests to resources with a path of "LABEL/res/*" are automatically handled.
For html (content) requests, the web console automatically renders the header, footer and navigation.
Support for Jakarta servlets requires that the Jakarta Servlet API and the Apache Felix Http Wrappers are available in the runtime.
If you are upgrading from
AbstractWebConsolePlugin
there are some changes to be aware of:- Resources are detected via the
getResource(String)
method. - Regardless of the http method, if the corresponding doXXX method does not create
a response, the
renderContent(HttpServletRequest, HttpServletResponse)
method is invoked. - If a doXXX method other than doGet wants to create a response, it must not call doGet or renderContent directly. It rather just does not create any response and returns. In this case the web console will invoke the renderContent method afterwards.
-
-
Constructor Summary
Constructors Constructor Description AbstractServlet()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
renderContent(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
This method is used to render the main contents of the pluginstatic void
setNoCache(jakarta.servlet.http.HttpServletResponse response)
Sets response headers to force the client to not cache the response sent back.
-
-
-
Method Detail
-
renderContent
public void renderContent(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, java.io.IOException
This method is used to render the main contents of the plugin- Parameters:
request
- The requestresponse
- The response- Throws:
jakarta.servlet.ServletException
- If an error occursjava.io.IOException
- If writing the response fails
-
setNoCache
public static final void setNoCache(jakarta.servlet.http.HttpServletResponse response)
Sets response headers to force the client to not cache the response sent back. This method must be called before the response is committed otherwise it will have no effect.This method sets the
Cache-Control
,Expires
, andPragma
headers.- Parameters:
response
- The response for which to set the cache prevention
-
-