• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp redirections if session is null  RSS feed

 
Rahul Dhamecha
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a file named index2.jsp given below:




The sessionManagement.jsp file is as given below:




Problem:
Prior to hitting the index2.jsp page I have created a session in a servlet and set the MaxInterval value to 15(seconds) using the inbuilt setMaxInterval... function. Thereafter I use a sendRedirect to get to index.jsp page.
The index.jsp that contains a link pointing to index2.jsp. When I click it after 15seconds my response.sendRedirect("/sessionExpired.jsp") doesn't go to sessionExpired.jsp but prints only OSR(content of index2.jsp) on the index2.jsp page.

I don't want it to go to index2.jsp page if the session becomes invalid. I want it to redirect to sessionExpired.jsp instead. How should I do this?
 
john wutka
Ranch Hand
Posts: 31
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It might be something to do with the way that <jsp:include> works, I don't know. But I would never have done it that way in the first place, so I don't really care either. You should really make the decision about whether to redirect or not before you run any JSPs at all. Especially if the question is "Is the session timed out?" -- that sort of thing should be in a servlet filter.
 
Rahul Dhamecha
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, thanks for your replies.

The problem was with the jsp:include! Instead of using that I used the include directive. Apparently the former returns the result of the resultant servlet and embeds it in the index2.jsp file. However, include directive works differently.

However, as paul pointed out I am going to keep the session Management code in a servlet which results to a better design.

Thanks again.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!