Saturday, August 19, 2006

When to use instance variables in servlets.

As a general rule of thumb: never create instance variables in a servlet unless you really understand how servlets work in regards to threading. Containers will create one instance of your servlet and call your servlet's service methods (doGet, doPost, etc...) from within a separate thread for each request. This means that any instance varaibles will be shared among all of your requests.

Here is a link that explains when instance variables should and shouldn't be used in servlets.

0 Comments:

Post a Comment

<< Home