Solved

Storing a global object in servlet

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
trouble with PDF encryption using itext-1.3.1 17 84
caughtSpeeding java challenge 16 136
lessBy10  challenge 15 95
designing in object programming 12 78
If you thought ransomware was bad, think again! Doxware has the potential to be even more damaging.
This problem is more common than not and I will show you some things to check to solve this problem.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

777 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