# JSP & the MVC Pattern — Advanced Java

Source: https://www.geekswithgeeks.com/en/advanced-java/adv-jsp-mvc

> Separate request handling from view rendering with the Model 2 / MVC pattern, where a front controller builds a model and forwards to a JSP or template view.

## Model 2 / MVC

A front controller (servlet) handles the request, builds a **model**, and forwards to a **view** (JSP or a template engine like Thymeleaf) for HTML. Business logic never lives in the page. Modern stacks replace raw JSP with Spring MVC controllers returning views or JSON.

## DispatcherServlet: Spring's front controller

Spring MVC's `DispatcherServlet` **is** the Model 2 front controller: it receives every request, resolves the matching `@Controller` method, and either renders a view name or, with `@RestController`, writes the return value straight to the response body as JSON.
