• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error while running HttpSessionAttributeListener

 
Senthil Kumar
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a listener class like this,

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

class SessionAttributeListener implements HttpSessionAttributeListener
{
public void attributeAdded(HttpSessionBindingEvent ev)
{
System.out.println("Inside Addition "+ev.getName()+"|"+ev.getValue());
}

public void attributeReplaced(HttpSessionBindingEvent ev)
{
System.out.println("Inside Replace "+ev.getName()+"|"+ev.getValue());
}

public void attributeRemoved(HttpSessionBindingEvent ev)
{
System.out.println("Inside Removed "+ev.getName()+"|"+ev.getValue());
}
}

when i start the server i'm getting the error
SEVERE: Error listenerStart
and
my web.xml entry goes something like this
<listener-class>SessionAttributeListener </listener-class>

what is the cause of this error.

please clarify me


with regards
 
Phil Kurian
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll get that error in Tomcat. Make your class public.

default accessibility will not work.

good luck
 
Senthil Kumar
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kurian ,
But will that work in other servers.why is that these classes(including servlet) have to public.Is this specified in sun specifications.


thanks,
Senthil.S.S
 
MInu
Ranch Hand
Posts: 517
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Senthil Kumar SS:

my web.xml entry goes something like this
<listener-class>SessionAttributeListener </listener-class>

what is the cause of this error.

please clarify me


with regards





Your <listener-class> should enclosed in <listener>

<listener>

<listener-class>exact path here</listener-class>

</listener>
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this specified in sun specifications.

SRV.10.3.1 Provision of Listener Classes
The Developer of theWeb application provides listener classes implementing one or more of the listener classes in the javax.servlet API. Each listener class must have a public constructor taking no arguments. The listener classes are packaged into the WAR, either under the WEB-INF/classes archive entry, or inside a JAR in the WEBINF/lib directory.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic