Java Servlets
Welcome, champion! 🔥
You've mastered 0 of 71 lessons. Start your first lesson free — no signup needed.
About this course
A servlet is a Java class that runs inside a web container such as Apache Tomcat and answers HTTP requests. Spring MVC, JSP and most Java web frameworks are built on the Servlet API, so knowing how servlets, filters and sessions work explains a lot of what those frameworks do for you. This online Java Servlets course on Abekus teaches the API from a first servlet answering GET /hello up to filters, listeners, asynchronous processing and security, in short reading-card lessons each followed by an MCQ quiz.
Who this Java Servlets course is for
It is written for Java freshers and backend developers who use Spring or older JSP-based code at work, or who face servlet questions in service-company interviews. You should be comfortable with core Java and have a basic idea of what an HTTP request and response are. By the end you can write, map and deploy servlets on Tomcat 11, handle requests, responses, sessions and cookies, add filters and listeners, protect an app against common web attacks and explain what Spring MVC adds on top.
Examples follow one setup throughout: Jakarta Servlet 6.1 with the jakarta.servlet packages, Apache Tomcat 11 and Java 21 LTS, with Jakarta Pages (JSP), EL and JSTL only in the views topic. One running example appears in every lesson: TaskBoard, a small task list app deployed as taskboard.war, with a TaskServlet, a login and logout servlet, an authentication filter and a JSON endpoint. The course leaves out Spring internals beyond one comparison lesson, Tomcat administration, full JSP or JSF courses, the WebSocket API and IDE screens. Older javax code appears only in the version and migration lessons.
How the lessons work
Each lesson is a short set of reading cards on one part of the API, usually with a few lines of code and the HTTP request or response it produces, followed by a quiz of multiple-choice questions that often ask what the container or browser will do. Lessons go from basics up: first a working servlet and the request-response cycle, then packages and versions, the lifecycle and threading model, WAR layout and URL mapping, reading requests and building responses, forward, include and redirect, sessions, cookies and scopes, filters and listeners, JSP views, asynchronous processing and error pages, and finally container security and web vulnerabilities. You move at your own pace.
MCQ practice vs video courses for Java Servlets
Video courses on Udemy, Coursera or YouTube are a good choice if you want to watch someone create a project, configure Tomcat and click through a browser. This course is built for a different job: a short explanation followed straight away by questions about real servlet code, such as which URL pattern wins for a request, whether a forward changes the browser's address bar, what happens to an instance field when two requests arrive at once, or which status code sendRedirect sends. Servlet behaviour follows precise rules, and predicting it question by question is what interviews and debugging both test. Many developers use both: a video for setup, and questions to make the rules stick.
Common Java Servlets mistakes
The course corrects these directly:
- Importing javax.servlet for Tomcat 10 or 11. Those versions need jakarta.servlet.
- Believing the container creates a new servlet object per request. One instance serves many request threads.
- Keeping mutable data in servlet instance fields. It is shared across threads; SingleThreadModel is not the fix and was removed in Servlet 6.0.
- Expecting a forward to change the browser's URL. Only sendRedirect does that.
- Thinking web.xml is required. Annotations such as @WebServlet have made it optional since Servlet 3.0.
- Writing user input straight into HTML. Output must be escaped to prevent XSS.
- Keeping the same session ID after login. Changing it with changeSessionId prevents session fixation.
Best way to learn Java Servlets
Build one small app end to end on a real container. Write a servlet, map it, read a parameter, store something in the session, redirect after a POST and put an authentication filter in front, then watch the requests and cookies the browser actually sends. The last part of the course is built around these choices: servlet versus JSP, servlet versus a Spring MVC controller, filter versus servlet, when to go asynchronous and when to keep state in the session, applied to a login flow for the task board, a JSON endpoint for a mobile app, a file download servlet and migrating a javax app to Tomcat 11.