Can we define constructors in Servlet?

Answer Posted / vivekanand prasad

The init() method creates and loads the servlet.But the servlet instance is first created through the constructor (done by Servlet container). We cannot write constructors of a servlet class with arguments in servlet (It will throw Exception). So, They provided a init() method that accepts an ServletConfig object as an argument.ServletConfig object supplies a servlet with information about its initialization (init) parameters.Servlet class cannot declare a constructor with ServletConfig object as a argument and cannot access ServletConfig object.

Is This Answer Correct ?    20 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What’s jboss cache in short?

604


Is it possible to stop the execution of a method before completion in a sessionbean?

603


What is aop(assepct oriented programing)?

584


Explain the advantages and disadvantages of detached objects.

577


Brief description about local interfaces?

630






Can I have an action without a form?

600


Where can I find seam examples and documentation?

570


Why won’t the jvm terminate when I close all the application windows?

756


How messaging services are done, before release of JMS?

1592


What you mean by COM and DCOM?

619


Is there a guarantee of uniqueness for entity beans?

572


Can I run seam outside of jboss as?

644


Why does the tag url-encode javascript and mailto links?

587


what are memory considerations of jsp compares to other web components?

6019


What is the difference between static and non-static with examples?

1364