Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts Validatons are not working

 
Arka Mitra
Greenhorn
Posts: 16
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ::
 
Arka Mitra
Greenhorn
Posts: 16
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone please give a reply... I really need the same. Please give me any idea.
 
Joe Ess
Bartender
Posts: 9280
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Arka Mitra
Greenhorn
Posts: 16
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post your struts-config.xml and login page jsp.
 
Arka Mitra
Greenhorn
Posts: 16
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone please gve me an idea about this. I have stuck in the middle of this.
 
Arka Mitra
Greenhorn
Posts: 16
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arkaa Mitra wrote:I solved this problem by my own.

Well done
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic