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

How can we refresh automatically when new data is entered into the database?

604


What are the types of Session Tracking ?

652


Why is httpservlet declared abstract?

590


Explain web container.

577


Is dispatcher servlet a singleton?

555






How is a servlet implemented in code?

572


How do you design microservices?

629


Can you send an authentication error from a servlet?

531


What is getservletcontext?

556


Once the destroy() method is called by the container, will the servlet be immediately destroyed? What happens to the tasks(threads) that the servlet might be executing at that time?

784


Explain the working of service() method of a servlet.

512


What does the term localization refer to?

591


How can we refresh automatically when new data has entered the database?

626


When Servlet is unloaded?

637


What are the life cycle methods of the servlet?

590