Skip to main content

Servlet API & Lifecycle

Learn Servlet API & Lifecycle (Intro to Web & Servlets, JSP Servlets) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

What is Servlet? • A Servlet is a Java class used to handle client requests and generate dynamic web content. Servlet API Packages • jakarta.servlet • jakarta.servlet.http Main Interfaces & Classes • Servlet • GenericServlet • HttpServlet • HttpServletRequest • HttpServletResponse • ServletConfig • ServletContext Servlet Lifecycle Methods • init() → Called once when servlet is created • service() → Called for each request • destroy() → Called once before servlet is removed

More lessons in Intro to Web & Servlets