Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception Handling

 
shilpi_s
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 326
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could also do declarative exception handling in the struts config file.

 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic