Servlets Q)What is Servlets? =>Servlets is a Java based web technology from Sun Microsystems. Note:- As part of Every Java Technology, Sun Microsystems developed 2 doucments. JDBC technology 1)JDBC API 2)JDBC Specification(Set of Rules) =>JDBC API for application developers =>JDBC Specification for JDBC Driver vendors Servlet technology 1)Servlet API 2)Servlet Specification(Set of Rules) =>Servlet API for application developers =>Servlet Specification for Web Container vendors Q)What is a servlet? =>A servlet is a (web)server side Java program* that extends the functionality of a web server. =>A servlet is a web component a Java web application. =>A servlet is a dynamic web resource in a Java web application. =>A servlet is a Servlet Container managed public Java class that implements javax.servlet.Servlet interface. Q)What can a servlet do in a web application? 1)capturing the user input 2)communicating with the database. 3)processin the data 4)producing the response page 5)handing over the response page to the web server Q)What is the general structure of a servlet? public class MyServlet implements Servlet { public void init() { //resources allocation code //For eg. database connection, PreparedStatement } public void service(ServletRequest request,ServletResponse response) { // duties of the servlet } public void destroy() { //resources deallocation //For eg, closing the PreparedStatement, closing the database connection } ....... } Q)What is the life cycle of a servlet? =>servlet life cycle is described by 4 life cycle phases and 3 life cycle methods. =>Servlet Container controls the the life cycle of a servlet. =>Life cycle phases of a servlet are 1)instantiation phase 2)initialization phase 3)servicing phase 4)destruction phase =>Life cycle methods of a servlet are 1)init 2)service 3)destroy