PROBLEM WITH TOMCAT APPLICATION AND SESSIONS LISTENERS
HI MY PROBLEM IS THAT I'VE THIS CODE:
package listeners;
import java.io.IOException;
import java.util.Vector;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
public class objetoEscuchadoDeSesion implements
HttpSessionAttributeListener {
private String id, name, value, source, message = new String();
private HttpSession session = null;
/** Creates new SessionAttribListen */
public objetoEscuchadoDeSesion() {
System.out.println(getClass().getName());
}
public void attributeAdded(HttpSessionBindingEvent se) {
session = se.getSession();
id = session.getId();
name = se.getName();
value = (String) se.getValue();
source = se.getSource().getClass().getName();
message = new StringBuffer("Attribute bound to session in ")
.append(source).append("\nThe attribute name: ").append(name)
.append("\n").append("The attribute value:").append(value)
.append("\n").append("The session ID:
").append(id).toString();
System.out.println(message);
}
public void attributeRemoved(HttpSessionBindingEvent se) {
session = se.getSession();
id = session.getId();
name = se.getName();
if (name == null)
name = "Unknown";
value = (String) se.getValue();
source = se.getSource().getClass().getName();
message = new StringBuffer("Attribute unbound from session in ")
.append(source).append("\nThe attribute name: ").append(name)
.append("\n").append("The attribute value: ").append(value)
.append("\n").append("The session ID:
").append(id).toString();
System.out.println(message);
}
public void attributeReplaced(HttpSessionBindingEvent se) {
source = se.getSource().getClass().getName();
message = new StringBuffer("Attribute replaced in session ")
.append(source).toString();
System.out.println(message);
}
public String toString() {
return " Tiempo de Entrada: "+ new java.util.Date()+
", User: "+this.name+" = "+this.value;
}
}
HI, I'D PROBED THIS CODE AND IT WORKS, OK, BUT IF I WANT TO SHOW THE
OBJECT SESSION TO AN ADMINISTRATOR WHO HAS BEEN LOGIN TO MY
APPLICATION LIKE THIS:
HI user_name | you are [admin] IN this app | these are all THE USERS
CONECTED RIGTH NOW ->omm79/ADMIN
->jlmm /user
->bebo /user
I'M TRIYING TO DO SOMETHIG BUT ALL I GOT IS JUST WATCH THE SESSION
INFO IN THE SERVER SIDE COMMAND-WINDOW, AND IN THE APPLICATION WINDOW
SHOW THE FIELDS IN NULL LIKE THIS:
welcome omm79
Users: Fri May 11 16:35:05 CDT 2007, User: null = null
, AND I'LL APRETIATE IF THERE IS AN EXAMPLE TO CHECK, THANKS.