0

I have done session activation and deactivation using servlets using

HttpSession s = request.getSession(); 
s.setAttribute("uname", uname);

and deactivation in logout servlet using

HttpSession sess=  request.getSession();
sess.invalidate();

Now I want to check in my JSP page that is session is activate or not?
So for this I want this checking using JavaScript . I have method to check this using simple JSP code but I want this using JavaScript's function. So that if session is activate then I will reload same page and if session is expired then it will redirect to the login.jsp page. So I could not get any idea about it.

Aniket Kulkarni
  • 12,825
  • 9
  • 67
  • 90
Ronak Joshi
  • 1,553
  • 2
  • 20
  • 43

1 Answers1

0

As for tomcat webservers the session is usually mantained by a cookie with name JSESSIONID. However from that cookie being set you can not be sure that the session is still valid. The only one who can tell you, having a valid session or not is the server. So it'll be better to do the redirect on the server.

Markus
  • 1,016
  • 1
  • 8
  • 23
  • But i want check on my jsp page using javascript, so can you please elaborate answer or give me any example or link that will help me to understand this. Thanks @Markus – Ronak Joshi Apr 14 '14 at 08:07