Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

this function disable close window

 
saravanan rajendran
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
     
    Seetharaman Venkatasamy
    Ranch Hand
    Posts: 5575
    Eclipse IDE Java Windows XP
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi , saravanan rajendran


    what about HttpSessionListener?
     
    saravanan rajendran
    Ranch Hand
    Posts: 75
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    hi, thanks for yr reply HttpSessionListener this method can disable the close window please help me how to use this
     
    Seetharaman Venkatasamy
    Ranch Hand
    Posts: 5575
    Eclipse IDE Java Windows XP
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Pie
    Posts: 65227
    95
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic