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

What are the mechanisms used by a servlet container for maintaining session information?

570


What are the advantages of Servlet over CGI?

670


What is a web container and what is its responsibility?

531


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

508


What is meant by a servlet?

610






Name the different ways of session tracking.

573


What are its drawbacks of cgi?

572


What are different methods of session management in servlets?

780


Explain the lifecycle of a servlet?

511


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

624


What exactly are the functions of servlet?

603


What is cookie? Why is cookie used?

586


Difference between get and post in java servlets?

550


How servlets are deployed in java?

548


What is the difference between Server and Container?

623