Class CmsJspStatusBean
The JSPs using this bean are placed in the OpenCms VFS folder /system/handler/.
- Since:
- 6.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Request attribute key for the error message.static final String
Request attribute key for the error request URI.static final String
Request attribute key for the error servlet name.static final String
Request attribute key for the error status code.static final String
Default name for an unknown error status code.static final String
The OpenCms VFS path containing the handler files.Fields inherited from class org.opencms.jsp.CmsJspActionElement
NOT_INITIALIZED
-
Constructor Summary
ConstructorDescriptionEmpty constructor, required for every JavaBean.CmsJspStatusBean
(javax.servlet.jsp.PageContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) Constructor, with parameters.CmsJspStatusBean
(javax.servlet.jsp.PageContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, Throwable t) Constructor, with parameters. -
Method Summary
Modifier and TypeMethodDescriptionboolean
forwardToErrorPage
(String rootPath) Deprecated.will not work for container pages and other pages using cms:include tagsReturns the error message.Returns the exception.Returns the locale to use for the error page.protected Object[]
Returns the parameter object for localization.protected CmsMessages
Returns the initialized messages object to read localized messages from.getPageContent
(String element) Returns the processed output of the specified element of an OpenCms page.Returns the absolute path of the requested resource in the VFS of OpenCms.Returns the request Uri.getResourceUri
(String resourceName) Returns the full Workplace resource path to the selected resource.Returns the servlet name.Returns the site root of the requested resource.Returns the status code.Returns the status code message.Returns the URI used for template part inclusion.void
includeTemplatePart
(String target, String element) Include a template part to display on the error page.void
Include a template part to display on the error page.protected void
initMembers
(javax.servlet.http.HttpServletRequest req, Throwable t) Initializes the members of this bean with the information retrieved from the current request.Returns the localized resource string for a given message key.Returns the localized resource string for a given message key.Returns the localized resource string for a given message key depending on the HTTP status.void
Writes the exception into the 'opencms.log', if the exception is notnull
.protected void
setErrorMessage
(String errorMessage) Sets the error message.protected void
setException
(Throwable exception) Sets the exception.protected void
Sets the locale to use for the error page.protected void
setLocalizeParameters
(Object[] localizeParameters) Sets the parameter object for localization.protected void
setMessages
(CmsMessages messages) Sets the initialized messages object to read localized messages from.protected void
setRequestUri
(String requestUri) Sets the request Uri.protected void
setServletName
(String servletName) Sets the servlet name.protected void
setSiteRoot
(String siteRoot) Sets the site root of the requested resource.protected void
setStatusCode
(Integer statusCode) Sets the status code.protected void
setStatusCodeMessage
(String statusCodeMessage) Sets the status code message.void
setTemplateUri
(String templateUri) Sets the URI used for template part inclusion.boolean
Returns true if the current user has the "DEVELOPER" role and can view the exception stacktrace.Methods inherited from class org.opencms.jsp.CmsJspActionElement
editable, editable, editable, editableManualClose, editableManualOpen, getContent, getContent, getMessages, getMessages, getMessages, getMessages, getNavigation, getNavigationUri, img, img, include, include, include, include, include, include, includeSilent, includeSilent, includeSilent, includeSilent, info, label, link, link, properties, properties, property, property, property, property, template, template, template, toAbsolute, user
Methods inherited from class org.opencms.jsp.CmsJspBean
getCmsObject, getController, getJspContext, getMessage, getRequest, getRequestContext, getResponse, handleException, handleMissingFlexController, init, isNotInitialized, isSupressingExceptions, setContentType, setStatus, setSupressingExceptions
-
Field Details
-
ERROR_MESSAGE
Request attribute key for the error message.- See Also:
-
ERROR_REQUEST_URI
Request attribute key for the error request URI.- See Also:
-
ERROR_SERVLET_NAME
Request attribute key for the error servlet name.- See Also:
-
ERROR_STATUS_CODE
Request attribute key for the error status code.- See Also:
-
UNKKNOWN_STATUS_CODE
Default name for an unknown error status code.- See Also:
-
VFS_FOLDER_HANDLER
The OpenCms VFS path containing the handler files.- See Also:
-
-
Constructor Details
-
CmsJspStatusBean
public CmsJspStatusBean()Empty constructor, required for every JavaBean. -
CmsJspStatusBean
public CmsJspStatusBean(javax.servlet.jsp.PageContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) Constructor, with parameters.- Parameters:
context
- the JSP page context objectreq
- the JSP requestres
- the JSP response
-
CmsJspStatusBean
public CmsJspStatusBean(javax.servlet.jsp.PageContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, Throwable t) Constructor, with parameters.- Parameters:
context
- the JSP page context objectreq
- the JSP requestres
- the JSP responset
- the exception that lead to the error
-
-
Method Details
-
forwardToErrorPage
Deprecated.will not work for container pages and other pages using cms:include tagsTries to forward to the configured error page for the current site root if present.- Parameters:
rootPath
- the resource to be used as error page- Returns:
true
if the forward was successful performed,false
otherwise
-
getErrorMessage
Returns the error message.- Returns:
- the error message
-
getException
Returns the exception.- Returns:
- the exception
-
getLocale
Returns the locale to use for the error page.- Returns:
- the locale to use for the error page
-
getPageContent
Returns the processed output of the specified element of an OpenCms page.The page to get the content from is looked up in the property value "template-elements". If no value is found, the page is read from the "contents/" subfolder of the handler folder.
For each status code, an individual page can be created by naming it "content${STATUSCODE}.html". If the individual page can not be found, the content is read from "contentunknown.html".
- Parameters:
element
- name of the element- Returns:
- the processed output of the specified element of an OpenCms page
-
getRequestResourceName
Returns the absolute path of the requested resource in the VFS of OpenCms.- Returns:
- the absolute path of the requested resource in the VFS of OpenCms
-
getRequestUri
Returns the request Uri.- Returns:
- the request Uri
-
getResourceUri
Returns the full Workplace resource path to the selected resource.- Parameters:
resourceName
- the name of the resource to get the resource path for- Returns:
- the full Workplace resource path to the selected resource
-
getServletName
Returns the servlet name.- Returns:
- the servlet name
-
getSiteRoot
Returns the site root of the requested resource.- Returns:
- the site root of the requested resource
-
getStatusCode
Returns the status code.- Returns:
- the status code
-
getStatusCodeMessage
Returns the status code message.- Returns:
- the status code message
-
getTemplateUri
Returns the URI used for template part inclusion.- Returns:
- the URI used for template part inclusion
-
includeTemplatePart
public void includeTemplatePart(String target, String element) throws javax.servlet.jsp.JspException Include a template part to display on the error page.- Parameters:
target
- the target uri of the file in the OpenCms VFS (can be relative or absolute)element
- the element (template selector) to display from the target- Throws:
javax.servlet.jsp.JspException
- in case there were problems including the target
-
includeTemplatePart
public void includeTemplatePart(String target, String element, Map<String, Object> parameterMap) throws javax.servlet.jsp.JspExceptionInclude a template part to display on the error page.- Parameters:
target
- the target uri of the file in the OpenCms VFS (can be relative or absolute)element
- the element (template selector) to display from the targetparameterMap
- a map of the request parameters- Throws:
javax.servlet.jsp.JspException
- in case there were problems including the target
-
key
Returns the localized resource string for a given message key.If the key was not found in the bundle, the return value is
"??? " + keyName + " ???"
.The key can use the following parameters for formatting:
- 0: the HTTP status code
- 1: the requested URI
- 2: the generated error message
- 3: the servlet name
- 4: the date of the request
- Parameters:
keyName
- the key for the desired string- Returns:
- the resource string for the given key
-
key
Returns the localized resource string for a given message key.For a detailed parameter description, see
key(String)
.- Parameters:
keyName
- the key for the desired stringdefaultKeyName
- the default key for the desired string, used if the keyName delivered no resource string- Returns:
- the resource string for the given key
-
keyStatus
Returns the localized resource string for a given message key depending on the HTTP status.Automatically adds a status suffix for the key to get, eg. "keyname" gets the suffix "_404" for a 404 status. For a detailed parameter description, see
key(String)
.- Parameters:
keyName
- the key for the desired string- Returns:
- the resource string for the given key
-
logException
Writes the exception into the 'opencms.log', if the exception is notnull
. -
setTemplateUri
Sets the URI used for template part inclusion.- Parameters:
templateUri
- the URI used for template part inclusion
-
showException
Returns true if the current user has the "DEVELOPER" role and can view the exception stacktrace.- Returns:
- true if the current user has the "DEVELOPER" role and can view the exception stacktrace
-
getLocalizeParameters
Returns the parameter object for localization.- Returns:
- the parameter object for localization
- See Also:
-
getMessages
Returns the initialized messages object to read localized messages from.- Returns:
- the initialized messages object to read localized messages from
-
initMembers
Initializes the members of this bean with the information retrieved from the current request.- Parameters:
req
- the JSP requestt
- the exception that lead to the error
-
setErrorMessage
Sets the error message.- Parameters:
errorMessage
- the error message to set
-
setException
Sets the exception.- Parameters:
exception
- the exception to set
-
setLocale
Sets the locale to use for the error page.- Parameters:
locale
- the locale to use for the error page
-
setLocalizeParameters
Sets the parameter object for localization.- Parameters:
localizeParameters
- the parameter object for localization
-
setMessages
Sets the initialized messages object to read localized messages from.- Parameters:
messages
- the initialized messages object to read localized messages from
-
setRequestUri
Sets the request Uri.- Parameters:
requestUri
- the request Uri to set
-
setServletName
Sets the servlet name.- Parameters:
servletName
- the servlet name to set
-
setSiteRoot
Sets the site root of the requested resource.- Parameters:
siteRoot
- the site root of the requested resource
-
setStatusCode
Sets the status code.- Parameters:
statusCode
- the status code to set
-
setStatusCodeMessage
Sets the status code message.- Parameters:
statusCodeMessage
- the status code message to set
-