How the exceptions are handled in struts?

Submitted by: Administrator
Exceptions in Struts are handled in two ways:

► Programmatic exception handling :
Explicit try/catch blocks in any code that can throw exception. It works well when custom value (i.e., of variable) needed when error occurs.

► Declarative exception handling :You can either define <global-exceptions> handling tags in your struts-config.xml or define the exception handling tags within <action></action> tag. It works well when custom page needed when error occurs. This approach applies only to exceptions thrown by Actions.

<global-exceptions>
<exception key="some.key"
type="java.lang.NullPointerException"
path="/WEB-INF/errors/null.jsp"/>
</global-exceptions>

or

<exception key="some.key"
type="package.SomeException"
path="/WEB-INF/somepage.jsp"/>
Submitted by: Administrator

Read Online Struts Job Interview Questions And Answers