Hi,
I want to know the differences between Static variable and Instance variable in
servlet.
Static variable: One per class
Instance variable: One per Instance
In servlet: A servlet that does not declare SingleThreadModel usually has one and only one instance, shared among all concurrent requests hitting that servlet.
So it seems that both instance variable and static variable behaves same in the servlet.
But I got the below defn from the website, which can't understand. Could anybody expain it with one simple example:
The big difference between instance variables and static variables comes when you have configured your servlet engine to instantiate two instances of the same servlet class how?(two instances of same servlet), but with different init parameters. In this case, there will be two instances of the same servlet class, which means two sets of instance variables, but only one set of static variables.