Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Storing a global object in servlet

Posted on 2004-03-26
3
Medium Priority
?
205 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
1 Comment
 
LVL 92

Accepted Solution

by:
objects earned 400 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 Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

772 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