Originally posted by Stephen Batsas:
Question: When the server is stopped - is there a garbage collection process? - and if so, should it call the finalize method on the Bean object.
At the moment the value of count is reset each time the server is restarted.
Stephen,
one of my most important rules as a
java programmer is to NEVER_TRUST_GARBAGE_COLLECTION (we learn that in scjp-exam by the way)
.
Remember that
servlets have a life-cycle. Why not put make_persistent code by simply overwriding destroy() method of the class GenericServlet?
You could try put it into a jsp - declaration (perhaps there is a better way for jsps I dont know):
<%! public void destroy() { do_serialization_here } %>
By the way: You dont need a bean. You could put the hit counter in a declaration, too.
<%! long counter = 0; %>
And then increment it through a simple scriptlet.
<% counter++; %>
As this is not thread-safe, one might think about making access to counter synchronized.
Axel
[ March 09, 2002: Message edited by: Axel Janssen ]