Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

not to allow closing current window..

 
Rekha Pande
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi...
i have this jsp page in which i want to implement a javasrcipt that doesnot allow the user to close that page ..... is there such a java script..!
What i mean is that i want the user to click on the log out button then he will be redirected to another page but i want to restrict the user to close the window manually... how do i do that...??? and on clicking log out button i want the session to invalidate or expire ...how would i control that...!
FOR EG: view_calls.jsp has a log out button..... i want to restrict the user from closing the view_calls.jsp manually...... i have to just redirect this page by clicking the log out button and then expire the session....
Any Suggestions..!!pls help...!
thanxs...!!!
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can not keep the user from closing the window....
 
Yuriy Fuksenko
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically, you can either open another window or submit a request to a server, using onunload handler, but that pretty much it.
Besides, what if user turns of a computer?
You should rethink your server side.
Use session timeout setting, seeeion listeners if you need to clean up something when session invalidates and so on.
 
Rekha Pande
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i cannot close the current window .. then can u please tell me how i can re-direct to another page when the user clicks the top right button to close the window....!!!
is there a way for it ...!
 
Rekha Pande
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
re-direct to another page or open another window...!!!
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use onunload with window.open but doing this will also cause it to open when you submit the form so you need to have a flag to check whether it is submitted or closed....
the X is not the only way to close a window either....
 
Rekha Pande
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
eric..
since i'm not that familiar with java script can you please provide a code to carry out the task that you had mentioned in your previous post..!

thanxs..!
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I always say: DO NOT RELY ON JAVASCRIPT SINCE IT CAN BE TURNED OFF. USE SERVER SIDE PROGRAMMING TO FIX YOUR BUGS! You should make your server side handle cancelling sessions with timeouts or something.....
BUT since you asked...
Basic idea:

Eric
 
Rekha Pande
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you eric....
it worked....thanxs a lot..!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic