• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

User log out

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am using Tomcat Form authentication to have user login. Is there anyway I can add a link or button that user can logout whenever he/she intends to?
<% HttpSession ses = request.getSession(true);
if (ses != null){
ses.invalidate();
}
%>
Sorry, I am really new to jsp/servlet... thanks
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sandra Baker:
Hi,
I am using Tomcat Form authentication to have user login. Is there anyway I can add a link or button that user can logout whenever he/she intends to?
<% HttpSession ses = request.getSession(true);
if (ses != null){
ses.invalidate();
}
%>
Sorry, I am really new to jsp/servlet... thanks


Your ses object will never be null in your code since by default the session is created and even more, you enforce it's creation by specifying 'true' as argument.
A button by itself will not help since is executed on the client side. The session invalidation should be made on the server side, in a jsp or a servlet. If your button triggers a page load i.e. logout.jsp, then you can invalidate the session in this page.
Hope this helps,
Adrian
SCJP, SCWCD
[ December 19, 2002: Message edited by: Adrian Muscalu ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic