A JSP Counter
<%! int count = 0 ; %>
<html><head></head><body>
This JSP page has been accessed <%= count++ %> times
</body></html>
As usual, this is the complete JSP page.
Note that actually it doesn’t matter where the declaration element appears in the JSP page, since it is not associated with request handling “thread of control”.