Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

What happen when applet browser is closed?

 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing an applet that do nothing but will keep track total time the window is opened. I do a http get request in applet's destroy()/stop() method to check in with a servlet about its closing time. When applet is reload(), this process is completed and servlet can get the reload time. However, when the browser is closed, the get request is not transmitted because the URL.openStream() cannot succeed. Thus, i cannot open a BufferedStreamReader to read the reponse from the server (this step is needed to complete a TCP/IP cycle). How can i make the last request successful by modifying my applet?
Here is my code snippet.
<code>
/********************************/
try{
URL url = new URL(url_to_servlet);
BufferedReader bf = new BufferedReader(
new InputStreamReader(
url.openStream()));
//This readLine() is needed to complete a request.
String temp = bf.readLine();
bf.close();
}catch(Exception e){}
/**************************************/
<code>
Can anyone help?
Regards,
[ June 27, 2002: Message edited by: SoonAnn Lim ]
 
My, my, aren't you a big fella. Here, have a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic