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 Questions on Struts 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 "Questions on Struts" Watch "Questions on Struts" New topic
Author

Questions on Struts

Mike Yu
Ranch Hand

Joined: Nov 17, 2001
Posts: 175
Hi,

I am new to Struts. I have some questions that may be simple to you.
(1) How do you validate user input in Struts?
(2) What uniquely identifies an Action element, for example, name, path or something else?
(3) Does the reset in ActionForm set properties to the initial values or to the request parameters?


Thanks,<br />Mike
John Smith
Ranch Hand

Joined: Sep 02, 2004
Posts: 61
You can validate in the validate method and return an error if the data is invalid.

The reset method should be used to reset checkboxes only as their state is only forwarded on a submit if they are checked.

You should initialise your stuff within action classes, see my posting here:
http://www.coderanch.com/t/49471/Struts/action-class
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30068
    
149

Mike,
2) The path is what needs to be unique. You can the same action class servicing several types of requests by changing the form bean or forward.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
 
subject: Questions on Struts
 
Similar Threads
doubt in struts
Validator Struts not is loading in browser
HTTP Status 404 - Servlet action is not available
aceessing getPropery(int index) thru Equals tag
Servlet Exception