This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes how to sign out of my application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to sign out of my application" Watch "how to sign out of my application" New topic
Author

how to sign out of my application

saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
ia m developing an application for admin ...so admin must enter userid and password then login.if the admin log out of the application. then he must need to perfectly do tht.. even if the admin press back button in the browser he must not abe to login.
iam using session.invalidate () for log out..


A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
Amod Mulay
Ranch Hand

Joined: Apr 06, 2006
Posts: 33
hi
if you are using session.invalidate() it should work unless you are not checking the session on each jsp.
by hitting the back button only the the history of previous screen is displayed, if any operation is tried on the page then the page will return a invalid session and redirect you to a longin page if any.

See if you can delet the history when logging out..then there is no question of going to the previous page
Shrinivas Mujumdar
Ranch Hand

Joined: Aug 27, 2004
Posts: 328
you can use session timeout programatically or in web.xml
saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
Originally posted by Amod Mulay:
hi
if you are using session.invalidate() it should work unless you are not checking the session on each jsp.
by hitting the back button only the the history of previous screen is displayed, if any operation is tried on the page then the page will return a invalid session and redirect you to a longin page if any.

See if you can delet the history when logging out..then there is no question of going to the previous page

yes i am using session.ivalidate() it is working but when i press back button on the browser button it shows the previous screen

instead of showing the last accessed page i want to display session expired messgae to the user
can u please can u suggest me how to delete the history?

thanx in advance
Alix Sye
Greenhorn

Joined: Jun 07, 2006
Posts: 17
Put the following code between the <head> </head> in the page . it will not let you go back ever to the previous page. I put this code in my main_frame page where i display all my application pages.


<HEAD>

<script>
history.forward();
</script>

</Head>
saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
Originally posted by Alix Sye:
Put the following code between the <head> </head> in the page . it will not let you go back ever to the previous page. I put this code in my main_frame page where i display all my application pages.


<HEAD>

<script>
history.forward();
</script>

</Head>



ok thanx very very much for ur code..
but in my application some of my links are directly pointing to servlet and the servlet then forwards to jsp file..
so how can i restict here.. what should i write in the servlet .. can any one hlep me by providing some piece of code

saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
please sombody tell me how to develop the code for login and logout
and how can i know the currently logged in users?
Amod Mulay
Ranch Hand

Joined: Apr 06, 2006
Posts: 33
Originally posted by saikrishna cinux:



ok thanx very very much for ur code..
but in my application some of my links are directly pointing to servlet and the servlet then forwards to jsp file..
so how can i restict here.. what should i write in the servlet .. can any one hlep me by providing some piece of code



dude i think you are confusing yourself here .... there is no need to write such code in a servlet by hitting back button you are not doing to the servlet unless your form is automatically submitting it self on load
Amod Mulay
Ranch Hand

Joined: Apr 06, 2006
Posts: 33
Originally posted by saikrishna cinux:
please sombody tell me how to develop the code for login and logout
and how can i know the currently logged in users?
Amod Mulay
Ranch Hand

Joined: Apr 06, 2006
Posts: 33
Originally posted by saikrishna cinux:
please sombody tell me how to develop the code for login and logout
and how can i know the currently logged in users?


for your currently logged in users declare a static variable in your login servlet ....and increment it evertime anyone accesses it....and in logout decrement it..
Raj Kapoor
Greenhorn

Joined: Jun 17, 2006
Posts: 2
Hi, to prevent showing the previous page when "back" button is pressed after log out, you can do it in many ways, But one technique which I used is write a JSP which checks if a user is logged in or not..this you can check by looking for some session object , if its not null user is logged in else user is logged out, now you may include this at the begining of every other JSP page, this ensures that everytime, a check is performed to see if the user is logged in..

A more polished way of doing the same thing is if you are using Struts then in the Action servlet you can do this check if a session object is null or not, so you dont have to include anytihng in your JSPs, since all the requests go through this servlet

If anyone knows better approaches please let us know, since this is soething every web developer comes across
saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
hi raj welcome to javaranch
i am not using struts or any other fframe work..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to sign out of my application
 
Similar Threads
How to impletmet the Single Sing on
how to make logout page?
Session Management
how to find logout time in jsp if new user registers and logs out
Portlet getting log off