Breaking News
Popular News
Enter your email address below and subscribe to our newsletter
Servlet is a technology that are used to extends the capabilities of an server.
Java Servlets are programs that run on a web or application server and acts as middle layer between a request coming from a web browser or other HTTP client and from database or application on the HTP Server.
Servlets is an API in which No. of interface and classes are presents to create web application.
Using servlets , we can collect the data or input from users by or through a web page forms , presents the records from a database or another source , and create web pages dynamically. Java servlets are thread based or it initialized the thread.
Java servlets are portable. Java servlet API contains two packages:- 1.) Javax.servlet package 2.) Javax.servlet.http package There are many interface in Javax.servlet package . These are:- 1. ServletRequest 2. ServletResponse 3. ServletConfig 4. ServletContext 5. RequestDispatcher A. Forword B. Include There are many interface in Javax.servlet.http package . These are:- 1. HttpServletRequest 2. HttpServletResponse 3. HttpServletSession etc. Servlet Life cycle In servlet life cycle , there are three methods :- 1. init () 2. service () 3. destroy () Step 1. Servlet class is loaded on the server and the servlet instance is created. Step 2. The servlet is initialized by calling inint() method.The init() method is initialized only once for a servlet. Step 3. After servlet initialization , servlet calls service method to process a client request. Step 4. After successfully execution of program servlet calls the destroy () method and servlet is terminated. Finally servlet is garbage collected by the garbage collector. Steps to create a servlet:- The servlet can be created by three steps. These steps are . : -