wood burning stoves 2.0*
The moose likes JSP and the fly likes close pop up window from servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "close pop up window from servlet " Watch "close pop up window from servlet " New topic
Author

close pop up window from servlet

Yahya Elyasse
Ranch Hand

Joined: Jul 07, 2005
Posts: 510

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

Joined: Mar 22, 2000
Posts: 12761
    
    5
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

Joined: Jul 07, 2005
Posts: 510

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

Joined: Mar 22, 2000
Posts: 12761
    
    5
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

Joined: Jul 07, 2005
Posts: 510

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.
 
Consider Paul's rocket mass heater.
 
subject: close pop up window from servlet
 
Similar Threads
Enabling a button
Need urgent Help - Browser is hanging
Pop up window issue
How to Close the Pop-up when there is error on Java Web Start
modal pop up not closing