File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts Validatons are not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Validatons are not working" Watch "Struts Validatons are not working" New topic
Author

Struts Validatons are not working

Arka Mitra
Greenhorn

Joined: May 24, 2012
Posts: 16

Hi,
I am trying to develop a web application using Struts and have given validations in the user registration page using validate() method. The validations are working fine if I declare the registration page as welcome page in web.xml. But if I declare the user login page as welcome page in web.xml and later redirect to the registration page, the validations of the registration page are not working. I have mentioned each error messages properly in .properties file. Please help me...

I have mentioned necessary codes below.

web.xml ::


RegistrationForm ::


RegistrationAction ::


Registration.jsp ::


Thanks & Regards
Arka Mitra
Arka Mitra
Greenhorn

Joined: May 24, 2012
Posts: 16

Anyone please give a reply... I really need the same. Please give me any idea.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8708
    
    6

That's a heck of a lot of code to plow through. We're all volunteers here and the likelihood of someone having the free time to dig through your 500 line post is pretty unlikely. Can you pare your code down to the bare essentials?
Sometimes, Isolating The Problem gives you the insight to solving it.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Arka Mitra
Greenhorn

Joined: May 24, 2012
Posts: 16

Sorry Joe if I made a mess while posting the problem. Please let me give a few sentences to explain where my problem is. I am just putting the scenario in as brief as possible.
In my web application using Struts I used form bean which extends ValidatorForm and used validate() method for server side validation purpose in new user registration page. All kinds of validation are working fine if I declare welcome page as "Registration.jsp" in web.xml like below.

web.xml (when the validations are working):

But if I put the home page i.e. the Login.jsp page as welcome page in web.xml like below and redirect to Registration.jsp page whenever new user wants to register then the none of the validations are working. Even when I am submitting the empty form, it's redirecting to the Login page.

web.xml (when the validations are not working):

Please let me know if I have clearly pointed out this peculiar problem. Expecting a solution from you about this very eagerly.
In addition I have shown you the validate method which is used for registration form validation.

The validate() method in form bean:
Sumit Patil
Ranch Hand

Joined: May 25, 2009
Posts: 296

Please post your struts-config.xml and login page jsp.


Thanks & Regards, Sumeet
SCJP 1.4, SCWCD 5, LinkedIn Profile
Arka Mitra
Greenhorn

Joined: May 24, 2012
Posts: 16

As of now I have simply created my login page without any user ID and password field. Please find my struts-config.xml, Login.jsp and registration.jsp below.

struts-config.xml:


Login.jsp:

Registration.jsp:
Arka Mitra
Greenhorn

Joined: May 24, 2012
Posts: 16

Anyone please gve me an idea about this. I have stuck in the middle of this.
Arka Mitra
Greenhorn

Joined: May 24, 2012
Posts: 16

I solved this problem by my own. The problem was in struts-config.xml.

Previously I declared action input as "/", I think which indicates the action will start from home page.

wrong web.xml:


Later I declared input value as from the page the action starts like input = "/Login.jsp"

correct web.xml:
Sumit Patil
Ranch Hand

Joined: May 25, 2009
Posts: 296

Arkaa Mitra wrote:I solved this problem by my own.

Well done
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts Validatons are not working
 
Similar Threads
Doubt in Action Form
field validation problems in struts-need help
Doubt in Validating the values form database
How to display error message
How to Validate duplicate entries in database using struts1