File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Checked exceptions in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Checked exceptions in struts" Watch "Checked exceptions in struts" New topic

Checked exceptions in struts

vinaykrothapalli kumar

Joined: Aug 29, 2005
Posts: 12
Hi friends
i am new to struts and i have a small doubt
how can we handle the checked exceptions( ex:-- NumberFormat Exception) in struts
please help me
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi kumar

U can handle this exception also .but its not a good practice to do a that....
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

Originally posted by sreenath reddy:
Hi kumar

U can handle this exception also .but its not a good practice to do a that....

I completely disagree about this being a bad practice in general. You should catch and handle any Exception for which you want to display a specific and meaningful error message to the user.

A good workman is known by his tools.
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
i am with marc. handling exceptions is a MUST!

struts has built-in mechanisms (via struts-config.xml mappings) to map exceptions globally or locally (to each action) and forward to a JSP, action, or tiles definition when an exception is thrown. you can also define exception handler for each exception (see ... use the 'path' attribute instead of 'handler' attribute if you want to forward to JSP/action/tiles def).

-/a<br />certified slacker...yes, my last name is 'do' - <a href="" target="_blank" rel="nofollow"></a>
I agree. Here's the link:
subject: Checked exceptions in struts
jQuery in Action, 3rd edition