Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

validation on serverside

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your frombean, implement validate method and validate all the desired fields.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic