Static data updation in Servlet as well as in Java Application at same time
Khurram Fakhar
Ranch Hand
Joined: May 29, 2000
Posts: 65
posted
0
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: 6913
posted
0
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.
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: 6913
posted
0
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.