views:

26

answers:

1

Hi all,

From a security standpoint, what is the best solution to handle application errors with Websphere?

I've been thinking of creating a class that is called every time an application error is generated, log the error and display a generic error message to the users.

In PHP this can be achieved using the set_exception_handler() function. Is there something similar for websphere that could be configured in the web.xml?

I've found codes like this on the internet:

<error-page>
  <error-code>500</error-code>
  <location>/servlet/ExceptionHandlerServlet</location>
</error-page>

But that would only work with "500" HTTP error codes. I really want something generic that catches everything. Something like a class that implements a certain interface which can have access to all information about the error.

Thanks for your time.

+1  A: 

This is also available in web.xml:

 <error-page>
   <exception-type>UnhandledException</exception-type>
   <location>UnhandledException.jsp</location>
 </error-page>

Among other places, this is used in this WebSphere example. The JEE5 tutorial may also be helpful in setting this up, particularly the part about mapping servlet exceptions and creating JSP error pages.

Essentially, all of your exceptions should be wrapped in ServletExceptions and the JSP you map to should have <%@ page isErrorPage="true" %> set at the very top of the page.

ig0774