Servlet Advantages


Servlet is server side technology in java and it is class file which executes inside the JSP/Servlet container. Servlets are used to write mainly business logic in web application. Servlet is placed inside the private scope of the web application so nobody can access it directly.

In order to expose the servlet, we have to map it inside the web.xml file using "servlet" mapping tag and some unique url-pattern is assigned. Now servlet can be accessed outside the world using this unique "url-pattern".

All the java popular web application frameworks are based on Servlet. Like Spring, JSF , Struts etc.

Advantages of Servlet :-

  Servlets are used to generate dynamic web pages.

  Servlet is a class file so we can utilize all the features of java like thread, collections, exception handling , gc etc.

  Servlet is part of JEE stack so it is standard and it is easy portable across Web Servers which is based on JEE stack.
  Servlet can communicate with different servlet & servers.

  Since http is stateless protocol and servlet uses its own API to maintain session with end user

  Servlet has it's own life cycle to customize it.

 Servlets are used to write business logic for the web applications.

 Servlet acts as front controller for web application frameworks and web services frameworks like Spring MVC, Struts 1.x, JSF, Apache Axis-2, Apache CXF etc.