1) Can we override the service method of servlet?
A) Yes
2) What is Servlet? what is Generic servlet?
or
what is difference between Servlet and Generic Servlet?
A) Servlet is an interface. GenericServlet is a class which extends Servlet interface.
3) How do we pass data from one servlet to another servlet?
A) hint is ----- request.setAttribute() & requestDispatcher()
4) Explain how will you invoke a servlet from a JSP page?
A) urlpattern of servlet is configured in web.xml
5) Can we override service() method of servlet?
A) Yes.we can override. then, we need to explicitly call doGet() or doPost() from service method.
6)Servlet,geneticServlet,httpServlet which one class and which one is interface?
A) Servlet is an interface, GenericServlet class implements Servlet interface. HttpServlet class extends GenericServlet class
7) What is ServletConfig? Interface or class? What is it’s purpose?
A) ServletConfig is an interface. It’s parameter of the init() method. Servlet Container passes the data to servlet through ServletConfig. servletconfig.getInitParameter(“init-param-name”)
8) When is servlet object created?
A) servlet object can be created in 2 situations
a) when the webserver starts.
b) when the first request for the servlet is made. ifis used in web.xml, webserver creates servlet when webserver is started
9) What are lifecycle methods in servlet?how many times init() method called in servlet?
A) life cycle of servlet consists of init(), service(), destroy() methods. init() is called only once
10) How do you retrieve the data entered on a jsp page inside a servlet?
A) String s = httprequest.getParameter(“parameter name”);
11) How do you invoke a servlet from another servlet?
A) Through RequestDispatcher. requestdispatcher.forward();
12) How do you create RequestDispatcher object?
A) RequestDispatcher rd = request.getRequestDispatcher(“url pattern of servlet”);
13) when is the servlet object grabage collected?
A) after the destroy() is invoked by container
14) How do you create HttpSession object?
A) session = httprequest.getSession() & session = httprequest.getSession(boolean)
15) what is ServletContext? what are HttpServletRequest and HttpServletResponse?
A) HttpServletRequest & HttpServletResponse are interfaces.
ServletCotext interface has methods used by servlet to communicate with the servlet container.
16) Tell me the url to invoke a servlet?
17) How do you pass the data to servlet at initialization time?
A) using the init parameters in web.xml file.
18) What is the method of RequestDispatcher?
A) forward (req,response) and include()
19) How many servlet are created for 10 web requests to same servlet? (Threading issues)
A) Yes
2) What is Servlet? what is Generic servlet?
or
what is difference between Servlet and Generic Servlet?
A) Servlet is an interface. GenericServlet is a class which extends Servlet interface.
3) How do we pass data from one servlet to another servlet?
A) hint is ----- request.setAttribute() & requestDispatcher()
4) Explain how will you invoke a servlet from a JSP page?
A) urlpattern of servlet is configured in web.xml
5) Can we override service() method of servlet?
A) Yes.we can override. then, we need to explicitly call doGet() or doPost() from service method.
6)Servlet,geneticServlet,httpServlet which one class and which one is interface?
A) Servlet is an interface, GenericServlet class implements Servlet interface. HttpServlet class extends GenericServlet class
7) What is ServletConfig? Interface or class? What is it’s purpose?
A) ServletConfig is an interface. It’s parameter of the init() method. Servlet Container passes the data to servlet through ServletConfig. servletconfig.getInitParameter(“init-param-name”)
8) When is servlet object created?
A) servlet object can be created in 2 situations
a) when the webserver starts.
b) when the first request for the servlet is made. if
9) What are lifecycle methods in servlet?how many times init() method called in servlet?
A) life cycle of servlet consists of init(), service(), destroy() methods. init() is called only once
10) How do you retrieve the data entered on a jsp page inside a servlet?
A) String s = httprequest.getParameter(“parameter name”);
11) How do you invoke a servlet from another servlet?
A) Through RequestDispatcher. requestdispatcher.forward();
12) How do you create RequestDispatcher object?
A) RequestDispatcher rd = request.getRequestDispatcher(“url pattern of servlet”);
13) when is the servlet object grabage collected?
A) after the destroy() is invoked by container
14) How do you create HttpSession object?
A) session = httprequest.getSession() & session = httprequest.getSession(boolean)
15) what is ServletContext? what are HttpServletRequest and HttpServletResponse?
A) HttpServletRequest & HttpServletResponse are interfaces.
ServletCotext interface has methods used by servlet to communicate with the servlet container.
16) Tell me the url to invoke a servlet?
17) How do you pass the data to servlet at initialization time?
A) using the init parameters in web.xml file.
18) What is the method of RequestDispatcher?
A) forward (req,response) and include()
19) How many servlet are created for 10 web requests to same servlet? (Threading issues)
No comments:
Post a Comment