can servlet have instance variables?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we fetch the attributes related to a servlet on a different servlet?

626


Is servlet a controller?

567


What is meant by cookies?

605


How the typical servlet code look like ?

631


What do you mean by singlethreadmodel interface?

576






What are some advantages of storing session state in cookies?

589


Why do we have servlet listeners?

597


When a servlet accepts a call from a client, it receives two objects. What are they?

754


Explain the features are in servlet 3?

597


What is the need of servlet filters?

536


What do you mean by httpservlet and how it is different from the genericservlet?

534


What are different ways for servlet authentication?

559


What do you mean by mime type?

548


Define the life cycle of a servlets.

567


Can filter be used as request or response?

540