It isn't stored in the session. When you use the
<%! notation, the declaration is made at the top level of the JSP-generated
servlet. Therefore, your variable i becomes an instance variable of the servlet.
Since the container re-uses the servlet instance once it has been created (usually by the first hit to the JSP page), you are seeing the variable incremented every time you run the page.
The very best way to figure out why JSP pages act the way they do is to take a gander at the
Java code that is generated for the page by the container.
hth,
bear