This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes Servlet - JSP interaction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Servlet - JSP interaction" Watch "Servlet - JSP interaction" New topic
Author

Servlet - JSP interaction

Vanchi Nathan
Ranch Hand

Joined: Feb 24, 2004
Posts: 107
Hello all,
I have a problem in Servlet-JSP interaction. Actually, i have a servlet LogoutSt and a Update jsp page. The LogoutSt invalidates the session object that is used by the Update jsp, but the page directive's session attribute is 'true'. So, i'm not able to get the following condition to be "true"...
HttpSession s = request.getSession(false);
System.out.println(s.getId());
if (s != null) {


Best regards,<br /> <br />vanchin
Vanchi Nathan
Ranch Hand

Joined: Feb 24, 2004
Posts: 107
Sorry, not yet over...
How to get this condition "false" so that when this jsp page is revisited it should redirect the user to the Login Servlet?
Thanks in advance...
brad balmer
Ranch Hand

Joined: Mar 08, 2004
Posts: 57
Not sure if you have already figured out your issue, but I believe that jsp pages automatically create a session.
So, have you tried adding:
<#@ page session="false" %>
to the top of your page? If there is NOT a session (or invalid) then this page explicitly will NOT create one. Otherwise (without the attribute) I believe that the page automatically will create a session.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
yes, JSP pages will create a session for you.
Your servlet has indeed killed the session and everything in it, but the moment the JSP executed it creates a new one.
A better test to check for session expiration is therefore to insert a known value in the session when you first start monitoring it (for example, session.setAttribute("userid", userID) in a servlet doing login, and check for the existence of that value (if (session.getAttribute("userid") != null) )when you want to know whether the session is still valid.


42
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet - JSP interaction
 
Similar Threads
Continuation of an applet session to browser
Data transfer between Servlet and JSP
how to limit servlet response
Regarding session in JSPs, a question from Enthuware Mock Exam
Session Tracking using HttpSession