I have a static hash table that i use to store user information in. I have two servlets running in tomcat. I populate the HashTable in one Servlet and read the HashTable in another servlet. Here is my web.xml file
I have a HashTable that stores the user information that is not part of any servlet but i nead both servlets to use it. If i just use
request.getSession().setAttribute and put the HashTable in the session will that work? But since the HashTable is Static i want the very same instance of it to be used by bothe servlets. How can i do that ?
Have a look at this tutorial for how to set a servlet context listener. Using such listener, you can set your Hashmap object as an application-scoped attribute - which is commonly accessible for all of the Servlets. However, if your Hashmap is to be populated for each user on per-session basis, you should consider using a session listener.