Package org.opencms.main
Class OpenCmsServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.opencms.main.OpenCmsServlet
- All Implemented Interfaces:
Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig,I_CmsRequestHandler
- Direct Known Subclasses:
OpenCmsServletErrorHandler
This the main servlet of the OpenCms system.
From here, all operations that are results of HTTP requests are invoked. Any incoming request is handled in multiple steps:
- The requesting
is authenticated and aCmsUserwith this users context information is created. ThisCmsObjectis used to access all functions of OpenCms, limited by the authenticated users permissions. If the user is not identified, it is set to the default user, usually named "Guest".CmsObject - The requested
is loaded into OpenCms and depending on its type (and the users persmissions to display or modify it), it is send to one of the OpenCmsCmsResourceimplementations do be processed.I_CmsResourceLoader -
The
will then decide what to do with the contents of the requestedI_CmsResourceLoader. In case of a JSP resource the JSP handling mechanism is invoked with theCmsResource, in case of an image (or another static resource) this will be returned by theCmsJspLoaderetc.CmsDumpLoader
- Since:
- 6.0.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classContext class for storing request-dependent caches etc.static classDebugging information about currently running requests. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ConcurrentHashMap<CmsUUID, OpenCmsServlet.RequestInfo> Map containing beans with information about currently running requests.static final CmsThreadLocalStack<javax.servlet.http.HttpServletRequest> The current request in a threadlocal.static final StringURL prefix for the built-in service handler.static final StringGWT RPC services suffix.static final StringHandler prefix.static final StringName of theDefaultWebApplicationparameter in theweb.xmlOpenCms servlet configuration.static final StringName of theOpenCmsHomeparameter in theweb.xmlOpenCms servlet configuration.static final StringName of theOpenCmsServletparameter in theweb.xmlOpenCms servlet configuration.static final StringName of theWebApplicationContextparameter in theweb.xmlOpenCms servlet configuration. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddoGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) OpenCms servlet main request handling method.voiddoPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) OpenCms servlet POST request handling method, will just calldoGet(HttpServletRequest, HttpServletResponse).String[]Returns the handler name.static OpenCmsServlet.RequestCacheGets a thread-local, request-specific context object for requests made to the OpenCms servlet.voidhandle(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, String name) Handles an OpenCms request.voidinit(javax.servlet.ServletConfig config) protected voidinvokeHandler(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) Manages requests to internal OpenCms request handlers.protected voidopenErrorHandler(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, int errorCode) Displays an error code handler loaded from the OpenCms VFS, or if such a page does not exist, displays the default servlet container error code.static voidHelper method used to conveniently access the request cache, does nothing if the request cache isn't set.Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, serviceMethods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, logMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.opencms.main.I_CmsRequestHandler
getConfiguration, initParameters
-
Field Details
-
currentRequestStack
The current request in a threadlocal. -
activeRequests
Map containing beans with information about currently running requests. -
HANDLE_GWT
GWT RPC services suffix.- See Also:
-
HANDLE_PATH
Handler prefix.- See Also:
-
SERVLET_PARAM_DEFAULT_WEB_APPLICATION
Name of theDefaultWebApplicationparameter in theweb.xmlOpenCms servlet configuration.- See Also:
-
SERVLET_PARAM_OPEN_CMS_HOME
Name of theOpenCmsHomeparameter in theweb.xmlOpenCms servlet configuration.- See Also:
-
SERVLET_PARAM_OPEN_CMS_SERVLET
Name of theOpenCmsServletparameter in theweb.xmlOpenCms servlet configuration.- See Also:
-
SERVLET_PARAM_WEB_APPLICATION_CONTEXT
Name of theWebApplicationContextparameter in theweb.xmlOpenCms servlet configuration.- See Also:
-
HANDLE_BUILTIN_SERVICE
URL prefix for the built-in service handler.- See Also:
-
-
Constructor Details
-
OpenCmsServlet
public OpenCmsServlet()
-
-
Method Details
-
getRequestCache
Gets a thread-local, request-specific context object for requests made to the OpenCms servlet.- Returns:
- the thread context
-
withRequestCache
Helper method used to conveniently access the request cache, does nothing if the request cache isn't set.- Parameters:
handler- the handler to pass the request cache to
-
doGet
public void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws IOException, javax.servlet.ServletException OpenCms servlet main request handling method.- Overrides:
doGetin classjavax.servlet.http.HttpServlet- Throws:
IOExceptionjavax.servlet.ServletException- See Also:
-
doPost
public void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws IOException, javax.servlet.ServletException OpenCms servlet POST request handling method, will just calldoGet(HttpServletRequest, HttpServletResponse).- Overrides:
doPostin classjavax.servlet.http.HttpServlet- Throws:
IOExceptionjavax.servlet.ServletException- See Also:
-
getHandlerNames
Description copied from interface:I_CmsRequestHandlerReturns the handler name.- Specified by:
getHandlerNamesin interfaceI_CmsRequestHandler- Returns:
- the handler name
- See Also:
-
handle
public void handle(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, String name) throws IOException, javax.servlet.ServletException Description copied from interface:I_CmsRequestHandlerHandles an OpenCms request.- Specified by:
handlein interfaceI_CmsRequestHandler- Parameters:
req- the current requestres- the current responsename- the handler name to invoke- Throws:
IOException- in case an error occursjavax.servlet.ServletException- in case an error occurs- See Also:
-
init
- Specified by:
initin interfacejavax.servlet.Servlet- Overrides:
initin classjavax.servlet.GenericServlet- Throws:
javax.servlet.ServletException- See Also:
-
invokeHandler
protected void invokeHandler(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws IOException, javax.servlet.ServletException Manages requests to internal OpenCms request handlers.- Parameters:
req- the current requestres- the current response- Throws:
javax.servlet.ServletException- in case an error occursjavax.servlet.ServletException- in case an error occursIOException- in case an error occurs
-
openErrorHandler
protected void openErrorHandler(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, int errorCode) throws IOException, javax.servlet.ServletException Displays an error code handler loaded from the OpenCms VFS, or if such a page does not exist, displays the default servlet container error code.- Parameters:
req- the current requestres- the current responseerrorCode- the error code to display- Throws:
IOException- if something goes wrongjavax.servlet.ServletException- if something goes wrong
-