This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Static data updation in Servlet as well as in Java Application at same time

 
Khurram Fakhar
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I m facing a problem in updating a static data member of some
class in servlet Context as well as in simple Java Application at
the same time . Problem is that Servlet is not considering the
static Context of the object and treat it as a seperate instance.
How can i update a static data member of some class in servlet
and other Application at the same time so that i can get the
changed reflection of same static data member in both context.
Kindly reply me as soon as possible ..
If you are not clear with the problem plz let me know , i'll explain it in more detailed way , but kindly reply me fast.

Khurram
Fakahr
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem may be that your Servlet Container uses a separate class loader for its servlets (most do). Classes from different classloaders can't see each other's statics. You need to put your data somewhere which can be seen by both classes: a database, JNDI etc.
 
Khurram Fakhar
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Frank for ur prompt reply ,
ya ,that can bhe the scenario . so how that thing can be tackled by JNDI , can u explain me or give me some site address or tell me alil bit about JNDI ..

best Regards
Khurram Fakhar
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have a JNDI implementation available (some servers include one, or there is one which comes with J2EE), you should look in the documentation for that for more details. Essentially, you "bind" some data to a name in the JNDI hierarchy, and it may then be retrieved by name later from any system which has a JNDI client for that repository.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic