aspose file tools*
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
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: 12681
    
    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


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet
 
Similar Threads
javascript, servlets and SVG
Export in Excel
Capturing Form Data
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?