Page counter : Variable « JSP « Java Tutorial






<%@ page language="java" contentType="text/html" %>
<%! 
  int globalCounter = 0; 
%>
<html>
  <head>
    <title>A page with a counter</title>
  </head>
  <body bgcolor="white">
    This page has been visited: <%= ++globalCounter %> times.
    <P>
    <% 
      int localCounter = 0;
    %>
    This counter never increases its value: <%= ++localCounter %>
  </body>
</html>








23.2.Variable
23.2.1.Creating a Variable
23.2.2.Define variable and reference it later
23.2.3.Reference variable
23.2.4.Page counter