Solved

Storing a global object in servlet

Posted on 2004-03-26
3
187 Views
Last Modified: 2010-04-01
Hi all,

I am trying to have a global object that can be shared with all the servlet.

One servlet will initialize this object and then on other servlet should be able to get reference to it.

How do I do this ??

Any sample code is appreciated.

Ramesh
0
Comment
Question by:Ramesh4u
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 100 total points
ID: 10694026
Store it in the ServletContext instance.

To store:
getServletContext().setAttribute("abc", abc);

To retrieve:
MyObject abc = (MyObject) getServletContext().getAttribute("abc");
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A procedure for exporting installed hotfix details of remote computers using powershell
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now