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.
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:
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:
- Static HTML →
out.write("...")calls <% ... %>scriptlets → Java code in the generatedservice()<%= expr %>→out.write(String.valueOf(expr))- EL expressions
${user.name}→ property accesses
The JSP syntax in 90 seconds
| Syntax | Means |
|---|---|
<% 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:
- Browser hits
/users - Servlet (controller) loads users from the model layer
- Servlet places data into request attributes:
req.setAttribute("users", users) - Servlet forwards to
users.jsp - JSP loops over the data, generates HTML
- 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
- Legacy enterprise apps — many internal tools at banks, telecoms, government still run JSP
- Older Spring MVC apps using JSP as the view layer
- Interview trivia — "what's the difference between a Servlet and a JSP?"
"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:
| Day | What you locked in |
|---|---|
| 8 | HTTP fluency — methods, statuses, headers, idempotency |
| 9 | SQL essentials — joins, indexes, the relational mental model |
| 10 | Transactions, ACID, isolation levels, cascades |
| 11 | Raw JDBC — felt the boilerplate Spring saves you from |
| 12 | Servlets — lifecycle, filters, the foundation Spring builds on |
| 13 | REST architecture — Fielding's six constraints, real-world rules |
| 14 | JSP — historical context, why we moved past it |
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.
Lock in today's learning
Final week-2 reflection. Take it seriously.
- What is JSP and how does the container actually run it?
- What four parts of the JSP syntax should you recognize?
- What was the classical Java MVC request flow? (Browser → ? → ? → ? → Browser)
- Name three reasons JSP fell out of favor.
- What replaced JSP in the Spring world for server-rendered HTML, and what replaced it more broadly across the industry?
- 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.