To be sure of this behavior, I wrote a little TestingServlet - I will show you the lifecycle of a servlet and its members. Also supplied; How to work with session variables
import java.io.IOException; import java.io.PrintWriter; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Basic servlet for lifecycle testing * * @author powermicha * */ public class TestingServlet extends HttpServlet { /** * */ private static final long serialVersionUID = 4020575563844924588L; private Logger logger; private int requestCounter; @Override public void init() throws ServletException { logger = Logger.getLogger("TestingServlet_" + System.currentTimeMillis()); logger.log(Level.INFO, "TestingServlet initialized"); requestCounter = 0; } @Override public void destroy() { logger.log(Level.INFO, "TestingServlet destroyed"); } @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { int requestsPerSession = incrementRequestsPerSession(req); String logMessage = "TestingServlet was called " + (++requestCounter) + " times. " + requestsPerSession + " times from the same session (ID:" + req.getSession().getId() + ")"; logger.log(Level.INFO, logMessage); // send it to the browser PrintWriter writer = resp.getWriter(); writer.write(logMessage); writer.close(); } private int incrementRequestsPerSession(HttpServletRequest req) { Integer counter = (Integer) req.getSession().getAttribute("requestsPerSession"); if (counter == null) { counter = 1; } else { counter++; } req.getSession().setAttribute("requestsPerSession", counter); return counter; } }