Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

close pop up window from servlet

 
Yahya Elyasse
Ranch Hand
Posts: 510
Eclipse IDE Google Web Toolkit 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.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
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
Eclipse IDE Google Web Toolkit 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
Rancher
Posts: 13061
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
Eclipse IDE Google Web Toolkit 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic