Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

close pop up window from servlet

 
Ranch Hand
Posts: 510
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I built a jsp/servlet web application.
when user logs in to application a browser window pop up with jsp page and an embedded applet inside it.

what i want to do is when user logs out from application ,the pop up window with applet sold be closed / or maybe notify applet to destroy itself (leave its window open and ser will close it manually)
i would prefer option 1 . user logout is performed in a servlet .how can i tell the servlet to force the pop up window to close itself ? (is that possible to do at all ?)

thanks.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i would prefer option 1 . user logout is performed in a servlet .how can i tell the servlet to force the pop up window to close itself ? (is that possible to do at all ?)



short answer - NO

Longer answer - servlets can only respond to requests, actions on the client browser require code on the client browser. You might have the applet poll a servlet at reasonable intervals to see if the client is still logged in and perform some action if he/she is not. A simple GET polling approach takes surprisingly little CPU time on the server side. Depending on how your user logs out of the system, you could use code at that point to tell the applet to close down.

Bill
[ October 06, 2007: Message edited by: William Brogden ]
 
Yahya Elyasse
Ranch Hand
Posts: 510
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for helpfull answer.

Originally posted by William Brogden:


You might have the applet poll a servlet at reasonable intervals to see if the client is still logged in and perform some action if he/she is not.

[ October 06, 2007: Message edited by: William Brogden ]



you mean i could use a Timer for this task ? is Timer class the best approach to achieve this ?
a listener might be also a good solution .but which listener of applet to listen for events from servlets ?!

thanks.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

you mean i could use a Timer for this task ? is Timer class the best approach to achieve this ?
a listener might be also a good solution .but which listener of applet to listen for events from servlets ?!



Yes you could use a Timer, No you can't use a listener.

Remember - servlets can NOT initiate an event on the client, they can only respond to a HTTP request. This is the central fact of designing systems with servlets.

Bill
 
Yahya Elyasse
Ranch Hand
Posts: 510
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by William Brogden:


Yes you could use a Timer, No you can't use a listener.

Remember - servlets can NOT initiate an event on the client, they can only respond to a HTTP request. This is the central fact of designing systems with servlets.

Bill


Thanks again,
what time interval you propose me to use in Timer repeated task?
i plan to use 1 second time interval .will this hurt the performance of applet (as each second (or may be millisenconds ?) it will issue a GET request)?

thanks.
 
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic