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

Answer Posted / chandra

constructor required, but it should be public no-argument
constructor. even though if you are not write that
constructor java compiler will create that construtctor by
default. for that your servlet class should be public other
wise you will get RuntimeWxception saying RequestedResource
is not available like that.

Is This Answer Correct ?    9 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is it possible to have a constructor inside the servlet?

735


How printwriter is different from servletoutputstream?

767


What do you mean by deployment descriptor?

747


List some life cycle methods of a servlet.

782


Which method is called when reference variable is passed in system.net?

2053


What are advantages of servlets over cgi?

812


What is meant by cookies?

829


How do you load an image in a Servlet?

862


Explain the difference between servlet and cgi?

807


What is the structure of the http response

910


Tell us something about servletconfig interface.

761


Explain the difference between generic servlet and http servlet?

730


What is the use of send redirect () method?

785


What is called servlet container?

832


What are the difference between session and cookies in servlet? Explain

783