This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes Redirecting to the JSP when validation error occurs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Redirecting to the JSP when validation error occurs" Watch "Redirecting to the JSP when validation error occurs" New topic
Author

Redirecting to the JSP when validation error occurs

Srilakshmi Vara
Ranch Hand

Joined: Jul 21, 2004
Posts: 169
Hello All,

Thanks for your suggestions before.

Have another question!

I am populated a page using some database values, if user enters some values upon that and submits the form i am redirecting to .do(which populates with DB values) but i am loosing user entered values, if i redirect to the jsp i am getting null pointer exception on populated field values.

What to do in this scenario?

Thanks in advance,
Srilakshmi
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
create a 3rd action mapping that is mapped to the same form-bean definition and used this new mapping (uri) as your 'input' attribute for the action where you set validation to true. in essense, you'll have 3 mappings (a bit ugly, yes):

1. /myaction/entry.do (name="MyForm") //where DB values are loaded initially

2. /myaction/submit.do (name="MyForm" validate="true" input="/myaction/failed.do") //where action is submited to

3. /myaction/failed.do (name="MyForm") //temporary uri to hold form values, needs to map this to a different action class that forwards to the same jsp/tile as #1 mapping.

this is a little easier if you have all 3 inside a DispatchAction. the only thing you'll have to do is create a 'failed' method in the DispatchAction and specify the param attribute's value to 'failed' for the input (input="/myaction/submit.do?action=failed").
[ May 16, 2005: Message edited by: alan do ]

-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Redirecting to the JSP when validation error occurs