I am currently using
FacesContext.getCurrentInstance().getExternalContext().getSessionMap()
,is there any way i can get the last accessed time a client makes request associated with the same session, just like
Session.getLastAccessedTime()
? As of now, i could find any methods. Any suggestion? Thanks!
Retrieve the current HttpSession from the external context:
HttpSession session = (HttpSession)FacesContext
.getCurrentInstance().getExternalContext.getSession(false);
Then get the last accessed time:
if (session != null)
long ms = session.getLastAccesedTime();
else
System.out.println("There's no session created for the current user");
You may convert it into a Date
later on:
Date d = new Date(ms);