File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validation on serverside

 
Saptarshi Chakraborty
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends'

I want to implement validation routine in serverside.I have already implemented it as a client side validation.I have
1>validation.xml
2>validator-rules.xml
3>and a jsp page in which
In the form tag I have written onsubmit="return validateAddressForm(this);
and
<html:javascript formName="AddressForm"/>
This generates the client side javascript for client side validations in the fields like name,password etc.
How could I implement the same validation routine in the server side. Is there any change that I have to make in the form bean. and what I have to do in my jsp page.
 
Kishore Kumar
Ranch Hand
Posts: 71
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your frombean, implement validate method and validate all the desired fields.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All the validation rules you defined in a validation.xml file will apply to both client-side and server-side validation. Even when client-side validation is turned on, Struts Still does Server-side validation. There's nothing you have to do to turn that on. It's done automatically. All you have to do is make sure your ActionForm extends ValidatorForm and add an <html:errors /> tag to your JSP so that there is a place for server-side errors to be displayed.

Note that when client-side validation is enabled, server-side validation is really just a backup plan, as the client-side validation should pick up any errors before the request is even submitted to the server. However, because a user can disable JavaScript on the browser, it's always safer to do server-side validation also just in case.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic