Can we call init() method from service() method in servlet ? I got this as an interview question. Why would anyone do this anyway ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No reason to call
initfromservice,initis meant to be called by the container – to initialise it with configuration (as the name suggests) and to allow it to do any expensive operations it needs to do (setting up connections to database or whatever).It may make some sense if you wanted to programmatically reconfigure your servlet to call the
initfrom the servlet itself, but I struggle to see this use case.