I'm going to try to explain it better, if my English allows me.

I have this classe:
...
public class HttpTestListener implements HttpSessionListener {

   public void sessionCreated(HttpSessionEvent e){
       e.getSession().setAttribute("test", new String("testValue");
   }
...

In my web.xml I have put the follow:
...
   <listener>
       <listener-class>com.test.HttpTestListener</listener-class>
   </listener>
...

And, finally, in a servlet I try to recover the value of "test":
...
String test = (String)request.getSession().getAttribute("test");
...

After this, the value of de variable test is null....

What have I to do if I want to recover the value of test?




2006/10/11, Martin Gainty <[EMAIL PROTECTED]>:

message was cutoff

which object are you attempting to recover?
Servlet?
SessionListener?
Session?
SessionAttribute?

also you will not set any object in Session thru getAttribute as this is
an accessor method and not a mutator

Martin --
This e-mail communication and any attachments may contain confidential and
privileged information for the use of the
designated recipients named above. If you are not the intended recipient,
you are hereby notified that you have received
this communication in error and that any review, disclosure,
dissemination, distribution or copying of it or its
contents
----- Original Message -----
From: "Juanjo Cuadrado" <[EMAIL PROTECTED]>
To: <users@tomcat.apache.org>
Sent: Wednesday, October 11, 2006 8:09 AM
Subject: Problem with HttpSessionListener


> Hi,
>
>    I'm trying to create a listener in my application. I have created a
> listener class that implements HttpSessionLister and I have put the
element
> <listener>.... in my web.xml.
>
>    My listener class only sets a object in the session
> (getSession().getAttribute("k", "kk")), but when I try to recover this
> object from a class (a servlet), not exist in session.
>
>    Any idea?
>
> P.D.
>    I'm using NetBeans 5.0 and its envebed Tomcat 5.5.9
>

Reply via email to