File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes using Global ServletContextListener in several modules in the webapp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "using Global ServletContextListener in several modules in the webapp" Watch "using Global ServletContextListener in several modules in the webapp" New topic
Author

using Global ServletContextListener in several modules in the webapp

Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
Hello all
i have Global class named WebServerContextListener that implements the ServletContextListener
this class load every time the webapp load via the web.xml. now this has some Global settings that needs to be set for the overall webapp
but there is several modules in my web app that needs to do stuff when the application loads. but i dont want to write more classes in the web.xml
i like to use somehow this Global WebServerContextListener for setting stuff from modules . if i just extend this class it will not work .
is there some pattern or way to do that ?
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Why not use WebServerContextListener for configuring all your modules ?


Rahul Bhattacharjee
LinkedIn - Blog
Amol Nayak
Ranch Hand

Joined: Oct 26, 2006
Posts: 218
Why not use WebServerContextListener for configuring all your modules ?


Never heard of this listener, Rahul can you throw more light on this one.
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
WebServerContextListener is what original poster Meir Yan is talking about.

Amol Nayak
Ranch Hand

Joined: Oct 26, 2006
Posts: 218
ohh ok..

I thought it is some listener you are talking about..
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

There is nothing keeping you from instanciating all of your configuration objects from a single context listener.

Having separate listeners is nice if you want the ability to add,remvoe, and reorder all of these actions without having to re-compile anything by simply editing your deployment descriptor. If you don't need this ability, by all means do everything from one listener.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
i dont want edit the web.xml
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using Global ServletContextListener in several modules in the webapp
 
Similar Threads
Programmaticaly undeploy webapp
Abort startup duing Loading Errors
Places where Singleton is used??(in J2EE)
Hibernate configuration class
"porting" a PHP application to Java...