This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Email validation does not work

 
Sudha Joish
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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
 
sandy gupta
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • 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
 
David Yutzy
tumbleweed and gunslinger
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the same issue and yes, that is in the rule.xml.
 
Jeremy Cavagnolo
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic