Can we write a constructor for a Servlet class ? if yes how ?
if no why not ?

Answer Posted / abhishek taneja

yes offcourse you can write a constructor for a servlet
after all it is a java class. you can simply provide but if
u do not provide then it is by default include the no
argument constructor that is used by the Init() method in
the servlet life cycle.

Is This Answer Correct ?    11 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the types of an http request?

585


Define the lifecycle for executing a jsp page.

597


When a client request is sent to the servlet container, how does the container choose which servlet to invoke?

580


What is the structure of the http response

677


What is getservletcontext?

552






Can you refresh servlet in client and server-side automatically?

624


How the servlet is loaded?

602


Write the code to get the server information in servlet.

575


Explain request dispatcher and its methods.

591


What is cgi and what are its drawbacks?

555


What is the use of httpservletrequestwrapper and httpservletresponsewrapper?

545


Tell us something about servletcontext interface.

628


How is a servlet implemented in code?

568


What are the steps that are required to handle the multi-threading?

599


Describe some assignments that are executed by servlet container?

589