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"/>
The various Struts tag libraries are:
► HTML Tags
► Bean Tags
► Logic Tags
► Template Tags
► Nested Tags
► Tiles Tags
<html:errors/> tag displays all the errors. <html:errors/> iterates over ActionErrors request attribute.
A specialized subclass of ActionForm that allows the creation of form beans with dynamic sets of properties (configured in configuration file), without requiring the developer to create a Java class for each type of form bean.
The SwitchAction class provides a means to switch from a resource in one module to another resource in a different module. SwitchAction is useful only if you have multiple modules in your Struts application. The SwitchAction class can be used as is, without extending.
Webmaster 20th of May 2012
Tell us what you feel about Apache Struts Interview Questions and Answers
All comments will be published after review. No login or registration is required to post a comment on Apache Struts Interview Questions and Answers We offer and invite you to submit your valuable comment now; Please be respectful of others when commenting. Insulting others, self-promotional comments, website promotional comments, marketing stuff, SEO Techniques, SMS-style content and off-topic comments will not be approved at this information portal.
So start sharing your thoughts regarding Apache Struts Interview Questions and Answers
Thank you.