can servlet have instance variables?

Answers were Sorted based on User's Feedback



can servlet have instance variables?..

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

can servlet have instance variables?..

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

can servlet have instance variables?..

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

can servlet have instance variables?..

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

can servlet have instance variables?..

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

can servlet have instance variables?..

Answer / ravikiran.chd

yes and we can make them thread safe by implementing
SingleThreadModel

Is This Answer Correct ?    2 Yes 2 No

can servlet have instance variables?..

Answer / shekhar

yes

Is This Answer Correct ?    3 Yes 8 No

can servlet have instance variables?..

Answer / soori

yes

Is This Answer Correct ?    5 Yes 12 No

Post New Answer

More Servlets Interview Questions

Which method the Servlet container call to create the instance of the servlet?

16 Answers   emc2, JK Technosoft,


Explain the lifecycle of a servlet?

0 Answers  


Does servlet have main method?

0 Answers  


What are the key methods that are involved in processing of http servlets?

0 Answers  


What is Server-Side Includes?

1 Answers   IBM, SAS,






What is the use of servlet wrapper classes?

0 Answers  


If we disable cookies in our web page, what will happen?

6 Answers   Zensar,


How is an application exception handling is done using a servlet?

0 Answers  


what is the difference between ServletContext and ServletConfig

7 Answers  


What are the functions of Servlet container?

0 Answers  


How will you open a new page after certain interval of time (5 sec), on clicking of a button in an html page?

2 Answers  


What is the difference between Servlets and Applets?

0 Answers  


Categories