There is one context per "web application" per Java Virtual Machine. (A "web application" is a collection of servlets and content installed under a specific subset of the server's URL namespace such as /catalog and possibly installed via a .war file.)
In the case of a web application marked "distributed" in its deployment descriptor, there will be one context instance for each virtual machine. In this situation, the context cannot be used as a location to share global information (because the information won't be truly global). Use an external resource like a database instead.
The ServletContext object is contained within the ServletConfig object, which the Web server provides the servlet when the servlet is initialized.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35252
7
posted
0
Hello Rajendra-
On your way in you missed that JavaRanch has a policy on display names, and yours does not comply with it; specifically, a first name and a last name are required. Please adjust it accordingly, which you can do right here. Thanks for your prompt attention to this matter.
As to your question, what you can set per servlet is, I believe, called servlet parameter, not context parameter. So you can have different servlet parameters for the same servlet class in a web app, but there is only a single context (and its parameters are the same for all servlets).
Crosspost was made to SCWCD. I'm closing the one in SCWCD but keeping it displayable because of the good answer shared there.
A good workman is known by his tools.
geeta lalchandani
Ranch Hand
Joined: Jun 07, 2005
Posts: 118
posted
0
Geetu, he is asking just reverse, one application and two context... not two application and one context...
rathi ji, I meant the same thing. You have two applications, with two different contexts, now when you put them in a single EAR, then, it will be a single application.
Though i tried getting the context parameters, from the applications and you wouldnt get them for both, that means, i couldnt share the contexts.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.