It's not a secret anymore!*
The moose likes Servlets and the fly likes Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet" Watch "Servlet" New topic
Author

Servlet

Soman Singh
Ranch Hand

Joined: Sep 02, 2003
Posts: 37
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

Joined: Mar 09, 2001
Posts: 2676
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.


Matthew Phillips
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet
 
Similar Threads
Capturing Form Data
javascript, servlets and SVG
Export in Excel
How can I change the sdk version of Websphere 4 if I already install it
Is there any way to get Servlet Init Parameter using EL?