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
Explain the differences between jsp and servlet.
Explain the difference between servlet and cgi?
Whether thread can be used in servlets?
What is meant by session? Tell me something about httpsession class?
What are the various ways of session supervision in servlets?
A client sends requests to two different web components. Both of the components access the session. Will they end up using the same session object or different session ?
Can we fetch the attributes related to a servlet on a different servlet?
How can we achieve transport layer security for our web application?
explain the advantages of servlet life cycle?
Why is a constructor needed in a servlet even if we use the init method?
What is servlet configuration?
Which protocol will be used by browser and servlet to communicate
What are the differences between servlet context vs servlet config?
What is difference between jsp and servlet?
Which httpsession object is used to view and manipulate information about a session?