aspose file tools
The moose likes Servlets and the fly likes ServletContext doubt ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "ServletContext doubt ?" Watch "ServletContext doubt ?" New topic
Author

ServletContext doubt ?

Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2896
    
    1

Hi ranchers,,

I am new to java servlets, and i want to do this ..

I created a class which implemnts ServletContextListener interface. In this class i override 'contextInitialized(ServletContextEvent sce)' abstract method which instantiated an object Of SomeClass . Now i want this object to be accessible to only one Servlet .. Is it possible to this using ServletContext , if yes , then How ?? OR any other way ?


Thanks in advance..

Regardz,
[ April 03, 2008: Message edited by: Sagar Rohankar ]

[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35241
    
    7
You can use the ServletContext (accessible from ServletContextEvent) to store any objects using the setAttribute method. Those are accessible by all servlets, though. Generally I wouldn't consider that a problem - if other servlets are not supposed to use that object, then, well, they shouldn't use it. Or do you have reason to mistrust what other servlets are doing?


Android appsImageJ pluginsJava web charts
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2896
    
    1

Thanks, Ulf Dittmer , thats solve my problem..

Thanks again..
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: ServletContext doubt ?
 
Similar Threads
ServletContext : Please Help
Can I instantiate a interface?
Can a request be forwarded to a resource in different web application and the same web container?
Getting ServletContext
TC4-TC5.5 with context-param