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 this function disable close window 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 "this function disable close window" Watch "this function disable close window" New topic
Author

this function disable close window

saravanan rajendran
Ranch Hand

Joined: Jun 13, 2008
Posts: 75
hi, I very hardly trying to disable the close window using servlet code

problem:
My servlet code contain logout button if they pressed that button that flag value will change but without pressing logout button directly closing the window i getting problem in that please help me
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You can't disable the ability to close a browser window from servlet code. You would need to do this via client-side JavaScript.

A couple of reasons why this is not a good thing to try to do:
  • it annoys users if you stop the normal operation of their browser
  • there is no 100% full proof way of doing it anyway


  • Why are you trying to prevent the browser window being closed? There may be another way to achieve what you want your application to do without having to mess with the browser behaviour.
    [ August 05, 2008: Message edited by: Paul Sturrock ]

    JavaRanch FAQ HowToAskQuestionsOnJavaRanch
    Seetharaman Venkatasamy
    Ranch Hand

    Joined: Jan 28, 2008
    Posts: 5575

    Hi , saravanan rajendran


    what about HttpSessionListener?
    saravanan rajendran
    Ranch Hand

    Joined: Jun 13, 2008
    Posts: 75
    hi, thanks for yr reply HttpSessionListener this method can disable the close window please help me how to use this
    Seetharaman Venkatasamy
    Ranch Hand

    Joined: Jan 28, 2008
    Posts: 5575

    Originally posted by saravanan rajendran:
    hi, thanks for yr reply HttpSessionListener this method can disable the close window please help me how to use this


    it can not disable the close window of browser. but while the session invalidate ,this Listener(one of the method sessionDestroyed() of HttpSessionListener) gets call...there you can do your business logic.

    if user directly close your window... assign default <session-invalidate>..so when session get invalidate...the HttpSessionListener gets call .

    Hope This Helps
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 60810
        
      65

    Originally posted by saravanan rajendran:
    hi, thanks for yr reply

    Please use real words when posting to the forums. Abbreviations such as "yr" in place of "your" only serve to make your posts more difficult to read and less likely to generate useful responses.

    Please read this for more information.

    thanks,
    bear
    JavaRanch sheriff


    [Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
     
    jQuery in Action, 2nd edition
     
    subject: this function disable close window
     
    Similar Threads
    how to disable close window
    Login Problem
    disable close button
    Logout when exit
    disable CLOSE (X) button on a popup window