Can we define constructor in Servlet class?
Answer Posted / srikanth b
Yes, we can define constructor in Servlet class.
Constructor may be a Default Constructor or Parameterised
Constructor.
If we didn't write any constructor then the default
constructor will be executed. Because, to read init
parameters of a servlet we need servlet config object in the
life cycle of the servlet. Servlet config object object is
created after the execution of the constructor.
| Is This Answer Correct ? | 1 Yes | 3 No |
Post New Answer View All Answers
What are the phases of servlet life cycle?
What is the use of httpservletresponsewrapper?
Which event is fired at the time of setting, getting or removing attribute from application scope?
What are all the protocols supported by httpservlet?
What are the different session tracking techniques?
Explain the role of dispatcherservlet and contextloaderlistener.
Which protocol will be used by browser and servlet to communicate
Difference between forward() method and sendredirect() method ?
Can you use javascript in servlets?
Explain the war file?
How can you push data from an Applet to a Servlet?
How do I support both get and post from the same servlet?
Explain the methods of request dispatcher in servlet?
explain the advantages of servlet life cycle?
Explain web container.