aspose file tools*
The moose likes Servlets and the fly likes init options 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 "init options" Watch "init options" New topic
Author

init options

Mike Phillip
Ranch Hand

Joined: Dec 05, 2007
Posts: 37
Hi,

In my app there are more then 3 servlets. And I need to call something like the init() method to config somethings.

But I think the init is only for its servlet, how can I do some init like so that all servlets can use the things I will start in it?

thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Research the concept of a context listener.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Devika Narasimhaiah
Greenhorn

Joined: Oct 24, 2008
Posts: 2
HI...

First write a Listener class which implements ServletContextListener. and
use setAttribute(var,val) and this attribute you can use in all servlets.


otherwise, use context-param tags in web.xml

That also works same.


Regards
Devika.N
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: init options
 
Similar Threads
init() and init(conf)
question on implicit objects in EL?
JSF + Hibernate - startup
How to obtain hostname during servlet init
init and constructor in servlet