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
How to notify an object in session when session is invalidated or timed-out?
What is http servlet? Explain with the help of an example.
How can you push data from an Applet to a Servlet?
What is the functionality of actionservlet and requestprocessor?
Explain the working of service() method of a servlet.
How a servlet is unloaded?
What is the main purpose of java servlets?
Difference between GET and POST?
Explain the lifecycle of a servlet?
What is the default http method in the servlet?
How to get the actual path of servlet in server?
What is Servlets and explain the advantages of Servlet life cycle?
Is tomcat a servlet container?
When Servlet is unloaded?
What is httpservlet class?