Class CsrfJavaScriptServletProxy
- All Implemented Interfaces:
Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
The third-party JavaScriptServlet overrides init(ServletConfig) without
calling super.init(config), so GenericServlet.getServletConfig() returns null.
Equinox's HttpServletRequestWrapperImpl.getSession() calls
registeredServlet.getServletConfig().getServletContext() on the servlet registered with
the OSGi HTTP Whiteboard — resulting in a NullPointerException on every request to the CSRF JS
endpoint.
This proxy is registered with OSGi instead. It correctly calls super.init(config),
so getServletConfig() is never null from Equinox's perspective. It then calls
delegate.init(config) which sets the static servletConfig field inside
JavaScriptServlet needed for its own logic (e.g. resolving context-path init params).
All requests are forwarded to the delegate unchanged.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, serviceMethods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Constructor Details
-
CsrfJavaScriptServletProxy
public CsrfJavaScriptServletProxy(javax.servlet.http.HttpServlet delegate)
-
-
Method Details
-
init
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException - Specified by:
initin interfacejavax.servlet.Servlet- Overrides:
initin classjavax.servlet.GenericServlet- Throws:
javax.servlet.ServletException
-
service
protected void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException - Overrides:
servicein classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionIOException
-
destroy
public void destroy()- Specified by:
destroyin interfacejavax.servlet.Servlet- Overrides:
destroyin classjavax.servlet.GenericServlet
-