1600 PMP mock questions 1400 CAPM mock questions 800 SCJP 6 mock questions 600 OCAJP 7 mock questions 590 OCPJP 7 mock questions 556 SCWCD 5 mock questions 500 OCEJWCD 6 mock questions pdfDownload (java,struts, hibernet etc)
Java online test
JSP online test
ORACLE online test
Hibernate online test
Servlet online test
Struts online test
EJB online test
C online test
C++ online test
Aptitude online test

Q.How you can do Exception Handling in Struts ?

There are two approaches available for the exception handling in struts.


Declarative:
Exceptions are defined in the struts-config.xml file and
if the exception occurs the control is automatically passed to the appropriate error page.
The <exception> tag is used to define the exception in the struts-config.xml file.

For Example : (( If RuntimeException in SaveEmpAaction class , control goes to exception.jsp)

<action path="/saveEmp"
type="com.techfaq.SaveEmpAaction"
input="/empform.jsp" >
<exception key="error.system" type="java.lang.RuntimeException" path="/exception.jsp" />
</action>

Where

Key: The key defines the key present in MessageResources.properties file to describe the exception occurred.

Type: The class of the exception occurred.

Path: The page where the control is to be followed in case exception occurred.

Handler: The exception handler which will be called before passing the control to the file specified in path attribute

OR


Defining the Exceptions Globally for the struts-config.xml : ( If RuntimeException in any Action class , control goes to exception.jsp)
<global-exceptions>
<exception key="error.system" type="java.lang.RuntimeException" path="/exception.jsp" />
</global-exceptions>


Programmatic:
In this approach the exceptions are caught using normal java language try/catch block and instead of showing the exception some meaningful messages are displayed.
In this approach the flow of control is also maintained by the programs.
The main drawback of the approach is the developer has to write the code for the flow of the application.

Online Practice Test

Java online test
JSP online test
ORACLE online test
Hibernate online test
Servlet online test
Struts online test
EJB online test
C online test
C++ online test
Aptitude online test

Reviews and Comments


PMP, CAPM, PMI is a registered certification mark of the Project Management Institute, Inc

Copyright © www.techfaq360.com 2016


About US | Contact US | Privacy Policy | Terms and Conditions  | Website disclaimer  | Cancellation and Refund Policy  | Shipping & Delivery Policy