Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java Servlets
Expertise: Beginner
Oct 10, 2000

Servlet Variables

Question:
If I declare one variable in a servlet class, and if I create many instances of that servlet, what will be the status of that variable?

Answer:
If the variable is not static, there will be separate instances of that variable in each servlet and the value of the variable in one instance will not be reflected in another. If the variable is static, it will be shared by all servlets running in the same servlet container that were loaded by the same class loader. In general, it is a bad idea to use static variables to share information between multiple instances of the same servlet.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap