• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

this function disable close window

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
     
    Ranch Hand
    Posts: 5575
    Eclipse IDE Windows XP Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi , saravanan rajendran


    what about HttpSessionListener?
     
    saravanan rajendran
    Ranch Hand
    Posts: 75
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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 Windows XP Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
     
    Sheriff
    Posts: 67637
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
     
    Wanna see my flashlight? How about this tiny ad?
    free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
    reply
      Bookmark Topic Watch Topic
    • New Topic