943,677 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Unsolved
  • Views: 20436
  • JSP RSS
You are currently viewing page 1 of this multi-page discussion thread
May 9th, 2008
0

How to logout!!!

Expand Post »
Java Syntax (Toggle Plain Text)
  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!!!
Last edited by peter_budo; May 9th, 2008 at 7:04 pm. Reason: Keep It Organized - please use [code] tags
Similar Threads
Reputation Points: 29
Solved Threads: 0
Newbie Poster
samlabs821 is offline Offline
17 posts
since May 2008
May 9th, 2008
0

Re: How to logout!!!

no. But when you go to that JSP you immediately create a new session
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
May 11th, 2008
0

Re: How to logout!!!

can you give an example?
Reputation Points: 29
Solved Threads: 0
Newbie Poster
samlabs821 is offline Offline
17 posts
since May 2008
May 20th, 2008
0

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rexlee84 is offline Offline
1 posts
since May 2008
Jun 29th, 2009
0

Re: How to logout!!!

Click to Expand / Collapse  Quote originally posted by rexlee84 ...
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

I had read what you have discussed here. I am facing same problem what you had. If any suggestion or help that will be appreciated.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
shardaprasad001 is offline Offline
1 posts
since Apr 2009
Jun 30th, 2009
1

Re: How to logout!!!

I had read what you have discussed here. I am facing same problem what you had. If any suggestion or help that will be appreciated.
JSP Syntax (Toggle Plain Text)
  1. is to session.setAttribute(null,"sessionname");
Reputation Points: 29
Solved Threads: 0
Newbie Poster
samlabs821 is offline Offline
17 posts
since May 2008
Oct 26th, 2009
0
Re: How to logout!!!
session.invalidate(); will do the job.....we should have conditions to check if the session-attributes are present in every page except the login page....


or session.removeAttribute(); will also do the job...if you remove all the attributes...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
itian_naeem is offline Offline
1 posts
since Oct 2009
Feb 18th, 2010
-2

those who dont know the coding

you dont know anything where is the code?
next be more clear.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
puar143 is offline Offline
1 posts
since Feb 2010
Feb 18th, 2010
0
Re: How to logout!!!
it was posted i think in May 2008.
Reputation Points: 29
Solved Threads: 0
Newbie Poster
samlabs821 is offline Offline
17 posts
since May 2008
Feb 18th, 2010
0
Re: How to logout!!!
Click to Expand / Collapse  Quote originally posted by puar143 ...
you dont know anything where is the code?
next be more clear.
Next time please make sure that you do not reopen old thread when you do not have anything valid to say.
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 871
Code tags enforcer
peter_budo is offline Offline
6,654 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in JSP Forum Timeline: for loop issues in .jsp
Next Thread in JSP Forum Timeline: help with "select" and jsp





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC