cancel
Showing results for 
Search instead for 
Did you mean: 

Modidy the Web Dispatcher Error message

Former Member
0 Kudos

Hi,

Where do we modify the web dispatcher error message "500 Dispatching error" to a cutome message on the J2EE?

Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

please refer to note 795699

Oliver_S
Advisor
Advisor
0 Kudos

note says:

Customization of 500 Internal Server Error

This response code is returned when there is a problem with the application or the server. Any not handled Exception or Error triggers the return of response with code 500.

To return different content on error occurance, you need to handle the error by inserting the appropriate declaration in web.xml.

Sample declaration for handling of test.MyApplicationException occurances in the application scope:

<error-page>

<exception-type>test.MyApplicationException< /exception-type>

<location>/customerrors/MyApplicationException.jsp</location>

</error-page>

Note1: For each error condition you need to handle (application exception use a separate error page. For all other exceptions use a global error handling definition for java.lang.Throwable.

However you must be aware of the following:

In case java.lang.OutOfMemoryError appears the subsequent behaviour of the JVM is undefined and this may lead to unpredicatable effects. Therefore the webcontainer will not pass such error to the error page for handling.

If the following general definition

<error-page>

<exception-type>java.lang.Throwable< /exception-type>

<location>/customerrors/WhateverProblem.jsp</location>

</error-page>

is in place, then the error handler resource is responsible for logging the error condition.

This means the resource handling general problems if such is declared must be dynamic (a JSP page or a servlet not HTML page)

Note2: Exceptions are searched in order of appearance in web. xml and not determining closest in class hierarchy.

This is true for all patchlevels of J2EE Engine 6.20 and versions of J2EE Engine 6.40 lower than SP11.

Therefore if test.ChildException extends test.ParentException extends java.lang.Exception and

<error-page>

<exception-type>test.ParentException</exception-type>

<location>/customerrors/ParentException.jsp</location>

</error-page>

<error-page>

<exception-type>test.ChildException</exception-type>

<location>/customerrors/ChildException.jsp</location>

</error-page>

is specified in the web.xml of the application as exceptions are searched in order of appearance regardless if ChildException or ParentException is thrown, the call will be directed to /Customerrors/ParentException.jsp because ChildException is a subclass of ParentException..

Working mapping would be :

<error-page>

<exception-type>test.ChildException</exception-type>

<location>/customerrors/ChildException.jsp</location>

</error-page>

<error-page>

<exception-type>test.ParentException</exception-type>

<location>/customerrors/ParentException.jsp</location>

</error-page>

so you need to switch the declarations in the web.xml (effective on next start of the application).

BR, Oliver

Answers (0)