This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Validating data against data in a database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Validating data against data in a database" Watch "Validating data against data in a database" New topic
Author

Validating data against data in a database

Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
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

Joined: Aug 18, 2004
Posts: 157
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

Joined: Nov 16, 2004
Posts: 264
I thought there had to be an easier way.

Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validating data against data in a database
 
Similar Threads
button action command from keylistener
Dispatch action
Session
How can Action class will get access to HttpServletRequest to access data??
login servlet