import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LastAccessedSession extends HttpServlet{
	public void doGet(HttpServletRequest req, HttpServletResponse res)
		throws IOException, ServletException
		{
		res.setContentType("text/html");
		HttpSession ssn = req.getSession(true);
		PrintWriter pw = res.getWriter();
		String s = ssn.getId();
		pw.println("Your Session Id = "+ s);
		pw.println("<br>Your Session creation time = "+ new Date(ssn.getCreationTime()));
		pw.println("<br>You had accessed the session last time = "+ new Date(ssn.getLastAccessedTime()));
	}
}
