Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt regarding ServletContext

 
Shashank vanjare
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a distrubuted application, the objetcs bound to servetcontext instance of one jvm can be accessed by servlets of another jvm?
 
Ravi Singh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Reema Patel
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks you are right. I found this excellent article about it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic