wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt regarding ServletContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt regarding ServletContext" Watch "Doubt regarding ServletContext" New topic
Author

Doubt regarding ServletContext

Shashank vanjare
Greenhorn

Joined: Apr 10, 2008
Posts: 9
In a distrubuted application, the objetcs bound to servetcontext instance of one jvm can be accessed by servlets of another jvm?
Ravi Singh
Greenhorn

Joined: Jun 02, 2008
Posts: 26
In distributed application one servletContext object will be available with per app per JVM.

So the attributes set to one servletContext can't be accessed by another servletContext set in other jvm. It will return null in this case.
Reema Patel
Ranch Hand

Joined: Jan 26, 2006
Posts: 169
Nope. ServletContext are one per web app, per JVM. In case the web app is distributed, there'll be two separate ServletContext objects.
Jan Sterk
Ranch Hand

Joined: Jun 06, 2008
Posts: 139
Ravi and Reema, could you please tell us where you got this knowledge from (experience, book)?

I've seen this statement before, in another thread. But I find it hard to believe.

First of all, the context scope is meant as an application scope. That means that the attributes in it, can be accessed by every component in the application.

Secondly, if there would be one (seperate) context per JVM, and the attributes in it cannot be communicated to each other, then one multiple-JVM application functions the same as multiple, isolated instances of the application with one JVM each.

Head First is not clear about this. It says (p.255) that there is one Context per JVM, but also that it is duplicated to the other JVM's. 'Duplicated' could be meant as in 'synchronized', that is, they are the same all the time. That would make sense, since it increases performance - only when attributes are changed, the contexts are updated through the network. When they are read, there would be no need for network traffic.

Charles Lyons' Study Companion states on p.65 clearly: one context per application.

It is hard to check this matter in practise, since it requires to have a multi JVM setup.


SCJP 1.4 (81%)<br />SCWCD 5 (95%)
Reema Patel
Ranch Hand

Joined: Jan 26, 2006
Posts: 169
Ravi and Reema, could you please tell us where you got this knowledge from (experience, book)?

I'm using two books:
(1) "SCWCD Exam Guide". URL- http://javaevangelist.com/images/SCWCD.gif, and
(2) HFSJSP. URL - http://oreilly.com/catalog/9780596516680/index.html

Both titles are good.

Best,
Reema
Jan Sterk
Ranch Hand

Joined: Jun 06, 2008
Posts: 139
Looks you are right. I found this excellent article about it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt regarding ServletContext
 
Similar Threads
Regarding Exception handling
Query on JVM
size for data type boolean
main() doubts
WA #2 ..... word association