public class SessionCounter implements HttpSessionListener {
private static int activeSessions = 0;
/* (non-Javadoc)
* @see javax.servlet.http.HttpSessionListener#sessionCreated(javax.servlet.http.HttpSessionEvent)
*/
public void sessionCreated(HttpSessionEvent se) {
// TODO Auto-generated method stub
activeSessions++; }
/* (non-Javadoc)
* @see javax.servlet.http.HttpSessionListener#sessionDestroyed(javax.servlet.http.HttpSessionEvent)
*/
public void sessionDestroyed(HttpSessionEvent se) {
// TODO Auto-generated method stub
if(activeSessions > 0)
activeSessions--; }
public static int getActiveSessions() {
System.out.println("SessionCounter.getActiveSessions()");
return activeSessions;
}
}得到ip
ActionContext.getRequest().getRemoteAddr();
private static int activeSessions = 0;
/* (non-Javadoc)
* @see javax.servlet.http.HttpSessionListener#sessionCreated(javax.servlet.http.HttpSessionEvent)
*/
public void sessionCreated(HttpSessionEvent se) {
// TODO Auto-generated method stub
activeSessions++; }
/* (non-Javadoc)
* @see javax.servlet.http.HttpSessionListener#sessionDestroyed(javax.servlet.http.HttpSessionEvent)
*/
public void sessionDestroyed(HttpSessionEvent se) {
// TODO Auto-generated method stub
if(activeSessions > 0)
activeSessions--; }
public static int getActiveSessions() {
System.out.println("SessionCounter.getActiveSessions()");
return activeSessions;
}
}得到ip
ActionContext.getRequest().getRemoteAddr();
能否就在SessionCounter 的某个方法里得到客户ip?
请告诉我哪里有这样的源码,谢谢