Package org.opencms.main
Class OpenCmsServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- org.opencms.main.OpenCmsServlet
-
- All Implemented Interfaces:
java.io.Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
,I_CmsRequestHandler
- Direct Known Subclasses:
OpenCmsServletErrorHandler
public class OpenCmsServlet extends javax.servlet.http.HttpServlet implements I_CmsRequestHandler
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 aCmsUser
with this users context information is created. ThisCmsObject
is 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 OpenCmsCmsResource
implementations 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 theCmsJspLoader
etc.CmsDumpLoader
- Since:
- 6.0.0
- See Also:
CmsShell
,CmsObject
,OpenCms
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.ThreadLocal<javax.servlet.http.HttpServletRequest>
currentRequest
The current request in a threadlocal.static java.lang.String
HANDLE_GWT
GWT RPC services suffix.static java.lang.String
HANDLE_PATH
Handler prefix.static java.lang.String
SERVLET_PARAM_DEFAULT_WEB_APPLICATION
Name of theDefaultWebApplication
parameter in theweb.xml
OpenCms servlet configuration.static java.lang.String
SERVLET_PARAM_OPEN_CMS_HOME
Name of theOpenCmsHome
parameter in theweb.xml
OpenCms servlet configuration.static java.lang.String
SERVLET_PARAM_OPEN_CMS_SERVLET
Name of theOpenCmsServlet
parameter in theweb.xml
OpenCms servlet configuration.static java.lang.String
SERVLET_PARAM_WEB_APPLICATION_CONTEXT
Name of theWebApplicationContext
parameter in theweb.xml
OpenCms servlet configuration.
-
Constructor Summary
Constructors Constructor Description OpenCmsServlet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
OpenCms servlet main request handling method.void
doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
OpenCms servlet POST request handling method, will just calldoGet(HttpServletRequest, HttpServletResponse)
.java.lang.String[]
getHandlerNames()
Returns the handler name.void
handle(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.lang.String name)
Handles an OpenCms request.void
init(javax.servlet.ServletConfig config)
protected void
invokeHandler(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
Manages requests to internal OpenCms request handlers.protected void
openErrorHandler(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.-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
-
-
-
-
Field Detail
-
currentRequest
public static final java.lang.ThreadLocal<javax.servlet.http.HttpServletRequest> currentRequest
The current request in a threadlocal.
-
HANDLE_GWT
public static final java.lang.String HANDLE_GWT
GWT RPC services suffix.- See Also:
- Constant Field Values
-
HANDLE_PATH
public static final java.lang.String HANDLE_PATH
Handler prefix.- See Also:
- Constant Field Values
-
SERVLET_PARAM_DEFAULT_WEB_APPLICATION
public static final java.lang.String SERVLET_PARAM_DEFAULT_WEB_APPLICATION
Name of theDefaultWebApplication
parameter in theweb.xml
OpenCms servlet configuration.- See Also:
- Constant Field Values
-
SERVLET_PARAM_OPEN_CMS_HOME
public static final java.lang.String SERVLET_PARAM_OPEN_CMS_HOME
Name of theOpenCmsHome
parameter in theweb.xml
OpenCms servlet configuration.- See Also:
- Constant Field Values
-
SERVLET_PARAM_OPEN_CMS_SERVLET
public static final java.lang.String SERVLET_PARAM_OPEN_CMS_SERVLET
Name of theOpenCmsServlet
parameter in theweb.xml
OpenCms servlet configuration.- See Also:
- Constant Field Values
-
SERVLET_PARAM_WEB_APPLICATION_CONTEXT
public static final java.lang.String SERVLET_PARAM_WEB_APPLICATION_CONTEXT
Name of theWebApplicationContext
parameter in theweb.xml
OpenCms servlet configuration.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OpenCmsServlet
public OpenCmsServlet()
-
-
Method Detail
-
doGet
public void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws java.io.IOException, javax.servlet.ServletException
OpenCms servlet main request handling method.- Overrides:
doGet
in classjavax.servlet.http.HttpServlet
- Throws:
java.io.IOException
javax.servlet.ServletException
- See Also:
HttpServlet.doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
-
doPost
public void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws java.io.IOException, javax.servlet.ServletException
OpenCms servlet POST request handling method, will just calldoGet(HttpServletRequest, HttpServletResponse)
.- Overrides:
doPost
in classjavax.servlet.http.HttpServlet
- Throws:
java.io.IOException
javax.servlet.ServletException
- See Also:
HttpServlet.doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
-
getHandlerNames
public java.lang.String[] getHandlerNames()
Description copied from interface:I_CmsRequestHandler
Returns the handler name.- Specified by:
getHandlerNames
in interfaceI_CmsRequestHandler
- Returns:
- the handler name
- See Also:
I_CmsRequestHandler.getHandlerNames()
-
handle
public void handle(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.lang.String name) throws java.io.IOException, javax.servlet.ServletException
Description copied from interface:I_CmsRequestHandler
Handles an OpenCms request.- Specified by:
handle
in interfaceI_CmsRequestHandler
- Parameters:
req
- the current requestres
- the current responsename
- the handler name to invoke- Throws:
java.io.IOException
- in case an error occursjavax.servlet.ServletException
- in case an error occurs- See Also:
I_CmsRequestHandler.handle(HttpServletRequest, HttpServletResponse, String)
-
init
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
- Specified by:
init
in interfacejavax.servlet.Servlet
- Overrides:
init
in classjavax.servlet.GenericServlet
- Throws:
javax.servlet.ServletException
- See Also:
Servlet.init(javax.servlet.ServletConfig)
-
invokeHandler
protected void invokeHandler(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws java.io.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 occursjava.io.IOException
- in case an error occurs
-
openErrorHandler
protected void openErrorHandler(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, int errorCode) throws java.io.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:
java.io.IOException
- if something goes wrongjavax.servlet.ServletException
- if something goes wrong
-
-