• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Quick! Before anybody notices! Cover it up with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic