Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

redirecting to a new page when session expires

 
Pavitra Acharya
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All
I am having a problem while redirecting in struts .When my session expires i redirect to the login page.i.e
if(session == null || session.getAttribute("userId") == null){
return mapping.findForward("login");}
and in my struts_config.xml,i have included
<forward name="login" path="login.jsp" redirect="true"/>
But the problem is when the session expires,the login page is being displayed within the page as a inner frame but not as a fresh new page.Can please suggest a solution to this?
Thanks
Pavitra
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately, if the page the user was trying to display when the session expired was in a frame, your login page will be also.

I think there might be a JavaScript solution to this, though. I haven't tried it, but give it a shot and see if it works:

1. add on load="init()" to the <body> tag of your login page. (on load is one word, not two, but the Java Ranch filter makes me write it this way)

2. Code the following somewhere in the <head> portion of the page:


If the parent variable is not null, that means the current page is being displayed in a frameset. This code will replace the frameset with the login page.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After trying it out, the code in my previous post does not work, but this code does:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic