This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes Exception Handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Exception Handling" Watch "Exception Handling" New topic
Author

Exception Handling

shilpi_s
Greenhorn

Joined: Jan 04, 2004
Posts: 2
Can anyone tell me how to do exception handling in struts. ?For example if a field already exists in database...the user should get a msg as "data already exists".
Ray Stojonic
Ranch Hand

Joined: Aug 08, 2003
Posts: 326
I do something along the following:
error occurs
create ActionErrors object
create ActionMessage with error text
add ActionMessage to ActionErrors object
add ActionErrors to request
return to page request originated from
pick up ActionErrors object with <logic:messagesPresent> tag in jsp
display error to user
Rick Hightower
Author
Ranch Hand

Joined: Feb 20, 2002
Posts: 350
You could also do declarative exception handling in the struts config file.



Rick Hightower is CTO of Mammatus which focuses on Cloud Computing, EC2, etc. Rick is invovled in Java CDI and Java EE as well. linkedin,twitter,blog
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
"shilpi_s",
Please take a moment for reading our naming policy. As it stands, your display name fails to comply with the policy so I'll have to ask you to change it accordingly.
More specifically, the policy allows the use of initials only for the first name, not the last name. You should also use a space instead of the underscore character.
Thanks. And welcome to the JavaRanch!


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
wood burning stoves
 
subject: Exception Handling
 
Similar Threads
How long should this take full time?
Error transforming using TransformerHandler
Exception handling using hibernate template in Spring framework
Implementation Opinions Wanted...
java [question -- exception handling]