Win a copy of Spark in Action this week in the Open Source Projects 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

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 ]
 
What a show! What atmosphere! What fun! What a tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic