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();