PROBLEM WITH TOMCAT APPLICATION AND SESSIONS LISTENERS

G

GRUPOS DE JAVA

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top