• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet

 
Soman Singh
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,
I am new to Servlets. Can we declare a Sting variable in Servlet?
If no then Why?
Thanks in advance,
sos
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you referring to having member variables in your servlet? If so then yes, you may declare it. It is generally recommended that your servlet not have member variables because they are not thread safe.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to amplify what Matthew said - you should not use member variables for anything that is user specific. Remember that more than one request can be processed "at the same time" in a servlet object. Its ok to use a member variable or a static variable for something that does not relate to a specific user.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic