Only one instance of the servlet is created in
the JVM. However, each time you call the doGet or
doPost method on a servlet, a new thread of that method
is created.Therefore, the class variable
inCount only is created once, but each time you call the
doGet/doPost (and any other person who calls it through a
browser) will increment the single instance of
intCount.You need to keep your doPost/doGet methods
threadsafe. Unless you want the above behavior (a counter for
people visiting the page or something like that), you
need to make all your variables method level
scope.What you want the servlet to do each time you call it,
should be contained in the doGet/doPost method anyway.
Access variables declared in those methods.