Solved

Storing a global object in servlet

Posted on 2004-03-26
3
193 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
java cyclic graphs 15 201
parse example 13 92
javax.naming.NameNotFoundException: Name ... is not bound in this Context. 6 196
instanceof  operator in java 26 85
Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Scenario: Your operations manager has discovered an anomaly in your security system. The business will start to suffer within 15 minutes if it is a major IT incident. What should she do? We have 6 recommendations for managing major incidents (https:…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

932 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

7 Experts available now in Live!

Get 1:1 Help Now