I'm using JavaEE and have an HttpSessionListener
implementation that I am trying to use to get an IP address when a client creates a session. How do I do this?
My webapp is 2.4 (cannot change this, I'm afraid):
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
Here is my session created method:
public void sessionCreated(HttpSessionEvent se) {
System.err.println("Session source: " + se.getSource());
System.err.println("SessionLifecycleListener:sessionCreated() not implemented yet");
HttpSession s = se.getSession();
printAll(s.getAttributeNames(), "HttpSession attribute names");
ServletContext sc = s.getServletContext();
printAll(sc.getAttributeNames(), "ServletContext attribute names");
}
How do I get the IP address given the HttpSessionEvent
?