Why do you maintain sessions yourself? The servlet container should do this for you. I did not see your code, maybe you have every reason to do what you are doing, but it seems to me that you simply do not understand the servlet API and are trying to reimplement it.
In addition, you may be interested: Tomcat has a function in which it is saved, and this means that the session state is saved when the server restarts. (Disable this when updating the application, as there may be discrepancies between different versions of the classes.)
source
share