posted 22 years ago
I want to display count of page hit through session but every time its displaying s1=0,either its not setting the attribute of session or what?
The code is given below :
<%@ page import = "java.io.*,
java.util.*,
java.sql.*"
session="true"
%>
<%! int a; %>
<%
Integer s1 = (Integer)session.getAttribute("sess");
out.println("s1 before " + s1);
if (s1==null) {
s1 = new Integer(0);
}
else {
s1 = new Integer(s1.intValue()+1);
}
session.setAttribute("sess",s1);
out.println("s1 after " +s1);
%>
<html>
<body> No of times you request for the page !</body></html>