Can we define constructors in Servlet?

Answer Posted / qim2010

One can definitely have constructor in servlet. Even you can
use the constructor in servlet for initialization purpose,
but this type of approach is not so common. You can perform
common operations with the constructor as you normally do.
The only thing is that you cannot call that constructor
explicitly by the new keyword as we normally do. In the case
of servlet, servlet container is responsible for
instantiating the servlet, so the constructor is also called
by servlet container only.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the benefits of detached objects?

587


What is the purpose of the notifyall() method?

613


What is the difference between the font and fontmetrics classes?

566


What is the diffrence between a local-tx-datasource and a xa-datasource? Can you use transactions in both?

574


What do you know about seam?

602






What is ripple effect?

637


What must a class do to implement an interface?

587


What is the immediate superclass of the applet class?

605


Why are component architectures useful?

575


How can I avoid validating a form before data is entered?

556


What is threadfactory?

620


What is the highest-level event class of the event-delegation model?

578


What is the difference between the string and stringbuffer classes?

547


what are the advantages of JTA over JTS?

1674


What is the difference between the ‘font’ and ‘fontmetrics’ class?

642