Free Jobs
Reference




click here


click here
Servlet Interview Questions(Basic)

For more advanced and tough Servlet Interview Questions Click Here



Q1. What is a Java servlet?
A Java servlet is a J2EE component that run on the Server. In other words A Java servlet runs in a Web server or application server and provides server-side processing like accessing a database and/or e-commerce transactions etc.

Q2. What is Servlet LifeCycle?
Servlet Lifecycle has following three phases:
a)Creation and intialization : Handled by init() method.
b)Execution of service : Handled by service() method.
c)Destroy the servlet : Handled by destroy() method.

Q3. What is servlet mapping?
Servlet mapping maps url patterns to servlets.If a request from a client comes, servlet container decides to what application the request should be forwarded to.

Q4. What is Servlet Invoker?
Servlet Invoker is used to dispatch servlets by class name. The purpose of Invoker Servlet allows a web application to dynamically register new servlet definitions that correspond with a servlet tag in the /WEB-INF/web.xml deployment descriptor.


Q5. What is meant by the Default initialization of Java Servelet?
In the Default initialization of Java Servlet,the java servlet is initialized when the servlet is called for the first time.Another term for this type of servlet initialization is called lazy loading.

Q6. How is HttpServlet is different from GenericServlet?
HttpServlet extends the GenericServlet ,thus inherits the properties of GenericServlet. Also HttpServlet defines a HTTP protocol specific servlet while GenericServlet defines a generic, protocol-independent servlet.

Q7. Why a constructor is not prefereble in java servlet?
Ideally we can define constructors in servlet. But the constructor cannot access the ServletConfig object.So To overcome this, init() method is used for initialization instead of declaring a constructor.

Q8. How to get the current HttpSession object?
The current HttpSession object can be achieved by calling the getSession method on HttpServletRequest.


Q9. In the context of Servlet what is Filter?
Filters dynamically intercept request and response objects and change/use the data present in those objects while performing actions like authentication/style conversion etc.Filters are configured in the web deployment descriptor.

Q10..When we call the Destroy() method on the servelet will the servlet be destroyed?
No.When we call the Destroy() method on the servlet the the servlet will NOT be destroyed.Only the code inside the Destroy() method will be executed.The name of the Destroy() method is confusing ,actually it does not destroy the object but the code inside it runs when the object is destroyed.

For more advanced and tough Servlet Interview Questions Click Here









www.freejobsreference.com Copyright © 2009-2011 | All Rights Reserved
All content of this website is protected by copyright laws and should not be reproduced in any form or by any means without written permission
(Best viewed in IE 8.0+ or Firefox 3.0+ at resolution of 1024 * 768 or higher)