• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How to deploy a ServletRequestListener to work only for specified Servlets?

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems that DD only provides mechanism for Listeners to work for the whole application, instead of some specified Servlet. Am I right?
If it is true. I feel it is a flaw, since sometimes you may want you ServletRequestListener to work not on every request to all the Servlets in the application. It is inefficient.
 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I feel it is a flaw, since sometimes you may want you ServletRequestListener to work not on every request to all the Servlets in the application.


What about:

[ October 15, 2006: Message edited by: sven studde ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are you trying to do with the listener?
Is is something that could be done with a filter?
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The ServletRequestListener is used to listen events on the request. There is no meaning in making it servlet specific. A request can be to any resource, need not be to a servlet.
 
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
People are always curious as to how to get the various listeners working in a web application. I hear that complaint so often, that I put together a flash, multimedia tutorial to demonstrate just that:

http://www.technicalfacilitation.com/examscam/tf/get.php?link=web

This deals with HttpSessionListeners an WebContextListeners, but coding and configuring all of the various Servlet and JSP API listeners is pretty much the same.

Do make sure there is an entry in your web.xml file:



As far as the class goes, it just has to implement the appropriate listener interfaces:



Here's the ear, which contains a functional war file. It was put together using IBM's Rational Application Developer (IRAD), but the war has been tested and runs fine on tomcat.

http://www.technicalfacilitation.com/examscam/tf/vangogh/09lifecyclelisteners.ear

Cheers!

-Cameron McKenzie
 
Whoever got anywhere by being normal? Just ask this exceptional tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic