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
the same information whether it will connect to the database or it will be used previous information?
If your ui seems to freeze periodically, what might be a likely reason?
What is the difference between long.class and long.type?
What is the diffrence between a local-tx-datasource and a xa-datasource? Can you use transactions in both?
What is a policy?
What is TL and its use?
What is scalable, portability in the view of J2EE?
Describe, in general, how java's garbage collector works?
Difference between swing and awt?
Why a component architecture for the java platform?
What is the difference between the session.get() method and the session.load() method?
What are the benefits of detached objects?
wahts is mean by dynavalidatorform in struts/
What is abstract schema?
How are the elements of a cardlayout organized?