-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathSessionLastAccessTime.java
More file actions
32 lines (28 loc) · 1.16 KB
/
SessionLastAccessTime.java
File metadata and controls
32 lines (28 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import javax.servlet.ServletConfig;
import java.text.DateFormat;
public class SessionLastAccessTime extends HttpServlet
{
protected void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
HttpSession session = req.getSession();
Date CreationTime = new Date(session.getCreationTime());
Date LastAccess = new Date(session.getLastAccessedTime());
Date now = new Date();
DateFormat foreatter = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM);
out.println("<html><head><title>Displaying Session Last aceess time</title></head>");
out.println("<body>");
out.println("<h2><b>130050131044</b></h2>");
out.println("<h2>Session Creation and Last aceess time:</h2>");
out.println("the time and date now is:"+foreatter.format(now)+"<br><br>");
out.println("The session creation time is: "+foreatter.format(CreationTime)+"");
out.println("The session Last Access time is: "+foreatter.format(LastAccess)+"");
out.println("</body></html>");
}
}