• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validating data against data in a database

 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to do something as simple as verify a password stored in a database.
Doesn't seem so difficult. I can do it inside of the action associated to the login form easy enough and I can send the user ahead if its right, or back to the login page if its wrong.

The problem I'm having is sending an error message with it. Is there a way to add errors that will show up in the <html:errors/> when the mapping.findForward("failure") is returned from the Action class?

the only "work-around" I've found is to have it throw and exception and to declare the exception in the struts-config file. This seems tedious to create an exception class everytime I want to do this.

-Tad
 
Sheldon Fernandes
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create your own ActionErrors, add your errors to it and save it in request.



You should now get your errors on your jsp using <html:errors />.
Instead of mapping.findForward("failure"), if your failure is same as the page that the input attribute of your action-mapping points to, then you could also use mapping.getInputForward().

Sheldon Fernandes
 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought there had to be an easier way.

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic