File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Websphere and the fly likes WS4.0.1 / Servlet 2.2 / listener tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "WS4.0.1 / Servlet 2.2 / listener tags" Watch "WS4.0.1 / Servlet 2.2 / listener tags" New topic
Author

WS4.0.1 / Servlet 2.2 / listener tags

ashi mu
Greenhorn

Joined: Oct 21, 2003
Posts: 5
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 ]
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
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


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Debashish Chakrabarty
Ranch Hand

Joined: May 14, 2002
Posts: 226

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 ]

Debashish
SCJP2, SCWCD 1.4
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
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

Joined: May 14, 2002
Posts: 226

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 ]
 
wood burning stoves
 
subject: WS4.0.1 / Servlet 2.2 / listener tags
 
Similar Threads
Entries in Web.xml file
java.lang.Exception: Attempted to use a 5.0 DataSource outside of a 2.3 servlet
DTD for Web.xml
ServletContextListener
About change the servlet version from 2.2 to 2.3