Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Step by Step Servlet Video Tutorial – First Java Servlet Program

servlet is programmed with the Java language, so all the Java features such as high portability, platform independence, security and Java database connectivity is applicable. As servlet modules run on the Server machine, they receive requests from clients and sends response in html format.

SERVLET LIFE CYCLE

Above figure shows, the life cycle of servlet. As the first request from client browser, the server container that is web server (ex. Tomcat, Glassfish ) locates servlet and create the instance and called init method. It is called only once and not for each user request. so, it is used for one-time initializations.

To process that request , service method get invoked. It is the main method to perform the actual task. The servlet container that is the web server (ex. Tomcat, glassfish) calls the service() method to handle requests coming from the client browser and to write the  response in html format & send back to the client. for each request for a servlet, the server assign a new thread and calls service method.according to HTTP request type service method calls doGet , doPost , doPut, doTrace doDelete method.

After the destroy() method is called, the servlet object is marked for garbage collection. The destroy() method is called only once. Here we can put the code for clean activities like close database connections,  write cookie lists or hit counts to disk etc.

Install Java Development Kit (JDK) first, then Install Netbeans version above 8 , Please choose setup according to your operating system. during installation select glass fish server or apache tomcat server as shown below.

Following video shows step by step instruction to develop first servlet program using netbeans IDE.

Thanks !



This post first appeared on DIGITAL PADM, please read the originial post: here

Share the post

Step by Step Servlet Video Tutorial – First Java Servlet Program

×

Subscribe to Digital Padm

Get updates delivered right to your inbox!

Thank you for your subscription

×