GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  Struts
Go To First  |  Previous Question  |  Next Question 
 Struts  |  Question 9 of 102    Print  
How you will handle errors and exceptions using Struts

  
Total Answers and Comments: 7 Last Update: September 06, 2007   
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: siva kumar reddy
 

hi,

to handle the errors:

in struts project to handle the error objet by using ActionError object and to handle the errors by using ActionErrors object.

for suppose

ActionError ae1=new ActionError("err.one");

ActionError ae2=new ActionError("err.two");

Action Errors aes=new ActionErrors();

aes.add(ae1);

aes.add(ae2);

saveErrors(request,aes);//store the errors object in request object

to handle exception:

1)using try and cach blocks

2)using declarative exception handling technique

to handle the exceptions by using global exceptons tag in struts-config.xml

<global-exceptions>

<exception key="gen.err" type="java.lang.ClassNotFoundException"  path="/gen.jsp"/>

  whenever that exception will be came it executes the gen.jsp page.            

cheers

siva



Above answer was rated as good by the following members:
pradeepkmr18
June 11, 2005 13:51:18   #1  
abhishek roy        

RE: How you will handle errors and exceptions using Struts
there are various ways to handle exception: 
1) To handle errors server side validation can be used using ActionErrors classes can be used. 
2) The exceptions can be wrapped across different layers to show a user showable exception. 
3)using validators

 
Is this answer useful? Yes | No
July 14, 2005 04:15:54   #2  
Rahul Pundhir        

RE: How you will handle errors and exceptions using Struts
Can you suggest me some good Tutorial for Struts available on the Net. 
 
With Thanks And Regards 
Rahul Pundhir

 
Is this answer useful? Yes | No
July 15, 2005 09:13:58   #3  
me        

RE: How you will handle errors and exceptions using Struts
http://struts.apache.org/userGuide/index.html 
http://www.coreservlets.com/Apache-Struts-Tutorial/

 
Is this answer useful? Yes | No
September 14, 2005 08:38:16   #4  
shreeram        

RE: How you will handle errors and exceptions using St...

To get overall view of error handling in struts (it explains struts portlet framework)

http://www-128.ibm.com/developerworks/websphere/library/techarticles/0411_sriramoju/0411_sriramoju.html


 
Is this answer useful? Yes | No
October 04, 2005 17:56:33   #5  
Anant        

RE: How you will handle errors and exceptions using St...
Strust provides ActionError object. Store each error msg by converting them to ActionErrors obj. Then save this obj in the request by calling saveError method of the ActionServlet.In the JSP use tag to show the error msg.
 
Is this answer useful? Yes | No
May 12, 2006 03:40:30   #6  
abdul khalik        

RE: How you will handle errors and exceptions using St...

Hi All

I struts we can handle the exceptions using

1) validations: here we validate inputs and contron will be transfered to the input page of the action as per the validation rule voilation or we can simply validate the values in action class and send the contron on to desired page. 

2) using declarative Exception Handling: in deployment descriptor we can declare on which type of exception request should be redirected to which page.

Waiting for comments.

Thaks

Abdul


 
Is this answer useful? Yes | No
August 04, 2006 04:22:07   #7  
siva kumar reddy        

RE: How you will handle errors and exceptions using St...

hi,

to handle the errors:

in struts project to handle the error objet by using ActionError object and to handle the errors by using ActionErrors object.

for suppose

ActionError ae1=new ActionError("err.one");

ActionError ae2=new ActionError("err.two");

Action Errors aes=new ActionErrors();

aes.add(ae1);

aes.add(ae2);

saveErrors(request,aes);//store the errors object in request object

to handle exception:

1)using try and cach blocks

2)using declarative exception handling technique

to handle the exceptions by using global exceptons tag in struts-config.xml

<global-exceptions>

<exception key="gen.err" type="java.lang.ClassNotFoundException"  path="/gen.jsp"/>

  whenever that exception will be came it executes the gen.jsp page.            

cheers

siva


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape