• 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

Problem in Servlet Request Attribute Listener

 
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am trying a example on ServletRequestAttributeListener. It's giving error:





Whether for this also, we havr to register in web.xml like below

 
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing wrong with your code. It works fine.
Please check your classpath or other tomcat settings.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Micheal,

You have to register the ServletRequestAttributeListener in the web.xml. Try it and let me know.
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You definintely need to add an entry into your web.xml file. Make sure it is there. Although, I would have thought that if it wasn't there, it would just be ignored, as opposed to causing a runtime error?

I have a bunch of tutorials on my website about J2EE and web development. One deals with Listeners, although it is a session listener, as opposed to a request listener. Still, it's the same idea. Plus, the web.xml code is on the page. It might be helpful:

Tutorial on Configuring Listeners in a Servlet/JSP Based Application - With Code!

I hope that helps.

-Cameron McKenzie
 
Micheal John
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have registerd in the web.xml..

I have the following classpath:
D:\jdk1.5.0_01\lib\servlet.jar;D:\jdk1.5.0_01\lib\xerces-2.3.0;D:\jdk1.5.0_01\lib\xml-apis;.;

I have the below import statemnt:
import javax.servlet.*; //(which will cover all)
import javax.servlet.http.*;//(which will cover all)
import java.io.*;

Other servlets and JSP are compiling & running fine..even I tried the ServletContextListener example from HFSJ and it's wirks fine..

I think it shouldn't be a classpath problem..

And also,Whether for all Listener interfaces, where (in which class) the implementation is implemented does matter? What will be the pros and cons or any guidelines for it?pls explain

Any glue..?
[ December 30, 2006: Message edited by: Micheal John ]
 
Micheal John
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I couldn't figure out the problem..any help...?
 
VijayKumar Sivagnanam
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Michael,

You are having the listener in your servlet itself. Try creating the listener separately and give a try.
 
reply
    Bookmark Topic Watch Topic
  • New Topic