Hi guys.. Well can u tell me that why there is need of
"init()" , i mean why can not we initialize the servlet object
with the help of constructors?
Thank you.

Answer Posted / manas banerjee

you can use but should not.the original reason for init()
was that ancient version of java could not dynamically
invoke constructors with arguments.so there was no way to
give the constructors a ServletConfig.So u would not have
to access to ServletConfig or ServletContext.

{{in short:init() has access to servletconfig and
servletcontext object constructor would not..

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can we invoke another servlet in a different application?

907


What is the difference between the servlets and cgi programs?

733


What is a servlet context object?

861


What are the steps involved in placing a servlet within a package?

825


how the HTML data stored in web server?

2179


What is ServletConfig object?

817


What is the difference between forward () and sendredirect () functions in servlet? Explain

738


What is SingleThreadModel interface?

861


List some life cycle methods of a servlet.

781


How to generate the server side programming and the advantages of it over the other languages?

766


What is meant by a servlet?

782


How can you use a servlet to generate a plain text instead of html?

840


Explain the difference between jsp and servlet?

769


How do you communicate in between Applets and Servlets?

803


Is servlet a server side scripting language?

803