Day 14 · Week 2 · Web + Data

JSP — a historical tour.

JSP is the technology that taught the Java world how server-rendered HTML works. It is mostly dead today — but understanding it is the bridge between yesterday's MVC and today's REST + React separation. One short, focused day.

~15 min readhistorical onlyno coding needed
You will not write JSP. You will see it in legacy codebases and interview questions. Today is just enough to recognize, contextualize, and move on. Then we close Week 2 and head into Spring.

The problem JSP solved

Day 1 hinted at the pain: writing HTML inside Java with out.println():

// Servlet rendering HTML — painful
res.getWriter().println("<h1>Hello " + user.getName() + "</h1>");
res.getWriter().println("<ul>");
for (Item i : cart) {
  res.getWriter().println("<li>" + i.getName() + "</li>");
}
res.getWriter().println("</ul>");

HTML disappears into Java strings. Designers can't touch it. Refactoring is brittle. JSP inverted this:

<!-- hello.jsp — HTML with embedded Java -->
<h1>Hello <%= user.getName() %>!</h1>
<ul>
<% for (Item i : cart) { %>
  <li>${i.name}</li>
<% } %>
</ul>

Now HTML is the foreground. Java is the foreground only when needed. This was a major usability win in 2000.

How JSP actually works

Here is the trick that surprises everyone:

🧠 JSP is a Servlet in disguise

The first time a request hits hello.jsp, the Servlet container compiles the JSP file into a Servlet class, then runs it. From that point on, the JSP is a Servlet. Everything you learned yesterday about Servlets applies — same lifecycle, same threading, same dispatcher.

Translation:

hello.jspyour filetranslatehello_jsp.javagenerated Servlet sourcejavachello_jsp.classruns in container
The two-stage JSP compilation. The user only writes hello.jsp.

The JSP syntax in 90 seconds

SyntaxMeans
<% code %>Scriptlet — Java statements that go straight into service()
<%= expr %>Expression — outputs the value
<%! decl %>Declaration — goes outside service() (rare)
<%@ page import="..." %>Directive — like an import for the file
${expr}EL (Expression Language) — modern, accessing properties cleanly
<c:if test="...">JSTL tags — preferred over scriptlets in modern JSP

Modern JSP (post-2010) discourages scriptlets entirely. Use EL + JSTL tags. But by then, the world had already moved on.

The Model-View-Controller pattern (where JSP lived)

JSP was rarely used alone. It was the View in the classic MVC pattern:

BrowserrequestControllerServletload dataModel (services)forwardViewJSP renders HTMLBrowserHTML
The classical Java MVC. The Servlet computes; the JSP renders.
  1. Browser hits /users
  2. Servlet (controller) loads users from the model layer
  3. Servlet places data into request attributes: req.setAttribute("users", users)
  4. Servlet forwards to users.jsp
  5. JSP loops over the data, generates HTML
  6. HTML returned to browser

This pattern shaped Spring MVC. The names persist: @Controller, Model, view templates. Spring just modernized each piece.

Why JSP died

JSP's losses

  • Server has to render every interaction — every click is a full page load
  • Bad for SPA-style apps — modern UI is interactive, not page-based
  • JS frameworks (React/Vue/Angular) render in the browser, way faster on subsequent interactions
  • Mobile apps can't consume HTML — they need JSON
  • Microservices push toward language-agnostic JSON over HTTP — REST

What replaced it

  • Backend serves JSON via REST endpoints
  • Frontend (React/Vue/Angular) is a separate codebase, often a separate deployment
  • Same backend serves web, mobile, third-party APIs
  • Designers and frontend engineers can work without touching Java
  • For server-rendered Java apps, Thymeleaf replaced JSP within the Spring world (better syntax, modern)

Where you'll still meet JSP

📌 Interview-ready answer

"JSP is a templating technology that compiles to a Servlet. It was the way Java did server-side HTML rendering before REST + frontend frameworks took over. It's still around in legacy apps, but new projects use REST APIs with separate frontends, or Thymeleaf when server rendering is needed."

Week 2 — what you've gained

You walked into Week 2 knowing modern Java. You walk out knowing the entire stack a Spring app sits on:

DayWhat you locked in
8HTTP fluency — methods, statuses, headers, idempotency
9SQL essentials — joins, indexes, the relational mental model
10Transactions, ACID, isolation levels, cascades
11Raw JDBC — felt the boilerplate Spring saves you from
12Servlets — lifecycle, filters, the foundation Spring builds on
13REST architecture — Fielding's six constraints, real-world rules
14JSP — historical context, why we moved past it
🎉 You've completed half the journey

Weeks 1 and 2 are the foundations. From here, every concept you'll meet — IoC, AOP, JPA, REST controllers, transactions in Spring — has a home in your mental model. You will not be lost in Spring. You'll see annotations as labels on familiar machinery.

Week 3 begins the modern era: Spring Core. IoC, DI, beans, AOP, proxies. Take a day off first.

Pause & reflect

Lock in today's learning

Final week-2 reflection. Take it seriously.

  1. What is JSP and how does the container actually run it?
  2. What four parts of the JSP syntax should you recognize?
  3. What was the classical Java MVC request flow? (Browser → ? → ? → ? → Browser)
  4. Name three reasons JSP fell out of favor.
  5. What replaced JSP in the Spring world for server-rendered HTML, and what replaced it more broadly across the industry?
  6. Sketch the journey from raw HTTP bytes (Day 8) all the way to a JSP-rendered HTML page using Days 11–14 concepts.

End of Day 14 — and Week 2. You earned the break before Week 3.