Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In the example applications, the logging is just to the Servlet container's console (see the log4j.xml file for the log settings).

Display Exception Information In Browser

You can display information about the exception in the browser if you want by using s:property tags with a value of exception and exceptionStack. For example in error.jsp is this markup.

Code Block
XML
XML
1error.jsp


   <h4>The application has malfunctioned.</h4>

   <p>  Please contact technical support with the following information:</p> 

   <h4>Exception Name: <s:property value="exception" /> </h4>

   <h4>Exception Details: <s:property value="exceptionStack" /></h4> 

When the exception interceptor is triggered it adds to the fields available for display the exception message and the exception's stack trace.

Summary

Struts 2 provides a easy to use configuration for handling uncaught exceptions and redirecting users to appropriate view pages. You can configure exception handling to be global for all actions or to just for a specific action. You can also enable the Struts 2 framework to log the uncaught exceptions.

...