DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   JSP (http://www.daniweb.com/forums/forum24.html)
-   -   How to logout!!! (http://www.daniweb.com/forums/thread123423.html)

samlabs821 May 9th, 2008 2:24 pm
How to logout!!!
 
  1. public class logout extends HttpServlet {
  2.         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  3.             process(request,response);
  4.     }
  5.     public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  6.             process(request,response);
  7.     }
  8.     public void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  9.                 HttpSession session = request.getSession();
  10.                 session.invalidate();
  11.                 response.sendRedirect("index.jsp");
  12.         }
  13. }


session is still alive!!!

jwenting May 9th, 2008 2:45 pm
Re: How to logout!!!
 
no. But when you go to that JSP you immediately create a new session :)

samlabs821 May 11th, 2008 3:50 am
Re: How to logout!!!
 
can you give an example?

rexlee84 May 20th, 2008 12:42 pm
Re: How to logout!!!
 
well u could logout by using these methods
1) using the session.invalidate();
2) restricting the user from using the login details (when using the back button) by refreshing the page.
3) Using the sessionAccessTime.........

The first method does get you out of the session ............
provided you have used the session='true' [for jsp pages]
or HttpSession s=request.getSession(true) [in servlet this code works in the jsp in <% %>tag]
in the first page and using false in the rest of the pages as it wont create the new sessions..................

but this method is ineffective as the browser has a back button.................

if you want to know more about doing a proper logout you can write to me


All times are GMT -4. The time now is 5:37 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC