
Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
On Sep 11, 3:31 am, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
> On Mon, 10 Sep 2007 12:56:31 -0700, jiep...@gmail.com wrote, quoted or
> indirectly quoted someone who said :
[quoted text clipped - 11 lines]
> Roedy Green Canadian Mind Products
> The Java Glossaryhttp://mindprod.com
hi thanks for replying.
however, i need to the append function, because i want to add more
text the existing file. so therefore i need to do this:
BufferedWriter log = new BufferedWriter (new>
FileWriter("log.txt",true));
one weird thing i found is, my program works in Firefox, but not in IE
7. IE7 simply invoke the servlet twice. do you have solution to this
problem?
Roedy Green - 13 Sep 2007 01:52 GMT
>however, i need to the append function, because i want to add more
>text the existing file. so therefore i need to do this:
>BufferedWriter log = new BufferedWriter (new>
>FileWriter("log.txt",true));
Your problem is the browser is free to invoke and shutdown your applet
as many times as it wants. Your code does an append every time it
starts up., so you get "duplicates".
To understand what is going on add some debug code to dump out the
contents of the log.txt just before you open it, or perhaps just the
last few lines if it is voluminous.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
kcwong - 13 Sep 2007 08:55 GMT
On Sep 13, 8:52 am, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
> Your problem is the browser is free to invoke and shutdown your applet
> as many times as it wants. Your code does an append every time it
> starts up., so you get "duplicates".
Er... I went through the OP's first post several times, but I didn't
see anything about an applet... it's a servlet...
Roedy Green - 25 Sep 2007 08:48 GMT
>Er... I went through the OP's first post several times, but I didn't
>see anything about an applet... it's a servlet...
You have the same problem with Servlets. The Servlet womb is free to
shut down and restart the Servlet any time it wants to conserve RAM.
You can track this by putting in some static init code to print out a
message every time the class is loaded, and in the constructor to
monitor every time the Servlet is instantiated.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Lew - 25 Sep 2007 15:22 GMT
>> Er... I went through the OP's first post several times, but I didn't
>> see anything about an applet... it's a servlet...
[quoted text clipped - 5 lines]
> message every time the class is loaded, and in the constructor to
> monitor every time the Servlet is instantiated.
You can also make use of the servlet's lifecycle methods, like init().

Signature
Lew