Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to invalidate a session

843785Aug 15 2008 — edited Aug 19 2008
Hi all,

i am creating a web application in eclipse SDK...when a user logins , he is assigned a session as

HttpSession session = req.getSession(true);
session.setAttribute("username", user);
and then user is redirected to openings.jsp page

my openings.jsp page contains.
if (session.getAttribute("username") == null){
response.sendRedirect("logout.jsp");
}

and my logout code is:

session.removeAttribute("username");
session.invalidate();
response.sendRedirect("Login.html");

my problem is this whenever i write http://localhost:8081/jobs/openings.jsp
it is redirected to that openings page with a previous username...

i want that whenever i write http://localhost:8081/jobs/openings.jsp i should be redirected to login page..
how this can be done...??

Thanks in advance..
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 16 2008
Added on Aug 15 2008
26 comments
416 views