can servlet have instance variables?
Answers were Sorted based on User's Feedback
Answer / rajashree
The servlet you write can be used simulataneously by many
users at the same time and each user of the servlet has a
thread. Consider the user and the session one and the same.
Avoid instance variables. An instance variable is any
object owned by a a class. There will be only one of these
per class - not one per user. In general, you can not have
a user modify an instance variable because other users are
also using the same variable.
| Is This Answer Correct ? | 35 Yes | 5 No |
Answer / unknown
Dear Soori and Shekhar ot post ur name here u answer YES if
u not know the right logic then why u post ur answers nways
thanks to Rajashree for the right answer
| Is This Answer Correct ? | 11 Yes | 4 No |
Answer / neeraj
Ravikiran.chd
If we implement single thread model then how servlet will
handle multiple request at a time??
So its better to avoid the use of instance variable.
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / debapriya maity
Yeah we surely can provide instance variable,but ur servlet
implements MultithreadModel,its is not the right
approach,better use local varibles ,using SingleThreadModel
approach cause perfomance degradation
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / ramana
it is not recomended to use instance variables in servlet...if necessary use static variables..
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / ravikiran.chd
yes and we can make them thread safe by implementing
SingleThreadModel
| Is This Answer Correct ? | 2 Yes | 2 No |
Which method of the httpservletrequest object is used?
What is use of parseQueryString ?
Define the lifecycle for executing a jsp page.
What is java servlet?
What is httpservlet and how it is different from genericservlet?
What is called a session?
What are the advantages of Servlet over CGI?
How do we share data using 'getservletcontext ()?
what is the difference between Servlet and JSP?Advantage of JSP over Servelt?Any concept present in JSP which we cant implement in Servlet?
31 Answers ABC, Apere, AZTEC, CTS, CybAge, iFlex, Impact Systems, Sara, TCS,
How can we refresh automatically when new data is entered into the database?
Explain the differences between jsp and servlet.
Which httpsession object is used to view and manipulate information about a session?