Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts 2 + how to redirect Page after Login validation

 
Viral Patel
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hii..

I am using struts2-core-2.0.11.2
I am trying to make server side validation for login control for the application

I maked the page for login and after the correct username and password gets I want to redirect to the specific page..
as well as I want to rescrict some pages that are only accessible after valid user login. I store the login information in session
and after at the time of page loads I check that session variable for login is correct or not and after I use jsp redirect but its not working.

same way if I use redirect without having session variable then its working

here is the code of it


please help me and solve te problem as I am now mashed after searching all about this...

Thanks is advance..
 
Viral Patel
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any one please help me....
 
Tom Rispoli
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did a little research and it appears that you can't do a response.sendRedirect with in an included page. I found a discussion about it on this site

http://forums.sun.com/thread.jspa?messageID=3397035

Rather than doing this in a jsp, you might want to write an interceptor to do this. You might also want to consider doing this through redirect actions in your struts.xml file.
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,

FOR server side validation you get the value from jsp page with getter mathod and check if it is null then user AddActionError("ERROR MESSAGE ");

Like :

if(login.getUserName == null){
AddActionError("Enter userName");
}
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Same for Password field check and user ActionError.

you can also use xml for validation.

Like use your actionname-validation.xml and define validation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic