OVERVIEW OF SERVLETS »



OVERVIEW OF SERVLETS Servlets provide a Java based solution used to address the problems currently associated with doing server side programming including inextensible scripting solution, platform specific API’s, and incomplete interfaces. Servlets are objects that confirm to a specific interface that can be plugged into a Java based server. Servlets are to the server side [...]

Thread safety of the servlet »



Q) How to ensure the thread safety of the servlet? Rep) 1) It is better to avoid instance variables & static variables in a servlet class 2) If the instance variable reference to a threadsage object then there will be no problem 3) If all Instance variables refers to an object that is not thread [...]

Can we provide a constructor in the servlet class »



Rep) As the Web Container uses newInstance() method for creating the servlet object,If requiered we can provide a zero arguent constructor

How the Web Container creates a servlet object »



Rep) Web Container reads the name of the servlet class from web.xml and uses Class.forName() method to load the servlet class and it calls the newInstance() method to create the servlet Object.