suraj kumar


{ City } bhubaneswar, orissa
< Country > india
* Profession * lead consultant
User No # 38653
Total Questions Posted # 3
Total Answers Posted # 2

Total Answers Posted for My Questions # 5
Total Views for My Questions # 17230

Users Marked my Answers as Correct # 18
Users Marked my Answers as Wrong # 5
Questions / { suraj kumar }
Questions Answers Category Views Company eMail

What is Connection Pooling?

Enteg Technologies, Infosys, Polaris,

1 Advanced Java 5566

What are Benefits of Connection Pooling?

2 Advanced Java 5312

What are uses of Hash Code?

Cognizant,

2 Core Java 6352




Answers / { suraj kumar }

Question { Ericsson, 21320 }

Can we call destroy() method inside the init() method? What
happens when we do so?


Answer

This action does not disturb the normal life cycle flow of the servlet. The servlet will work normal. You may test the below code.

/**
* @author Suraj
*
*/
public class TestServlet extends HttpServlet {


public void init(ServletConfig config)throws ServletException{
super.init(config);
destroy();
}

protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {

System.out.println("I am test servlet.");
}

}

Web.xml
--------------------------------------


Servlet

TestServlet
com.esspl.TestServlet


TestServlet
*.do


------------------------------------
Test URL: http://://TestServlet.do

Is This Answer Correct ?    10 Yes 4 No

Question { Wipro, 12045 }

Why does most servlets extend HttpServlet?


Answer

Yes, HttpServlet simplifies the handling of HTTP protocol but there is no hard and fast rule that the servlet class must extend abstract HttpServlet class. it may extend GenericServlet class to make the Servlet protocol independent.

Is This Answer Correct ?    8 Yes 1 No