OE-3.5 Servlets, JSP & Database Connectivity
You can explain the servlet lifecycle, handle requests and responses, track sessions, write JSP pages with directives and standard actions, and connect a servlet or JSP to MySQL.
This unit is where the language turns into a web application, and the servlet lifecycle is its central abstraction - the container creates, initializes, services and destroys, and you write only the middle. Session tracking exists because HTTP has no memory; the four approaches all solve that one problem differently. JSP is servlets written inside out, which is worth knowing when the generated code shows up in a stack trace.
Work through these
Overview of the Java Servlet API; servlet implementation and configuration
The server-side half of the course, and the object that handles one request. Configuration is included because a servlet that is not mapped is a servlet that never runs.
NPTEL: Programming in Java · CourseServlet exceptions and the servlet lifecycle
What can go wrong, and the sequence of calls the container makes. The lifecycle explains why some initialisation belongs in one method and not another.
Request and response methods
How a request is read and a response is written, which is the whole of the job in two objects. Everything else is arranged around these.
Approaches to session tracking
The web forgets who you are between requests, and these are the ways round it. Comparing cookies against server-side sessions is the security-relevant part.
Servlet context and servlet collaboration
Shared state across an application, and how two servlets cooperate. It is also where concurrency problems from the earlier topic reappear in a web setting.
JSP directives, scripting elements and standard actions
Writing pages that contain code rather than code that writes pages. The comparison with the servlet approach is the content, not the syntax.
Connecting a servlet to MySQL
Reaching a database from server-side code, which is where the course finally touches real data. Connection handling is the part that goes wrong in production.
Connecting a JSP to MySQL
The same connection from the page-oriented side. Doing it both ways shows you why mixing data access into a page is discouraged.
Sign in to keep your progress.
Free resources
We haven't checked most of these for screen reader use yet.
Links last checked 30 Aug 2026.
Stuck here?
Ask a mentor. A real person answers, and they can see exactly which topic you're on. Usually within a couple of working days.
Checking your session…
Topics shown in module order.