can v create a constructor 4 servlet?

Answer Posted / chandra kunchala

yes ofcourse we should.
it is mandatory for servlet.
for servlets we required publc no argument constructor. if v
don't having that one, our servlet should not work, even
though if you are not crating the public no-argument
constructor, the java compiler will take the responsibility
to create public no- argument constructor.. mean while your
servlet should be public otherwise you will get
RuntimeException.


we can create costructor for sevelet but it should b no-
argument constructor. and u r servlet should be public.
and one more thing this constructor in not in the place of
init() method..

Is This Answer Correct ?    7 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the new features added to servlet 2.5?

595


What are important features of Servlet 3?

599


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

1838


What are different ways for authentication of servlet?

531


What is servlet looping or chaining?

660






When servlet is loaded?

596


What is a servlet?

611


Difference between forward() method and sendredirect() method ?

587


How to upload a file to the server using servlet?

533


How can we upload the file to the server using servlet?

546


Explain the war file?

612


What is the use of httpservletrequestwrapper?

592


Explain the role of dispatcherservlet and contextloaderlistener.

610


Why do we need a constructor in a servlet if we use the init method?

522


How to generate the server side programming and the advantages of it over the other languages?

565