File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Static data updation in Servlet as well as in Java Application at same time 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 » Java » Servlets
Bookmark "Static data updation in Servlet as well as in Java Application at same time" Watch "Static data updation in Servlet as well as in Java Application at same time" New topic
Author

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

Khurram Fakhar
Ranch Hand

Joined: May 29, 2000
Posts: 65
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

Joined: Jan 07, 1999
Posts: 6920
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.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Khurram Fakhar
Ranch Hand

Joined: May 29, 2000
Posts: 65
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

Joined: Jan 07, 1999
Posts: 6920
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Static data updation in Servlet as well as in Java Application at same time
 
Similar Threads
private and protected class?
Is static a good choice
servlet load
servlet load issue
static Hashmap variable having large data ...!!