Top Description Inners Fields Constructors Methods
org.glassfish.grizzly.servlet

public Class ServletHandler

extends HttpHandler
Class Inheritance
Static Imports
jakarta.servlet.DispatcherType.REQUEST

HttpHandler implementation that provides an entry point for processing a Servlet request.
Author
Jeanfrancois Arcand

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
ServletHandler.ServletAfterServiceListener

AfterServiceListener, which is responsible for recycle servlet request and response objects.

Field Summary

Modifier and TypeField and Description
protected ClassLoader
private String
protected ExpectationHandler
protected FilterChainFactory
protected boolean
initialize

Initialize the ServletContext

private final Object
private static final Logger
private List<Runnable>
protected final Map<String, Object>
properties

Holder for our configured properties.

pack-priv static final Note<HttpServletRequestImpl>
pack-priv static final Note<HttpServletResponseImpl>
pack-priv static final ServletHandler.ServletAfterServiceListener
protected Class<? extends Servlet>
protected String
private final ServletConfigImpl
private final WebappContext
protected volatile Servlet
private SessionManager

Constructor Summary

AccessConstructor and Description
protected
ServletHandler(final ServletConfigImpl servletConfig)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
addOnDestroyListener(final Runnable
Runnable, which contains destroy listener logic.
r
)

Adds the Runnable, which will be invoked when destroy() is called.

protected void
public void
customizeErrorPage(final Response response, final String
the HTTP error message
message
,
final int
the error code.
errorCode
,
final Throwable t)

Customize the error page returned to the client.

public void
protected void
doServletService(final Request request, final Response response)

pack-priv void
doServletService(final ServletRequest servletRequest, final ServletResponse servletResponse, final DispatcherType dispatcherType)

public ClassLoader
private String

Returns:

The combined path with pathInfo appended to servletInfo
getCombinedPath
(final HttpServletRequest request)

Combines the servletPath and the pathInfo.

public String

Returns:

a String specifying the portion of the request URI that indicates the context of the request
getContextPath
()

Returns the portion of the request URI that indicates the context of the request.

public ExpectationHandler

Returns:

the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").
getExpectationHandler
()

Get the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").

protected FilterChainInvoker
public String
getName()

Overrides org.glassfish.grizzly.http.server.HttpHandler.getName.

Get the HttpHandler name.

public ServletConfigImpl
protected WebappContext
public Servlet

Returns:

Servlet instance.
getServletInstance
()

Return the Servlet instance used by this ServletHandler

pack-priv static HttpServletRequestImpl
getServletRequest(final Request request)

pack-priv static HttpServletResponseImpl
getServletResponse(final Request request)

protected String

Returns:

the session cookie name
getSessionCookieName
()

Overrides org.glassfish.grizzly.http.server.HttpHandler.getSessionCookieName.

Overrides default (JSESSIONID) session cookie name.

protected SessionManager
protected void
loadServlet()

Load a Servlet instance.

protected boolean
public void
service(Request request, Response response)

Implements abstract org.glassfish.grizzly.http.server.HttpHandler.service.

This method should contain the logic for any HTTP extension to the Grizzly HTTP web server.

public void
public void
setContextPath(String
Context path.
contextPath
)

Programmatically set the context path of the Servlet.

protected void
private void
setDispatcherPath(final Request request, final String path)

public void
setExpectationHandler(ExpectationHandler
the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").
expectationHandler
)

Set the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").

protected void
setFilterChainFactory(final FilterChainFactory filterChainFactory)

protected void
protected void
setServletClass(final Class<? extends Servlet> servletClass)

protected void
setServletClassName(final String servletClassName)

protected void
setServletInstance(Servlet
an instance of Servlet.
servletInstance
)

Set the Servlet instance used by this ServletHandler

protected void
setSessionManager(SessionManager
an implementation of SessionManager.
sessionManager
)

Set the SessionManager instance used by this ServletHandler

public void
start()

Overrides org.glassfish.grizzly.http.server.HttpHandler.start.

Called when the HttpHandler's container is started by invoking HttpServer#start.

Inherited from org.glassfish.grizzly.http.server.HttpHandler:
getErrorPageGeneratorgetRequestExecutorProvidergetRequestURIEncodingisAllowCustomStatusMessageisAllowEncodedSlashsetAllowCustomStatusMessagesetAllowEncodedSlashsetDecodeUrlsetRequestURIEncodingsetRequestURIEncodingupdatePaths

Field Detail

classLoaderback to summary
protected ClassLoader classLoader
contextPathback to summary
private String contextPath
expectationHandlerback to summary
protected ExpectationHandler expectationHandler
filterChainFactoryback to summary
protected FilterChainFactory filterChainFactory
initializeback to summary
protected boolean initialize

Initialize the ServletContext

lockback to summary
private final Object lock
LOGGERback to summary
private static final Logger LOGGER

Hides org.glassfish.grizzly.http.server.HttpHandler.LOGGER.

onDestroyListenersback to summary
private List<Runnable> onDestroyListeners
propertiesback to summary
protected final Map<String, Object> properties

Holder for our configured properties.

SERVLET_REQUEST_NOTEback to summary
pack-priv static final Note<HttpServletRequestImpl> SERVLET_REQUEST_NOTE
SERVLET_RESPONSE_NOTEback to summary
pack-priv static final Note<HttpServletResponseImpl> SERVLET_RESPONSE_NOTE
servletAfterServiceListenerback to summary
pack-priv static final ServletHandler.ServletAfterServiceListener servletAfterServiceListener
servletClassback to summary
protected Class<? extends Servlet> servletClass
servletClassNameback to summary
protected String servletClassName
servletConfigback to summary
private final ServletConfigImpl servletConfig

The ServletConfigImpl

servletCtxback to summary
private final WebappContext servletCtx

The WebappContext

servletInstanceback to summary
protected volatile Servlet servletInstance
sessionManagerback to summary
private SessionManager sessionManager

The SessionManager

Constructor Detail

ServletHandlerback to summary
protected ServletHandler(final ServletConfigImpl servletConfig)

Method Detail

addOnDestroyListenerback to summary
pack-priv void addOnDestroyListener(final Runnable r)

Adds the Runnable, which will be invoked when destroy() is called.

Parameters
r:Runnable

Runnable, which contains destroy listener logic.

configureServletEnvback to summary
protected void configureServletEnv() throws ServletException

Configure the WebappContext and ServletConfigImpl

Exceptions
ServletException:
Error while configuring Servlet.
customizeErrorPageback to summary
public void customizeErrorPage(final Response response, final String message, final int errorCode, final Throwable t)

Customize the error page returned to the client.

Parameters
response:Response

the Response

message:String

the HTTP error message

errorCode:int

the error code.

destroyback to summary
public void destroy()

Overrides org.glassfish.grizzly.http.server.HttpHandler.destroy.

Destroy this Servlet and its associated jakarta.servlet.ServletContextListener

Annotations
@Override
doServletServiceback to summary
protected void doServletService(final Request request, final Response response)
doServletServiceback to summary
pack-priv void doServletService(final ServletRequest servletRequest, final ServletResponse servletResponse, final DispatcherType dispatcherType) throws IOException, ServletException
getClassLoaderback to summary
public ClassLoader getClassLoader()
getCombinedPathback to summary
private String getCombinedPath(final HttpServletRequest request)

Combines the servletPath and the pathInfo. If pathInfo is null, it is ignored. If servletPath is null, then null is returned.

Returns:String

The combined path with pathInfo appended to servletInfo

getContextPathback to summary
public String getContextPath()

Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "". The container does not decode this string.

It is possible that a servlet container may match a context by more than one context path. In such cases this method will return the actual context path used by the request and it may differ from the path returned by the jakarta.servlet.ServletContext#getContextPath() method. The context path returned by jakarta.servlet.ServletContext#getContextPath() should be considered as the prime or preferred context path of the application.

Returns:String

a String specifying the portion of the request URI that indicates the context of the request

See Also
jakarta.servlet.ServletContext#getContextPath()
getExpectationHandlerback to summary
public ExpectationHandler getExpectationHandler()

Get the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").

Returns:ExpectationHandler

the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").

getFilterChainback to summary
protected FilterChainInvoker getFilterChain(Request request)
getNameback to summary
public String getName()

Overrides org.glassfish.grizzly.http.server.HttpHandler.getName.

Doc from org.glassfish.grizzly.http.server.HttpHandler.getName.

Get the HttpHandler name.

Annotations
@Override
getServletConfigback to summary
public ServletConfigImpl getServletConfig()
getServletCtxback to summary
protected WebappContext getServletCtx()
getServletInstanceback to summary
public Servlet getServletInstance()

Return the Servlet instance used by this ServletHandler

Returns:Servlet

Servlet instance.

Annotations
@SuppressWarnings:UnusedDeclaration
getServletRequestback to summary
pack-priv static HttpServletRequestImpl getServletRequest(final Request request)
getServletResponseback to summary
pack-priv static HttpServletResponseImpl getServletResponse(final Request request)
getSessionCookieNameback to summary
protected String getSessionCookieName()

Overrides org.glassfish.grizzly.http.server.HttpHandler.getSessionCookieName.

Overrides default (JSESSIONID) session cookie name.

Returns:String

the session cookie name

Annotations
@Override
getSessionManagerback to summary
protected SessionManager getSessionManager(Request request)

Overrides org.glassfish.grizzly.http.server.HttpHandler.getSessionManager.

Returns:SessionManager

Servlet-aware SessionManager

Annotations
@Override
loadServletback to summary
protected void loadServlet() throws ServletException

Load a Servlet instance.

Exceptions
ServletException:
If failed to Servlet#init(jakarta.servlet.ServletConfig).
sendAcknowledgmentback to summary
protected boolean sendAcknowledgment(Request request, Response response) throws IOException

Overrides org.glassfish.grizzly.http.server.HttpHandler.sendAcknowledgment.

Override parent's HttpHandler#sendAcknowledgment(org.glassfish.grizzly.http.server.Request, org.glassfish.grizzly.http.server.Response) to let ExpectationHandler (if one is registered) process the expectation.

