• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

WS4.0.1 / Servlet 2.2 / listener tags

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried to implement HttpSessionListener and HttpSessionAttributeListener. Im having a few problems.
I'm working with IBM Websphere Application Developer 4.0.1 and want to declare a listener class in the web.xml. So I added the appropriate listener tags in web.xml.But I get
org.xml.sax.SAXParseException: Element type "listener" must be declared.
My web.xml refers to the DTD-URL http://java.sun.com/j2ee/dtds/web-app_2_2.dtd .
Im aware that Servlet 2.3 supports HttpSessionAttributeListenerand WS 5.0 supports Servlet 2.3 specification.
So Im in a fix now, What should I do? How can I make use of the listener classes in WS 4.0.1.
Please somebody explain. I really appreciate ur time and help.
Thanks
[ October 22, 2003: Message edited by: ctk ]
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't. It's that simple. Listeners are part of Servlet 2.3 and WSAD 4.0 (as you mentioned yourself) only supports Servlet 2.2. You just CANNOT use them in WSAD 4.0. There is no workaround. You must upgrade to WSAD 5.0 in order to make this work.
Kyle
 
Ranch Hand
Posts: 250
Python Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am in a great fix. I have an application that had to load the OSCache Administrator object at start of application and also invoke a thread that runs as a background scheduler and updates the cache at regular intervals. For this I defined a ContextListener class that used to do the above stuff whenever application would start and destroy cache object and stop scheduler when app stops.
I tested the code in Tomcat and it works well, when I went for a deployment with WAS4 it was a bolt from blue when I was unable to add the listener to web.xml and saw this thread.
While I am in great shock, I can't go for WAS5, what are the work around to simulate the above work which my Listener class was performing.
[ January 11, 2004: Message edited by: Debashish Chakrabarty ]
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's what you get for not checking out that the application server you develop on and the one you plan on deploying on implement the same level of the Servlet spec!
Anyway, there is a way out. SeeThe WAS 4.0 Javadoc. Look for the class ApplicationListener. The Javadoc for the class ServletContextEventSource shows how you can (in the init() method of one of your servlets) set up a WAS 4.0 ApplicationListener that is similar (not THE SAME, mind you, but similar) to one of the new Servlet 2.3 listeners.
Kyle
 
Debashish Chakrabarty
Ranch Hand
Posts: 250
Python Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Kyle! Guess, it's too late for me now to change the implementation again because I changed the code to add a Servlet that loads on start-up and does all the stuff (in init) and cleanups (in destroy) I planned to do with the listener class. I have been warned in the past not to perform such things with Servlets.
How predictable is the behavior of WAS in such a case? Or am I committing a big mistake in not implementing the ApplicationListener interface as u had suggested? (The servlet code is following.)

[ January 11, 2004: Message edited by: Debashish Chakrabarty ]
reply
    Bookmark Topic Watch Topic
  • New Topic