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 life-cycle methods for a servlet?
How native code can be used in a servlet?
How to get the current httpsession object?
Difference between java beans & servlets?
What is servlet in tomcat?
Explain servlet events?
What is servlet and its life cycle?
What are the differences between the servletconfig interface and the servletcontext interface?
Which interface should be implemented by all servlets?
What is url encoding and url decoding
What are the differences between servlet context vs servlet config?
Why do you use session tracking in httpservlet?
Name the different ways of session tracking.
What is the capacity the doget can send to the server?
What methodology can be followed to store more number of objects in a remote server?