aspose file tools*
The moose likes Struts and the fly likes struts 2 + how to redirect Page after Login validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 2 + how to redirect Page after Login validation" Watch "struts 2 + how to redirect Page after Login validation" New topic
Author

struts 2 + how to redirect Page after Login validation

Viral Patel
Greenhorn

Joined: Aug 12, 2008
Posts: 8
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

Joined: Aug 12, 2008
Posts: 8
any one please help me....
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
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

Joined: Sep 07, 2008
Posts: 686

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");
}


Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 686

Same for Password field check and user ActionError.

you can also use xml for validation.

Like use your actionname-validation.xml and define validation.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts 2 + how to redirect Page after Login validation