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
What if the static modifier is removed from the signature of the main method?
What is re-entrant. Is session beans reentrant. Is entity beans reentrant?
What is abstract schema?
Why are my checkboxes not being set from on to off?
which book is better for jdbc ,servlets and jsp
What are the difference between RMI and CORBA?
What is TL and its use?
Name three component subclasses that support painting?
What are callback interfaces?
how to make a index.jsp for running the site in internet and find an error for connection with weblogic server and java that give an error invalid object name.and how to maintain session.
To what value is a variable of the string type automatically initialized?
How to deploy Jar, War files in J2EE?
How to implement RMI in Java?
Is it possible to stop the execution of a method before completion in a sessionbean?
What are local interfaces? Describe.