6.2.4. HTTP Error Control Handler

This handler performs log output and conversion to response for the exception that occurred in the subsequent handler.

This handler performs the following processes.

The process flow is as follows.

../../../../_images/flow24.png Module list

</dependency> Constraints

Place this handler after the HTTP Response Handler
Since HTTP response handler processes HttpResponse generated by this handler, it must be placed after HTTP Response Handler.
Place this handler after the HTTP Access Log Handler
Since log output is based on HttpResponse generated by this handler for error, it must be placed after HTTP Access Log Handler. Processing according to the exception type and generation of response

Log level:INFO
Description:It is recorded as a trace log since it means that the handler to process the request is not available. The response is configured to 404 because it means that the action class to be processed was not available.
Log level:

No log output




Log is not output because it means that a business exception (error response is thrown as a result of validation, etc.) was thrown in a subsequent handler.

If the cause of HttpErrorResponse exception is ApplicationException, perform the following process so that error message can be handled in view.

  1. Message information held by ApplicationException is converted to ErrorMessages.

  2. Configure ErrorMessages in the request scope. The key name when configuring to the request scope is errors by default. The key name can be changed in the component configuration file.

    Configuration example
    <component name="webConfig" class="nablarch.common.web.WebConfig">
      <!-- Change key to messages -->
      <property name="errorMessageRequestAttributeName" value="messages" />
Log level:Depends on the configuration
Description:See Log output of nablarch.fw.Result.Error .
Log level:FATAL
Description:Since it may be caused by a data or implementation bug, notified as a failure. The response is 500 because it is an unexpected error.
java.lang.ThreadDeath and java.lang.VirtualMachineError ( other than java.lang.StackOverflowError )
Log level:-
Description:This handler does nothing and leaves the processing to the upper handler. (Resend error)
Exceptions and errors other than the above
Log level:FATAL
Description:For exceptions and errors that do not correspond to the above, log is output as a failure. The response is 500 because it is an unexpected exception or error. Log output of nablarch.fw.Result.Error

If the exception raised in the subsequent handler is Error, then whether to output the log changes depending on the value configured in writeFailureLogPattern. A regular expression can be configured to this property, and if the regular expression matches Error#getStatusCode(), a FATAL level log is output. Configuration of the default page

Apply the default page to the HttpResponse created by error handling in subsequent handlers and this handler. In this function, if HttpResponse is not configured, apply the default page configured by defaultPage and defaultPages.

A configuration example is shown below.

<component class="nablarch.fw.web.handler.HttpErrorHandler">
  <property name="defaultPages">
      <entry key="4.." value="/USER_ERROR.jsp" />
      <entry key="404" value="/NOT_FOUND.jsp" />
      <entry key="5.." value="/ERROR.jsp" />
      <entry key="503" value="/NOT_IN_SERVICE.jsp" />


When this function is used, JSP configuration must be duplicated with the error page configuration (error-page element) for web.xml specified by the Servlet API. If web.xml is not configured, the default error page of the web server will be displayed based on where the error occurred.

Therefore, configuring the default error page in web.xml instead of using this function is recommended.