Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@page import="java.sql.Date"%>
- <%@page import="database.Database"%>
- <%
- // Get session creation time.
- System.out.print("oi");
- Date createTime = new Date(session.getCreationTime());
- // Get last access time of this Webpage.
- Date lastAccessTime = new Date(session.getLastAccessedTime());
- String title = "Welcome Back to my website";
- Integer visitCount = new Integer(0);
- String visitCountKey = new String("visitCount");
- String userIDKey = new String("userID");
- String userID = new String("ABCD");
- // Check if this is new comer on your Webpage.
- if (session.isNew() ){
- title = "Welcome to my website";
- session.setAttribute(userIDKey, userID);
- session.setAttribute(visitCountKey, visitCount);
- }
- visitCount = (Integer)session.getAttribute(visitCountKey);
- visitCount = visitCount + 1;
- userID = (String)session.getAttribute(userIDKey);
- session.setAttribute(visitCountKey, visitCount);
- %>
- <html>
- <head>
- <title>Session Tracking</title>
- </head>
- <body>
- <center>
- <h1>Session Tracking</h1>
- </center>
- <%
- database.Database db = new database.Database();
- db.testDB();
- %>
- <table border = "1" align = "center">
- <tr bgcolor = "#949494">
- <th>Session info</th>
- <th>Value</th>
- </tr>
- <tr>
- <td>id</td>
- <td><% out.print( session.getId()); %></td>
- </tr>
- <tr>
- <td>Creation Time</td>
- <td><% out.print(createTime); %></td>
- </tr>
- <tr>
- <td>Time of Last Access</td>
- <td><% out.print(lastAccessTime); %></td>
- </tr>
- <tr>
- <td>User ID</td>
- <td><% out.print(userID); %></td>
- </tr>
- <tr>
- <td>Number of visits</td>
- <td><% out.print(visitCount); %></td>
- </tr>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement