Im trying to write a listener that gets the current URL from the user before the session timeout. I need to store this url in the database.
public class SessionTimeoutListener implements HttpSessionListener,SessionAware {
HttpServletRequest request;
@Override
public void sessionDestroyed(HttpSessionEvent event) {
String url = request.getRequestURL().toString();
// url is empty here!!
}
@Override
public void sessionCreated(HttpSessionEvent arg0) {
}
@Override
public void setSession(Map<String, Object> arg0) {
session=arg0;
}
}
Im new to struts2 and java programming.... i cant understand why i get a null value in that line. Do i have to set the url some where for me to get it as shown? or is the listener itself not correct??