When exactly is the JSESSIONID cookie set on the browser? I access my JSP page from a browser after clearning all of the browsers cookies. The JSP page contains only a text box and a submit button. As soon as the jsp page loads, I can view the Jsessionid cookie being set on the browser. Why is this so? I thought the cookie is set only when a response is returned to the client. In this case, I've not returned any response to the client from the servlet. In fact, I have not hit the servlet at all ! Where am I going wrong? Thanks. Amit
When you access the JSP in browser, the session attribute of the page directive is true by default. so the session is created and activated by default when you access the page. If you want more testing you can set session attribute to false, so no new session is created or check if session is new in the JSP. I think the session.isNew() method will return always false for default JSP page setting as the session is always established when the page is accessed.