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

Which event is fired at the time of project deployment and undeployment?

931


Which is better jsp or servlet?

646


What are the uses of servlets?

701


Explain url encoding?

608


What is the directory structure of a war file?

788






Explain the difference between jsp and servlet?

661


Define the servlet mapping.

620


Why doesn’t a servlet include main()?

646


What is the use of java servlet api?

671


Explain the features are in servlet 3?

685


Why servlet is faster than jsp?

645


What's the use of servletcontext?

772


What is a cookie What is the difference between session and cookie

678


How do you find out what client machine is making a request to your servlet

617


What is servlet used for?

775