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

What if you need to span your transaction across multiple servlet invocations?

574


what do you understand by url rewriting?

541


Is java servlet still used?

585


How can you run a servlet program?

597


What is the use of httpservletrequestwrapper?

586






what is servlet chaining?

619


How do you deal property files in servlet?

598


How to rectify errors in java servlet while compilation?

515


What is the use of httpservletresponsewrapper?

528


Can you explain in detail 'javax.servlet' package?

543


What is the use of request dispatcher interface?

565


Hello, My project requirement is like I need to create a web page using MVC pattern. I hava a bean class, jsp page, servlet, service and dao. My jsp has two fields. One is dropdown list. The option values has to get populated from the database table. The other one is a text box and its value has to come from database table. As of now I have defined the fields in bean class, got the values from database using arraylists in dao class and I called this from service class. Can anyone please tell me the workflow of how the servlet will get this arraylist and populate the arraylist values as dropdown options in jsp page? Also I would like to know the role of bean class in MVC pattern? Thanks in advance!

1829


Explains the differences between context.getrequestdispatcher() and request.getrequestdispatcher()?

546


What are the advantages of cookies?

626


What are the kinds of http requests?

605