my dog learned polymorphism
The moose likes Servlets and the fly likes creatin  plugin Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "creatin  plugin" Watch "creatin  plugin" New topic

creatin plugin

arun krishnamurthy

Joined: Aug 30, 2006
Posts: 6
How to create plugin.
For example if i want to store some data into Context Opject before any request comes,ie during servlet instantiataion, how can we do that?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63873

That's not what I would term a "plugin".

But the answer to your question is to use a context listener that will execute when the web app starts prior to any requests being serviced.

[Asking smart questions] [About Bear] [Books by Bear]
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

The question always arises: how can I make sure something happens as soon as I load a web module; or how can I initialize something as soon as an HttpSession is created. The solution is to use a lifcyle listner, such as an HttpSessionListener or a WebContextListener.

Here's a tutorial on how to create a web context listener, and an HttpSesionListener:

The code for one of these things looks something like this:

Of course, you have to edit the old web.xml file too, don't forget!


-Cameron McKenzie
arun krishnamurthy

Joined: Aug 30, 2006
Posts: 6
Thanks Cameron
I agree. Here's the link:
subject: creatin plugin
It's not a secret anymore!