Global Exception Handling
– To implement global exception handling include the given struts.xml file. This will map exceptions of all action classes

Global Exception Configuration

Action Level Exception handling
– To implement action level exception handling add <exception-mapping> elements within the <action> element of the struts.xml file

Action Level Exception Configuration

Will redirect to DBError.jsp when action “connectDB" throws any exception

Exception Handling: Struts 2 (Cont’d)

Logging Exception
– Log exceptions to page and/or log files
– To enable logging declare an interceptor as shown:

Enable Logging

Note: The code snippet should be included in struts.xml