Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Error while running HttpSessionAttributeListener

 
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
 
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
 
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>
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • 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.
 
Normally trees don't drive trucks. Does this tiny ad have a license?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic