wood burning stoves
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "init options" Watch "init options" New topic

init options

Mike Phillip
Ranch Hand

Joined: Dec 05, 2007
Posts: 37

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?

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63837

Research the concept of a context listener.

[Asking smart questions] [About Bear] [Books by Bear]
Devika Narasimhaiah

Joined: Oct 24, 2008
Posts: 2

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.

I agree. Here's the link: http://aspose.com/file-tools
subject: init options
jQuery in Action, 3rd edition