Annotations
@Override
Exceptions
IOException:

Doc from org.glassfish.grizzly.http.server.HttpHandler.sendAcknowledgment.

if an error occurs sending the acknowledgment.

serviceback to summary
public void service(Request request, Response response) throws Exception

Implements abstract org.glassfish.grizzly.http.server.HttpHandler.service.

Doc from org.glassfish.grizzly.http.server.HttpHandler.service.

This method should contain the logic for any HTTP extension to the Grizzly HTTP web server.

Annotations
@Override
setClassLoaderback to summary
public void setClassLoader(ClassLoader classLoader)
setContextPathback to summary
public void setContextPath(String contextPath)

Programmatically set the context path of the Servlet.

Parameters
contextPath:String

Context path.

setDispatcherHelperback to summary
protected void setDispatcherHelper(final DispatcherHelper dispatcherHelper)

Overrides org.glassfish.grizzly.http.server.HttpHandler.setDispatcherHelper.

Annotations
@Override
setDispatcherPathback to summary
private void setDispatcherPath(final Request request, final String path)
setExpectationHandlerback to summary
public void setExpectationHandler(ExpectationHandler expectationHandler)

Set the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").

Parameters
expectationHandler:ExpectationHandler

the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").

setFilterChainFactoryback to summary
protected void setFilterChainFactory(final FilterChainFactory filterChainFactory)
setPathDataback to summary
protected void setPathData(final Request from, final HttpServletRequestImpl to)
setServletClassback to summary
protected void setServletClass(final Class<? extends Servlet> servletClass)
setServletClassNameback to summary
protected void setServletClassName(final String servletClassName)
setServletInstanceback to summary
protected void setServletInstance(Servlet servletInstance)

Set the Servlet instance used by this ServletHandler

Parameters
servletInstance:Servlet

an instance of Servlet.

setSessionManagerback to summary
protected void setSessionManager(SessionManager sessionManager)

Set the SessionManager instance used by this ServletHandler

Parameters
sessionManager:SessionManager

an implementation of SessionManager.

startback to summary
public void start()

Overrides org.glassfish.grizzly.http.server.HttpHandler.start.

Doc from org.glassfish.grizzly.http.server.HttpHandler.start.

Called when the HttpHandler's container is started by invoking HttpServer#start. By default, it does nothing.

Annotations
@Override
org.glassfish.grizzly.servlet back to summary

pack-priv final Class ServletHandler.AckActionImpl

extends Object
implements AckAction
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.servlet.ExpectationHandler.AckAction

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private final Response

Constructor Summary

AccessConstructor and Description
private
AckActionImpl(final Response response)

Method Summary

Modifier and TypeMethod and Description
public void
acknowledge()

Implements org.glassfish.grizzly.servlet.ExpectationHandler.AckAction.acknowledge.

Acknowledges a client that server wants to receive payload.

public void
fail()

Implements org.glassfish.grizzly.servlet.ExpectationHandler.AckAction.fail.

Notifies a client that server doesn't want to process HTTP message payload.

public boolean
public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

isAcknowledgedback to summary
private boolean isAcknowledged
isFailAcknowledgementback to summary
private boolean isFailAcknowledgement
responseback to summary
private final Response response

Constructor Detail

AckActionImplback to summary
private AckActionImpl(final Response response)

Method Detail

acknowledgeback to summary
public void acknowledge() throws IOException

Implements org.glassfish.grizzly.servlet.ExpectationHandler.AckAction.acknowledge.

Doc from org.glassfish.grizzly.servlet.ExpectationHandler.AckAction.acknowledge.

Acknowledges a client that server wants to receive payload.

Annotations
@Override
failback to summary
public void fail() throws IOException

Implements org.glassfish.grizzly.servlet.ExpectationHandler.AckAction.fail.

Doc from org.glassfish.grizzly.servlet.ExpectationHandler.AckAction.fail.

Notifies a client that server doesn't want to process HTTP message payload.

Annotations
@Override
isAcknowledgedback to summary
public boolean isAcknowledged()
isFailAcknowledgementback to summary
public boolean isFailAcknowledgement()
org.glassfish.grizzly.servlet back to summary

pack-priv final Class ServletHandler.ServletAfterServiceListener

extends Object
implements AfterServiceListener
Class Inheritance
  • java.lang.Object
  • org.glassfish.grizzly.servlet.ServletHandler.ServletAfterServiceListener
All Implemented Interfaces
org.glassfish.grizzly.http.server.AfterServiceListener

AfterServiceListener, which is responsible for recycle servlet request and response objects.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
onAfterService(final Request request)

Implements org.glassfish.grizzly.http.server.AfterServiceListener.onAfterService.

The method will be called once the Request processing will be completed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ServletAfterServiceListenerback to summary
pack-priv ServletAfterServiceListener()

Method Detail

onAfterServiceback to summary
public void onAfterService(final Request request)

Implements org.glassfish.grizzly.http.server.AfterServiceListener.onAfterService.

Doc from org.glassfish.grizzly.http.server.AfterServiceListener.onAfterService.

The method will be called once the Request processing will be completed.

Annotations
@Override