Servlet

Why Servlet is useful?

Servlet is used in web development, it is executed within web server's process such as Tomcat or WebLogic, and it is persist between message invocations, which gives better performance and portability.

ServletContext

Servlet can provide dynamic web content creation?

Some of the most useful API methods:

How does Servlet work?

Write java class extended from javax.servlet.HttpServlet.

Web request is directed to Servlet Engine via HTTP GET or POST, Servlet Engine then encapsulates HTTP request into a class called HttpServletRequest and delivers it to Servlet class doPost or doGet method.

The Servlet responds by writing HTML into HttpServletResponse and sent back to Servlet Engine via redirect method.

DoGet vs. DoPost

Servlet Design Issues

Since Http is a stateless protocol and session managmeent are done in Java HttpServletSession class. Servlets are managed in Servlet Engine.

Usefule links to read Servlet Design Issues