Apache Struts Question:
Download Questions PDF

How the exceptions are handled in struts?

Answer:

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"/>

Download Struts Interview Questions And Answers PDF

Previous QuestionNext Question
What are the various Struts tag libraries?What is Struts?