I have the following code.

package org.example;

import java.io.IOException;
import javax.servlet.http.*;

public class HelloAppEngineServlet extends HttpServlet {
        public void doGet(HttpServletRequest req, HttpServletResponse resp)
                        throws IOException {
                resp.setContentType("text/plain");
        static_counter++; member_counter++;
                resp.getWriter().println("static_counter = " + static_counter + 
"
member_counter = " + member_counter);
        }
    private static int static_counter = 0;
    private static int member_counter = 0;
}

I am expecting static_counter will always live, and never reset back
to 0 once it start to increment, as long as I do not perform any new
upload (Hence, the JVM of the server will not be restarted, I guess)

For member_counter, I expect it can be reset to 0 sometimes, as
servlet container may choose to create another new instance due to
certain situation.

However, my observation is that, after I am getting

static_counter = 3 member_counter = 3

If I let my web browser idle for says an hour, I will get

static_counter = 1 member_counter = 1

Seems the JVM had been restarted?

Can anyone explain why this happen?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to