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 is synchronization and why is it important?

543


How are the elements of a cardlayout organized?

596


What is the relationship between the canvas class and the graphics class?

540


What are the different class loaders used by jvm?

597


What is the difference between the session.update() method and the session.lock() method?

554






What is a class loader? What are the different class loaders used by jvm?

583


what is Activation Instantinator?

1907


What is a sessionfactory? Is it a thread-safe object?

679


how to make a index.jsp for running the site in internet and find an error for connection with weblogic server and java that give an error invalid object name.and how to maintain session.

1750


Difference between loadclass and class.forname?

596


Why doesn’t the focus feature on the tag work in every circumstance?

563


How would you create a button with rounded edges?

559


What is the difference between RMI and Corba?

2255


If we opened Windows Internet Explorer 4 times, does it starts 4 processes or 4 threads?

1736


In our urls and in the text of the buttons we have comma. Its causing an error. Is there a way to change the delimiting character for the menu arguments?

578