• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to sign out of my application

 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
Amod Mulay
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use session timeout programatically or in web.xml
 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 689
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 689
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 689
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi raj welcome to javaranch
i am not using struts or any other fframe work..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic