Please clarify a few points regarding Java Servlets
Let's say I am using Tomcat as my web container.
Is it true that after all the servlets are found in the web app / WEBAPPNAME
are init (IALIZED), then every change to the Servlet property will be displayed for every session.
So session 1 changes the userName property of servlet1 from "user1" to "user2"
session 1 is closed.
session 2 starts. Will it see "user2" as the only value for the Servlet1.userName property?
Any change to the Servlet field will show up in all subsequent sessions?
Servlets are standalone, right?
a source to share
Any change to the Servlet field will show up in all subsequent sessions?
Almost yes. Therefore, it is strongly discouraged to store data directly in servlets because servlets are not thread safe. Instead, data should be stored in the context of a servlet, session, or request context.
Servlets are standalone, right?
Sorting yes, in the sense that one servlet container has one instance of each configured servlet.
a source to share
Yes, if you are not using SingleThreadModel, there could be multiple instances of the servlet in that case. See E. g. Http://docstore.mik.ua/orelly/java-ent/servlet/ch03_04.htm
In any case, I would not rely on this. It is much better to write servlets in such a way that they do not depend on this.
a source to share