Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
208
Chapter 9 Session Tracking
Listing 9.1 ShowSession.java (continued)
(Integer)session.getValue("accessCount");
if (accessCount == null) {
accessCount = new Integer(0);
heading = "Welcome, Newcomer";
} else {
heading = "Welcome Back";
accessCount = new Integer(accessCount.intValue() + 1);
}
// Use setAttribute instead of putValue in version 2.2.
session.putValue("accessCount", accessCount);
out.println(ServletUtilities.headWithTitle(title) +
"\n" +
"" + heading + "
\n" +
"Information on Your Session:
\n" +
"\n" +
"\n" +
" Info Type | Value\n" +
"\n" +
" ID\n" +
" " + session.getId() + "\n" +
"\n" +
" Creation Time\n" +
" " +
new Date(session.getCreationTime()) + "\n" +
"\n" +
" Time of Last Access\n" +
" " +
new Date(session.getLastAccessedTime()) + "\n" +
"\n" +
" Number of Previous Accesses\n" +
" " + accessCount + "\n" +
" | | | | | | | | |
\n" +
"