• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Email validation does not work

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use Struts 1.1 with Tomcat 5.0 as my webserver.
My JSP has 3 text boxes. All three can't be left empty and one of them is accepts an email address. I want this text box to be validated for "email" and "required".
Validation works for 'required', but doesnt work for 'email'. I am probably missing something here. Nothing happens abt the email check, it merely goes onto the next Action class - if the text box is not empty.
Please have a look at my code:
Validation.xml:


In struts_config.xml:


And in ApplicationResources.properties:

I checked validator_rules.xml. It does contain scripts to validate email.
What am I missing here? Please help.
Thanks
-- $uDhA
 
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All that you have posted up here is correct way to do it and it should be working, not sure why it is not. One thing comes to mind though. I am sure i am just being paranoid but still can you check if:
<validator name="email"
classname="org.apache.struts.validator.FieldChecks"
method="validateEmail"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.email">
is there in your validator-rules.xml
Sandy
 
tumbleweed and gunslinger
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the same issue and yes, that is in the rule.xml.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had the same problem with the email validation not working, and I found the following in tomcat's logs:

....

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.commons.validator.Validator.validateFieldForRule(Validator.java:454)
at org.apache.commons.validator.Validator.validateField(Validator.java:544)

...

at java.lang.Thread.run(Thread.java:534)
Caused by: java.lang.NoClassDefFoundError: org/apache/oro/text/perl/Perl5Util
at org.apache.commons.validator.GenericValidator.isEmail(GenericValidator.java:420)
at org.apache.struts.validator.FieldChecks.validateEmail(FieldChecks.java:779)
... 41 more


I put the oro.jar in my webapp's lib directory, restarted, and email validation worked.
 
reply
    Bookmark Topic Watch Topic
  • New Topic