Hackforge Academy

Category: java

Introduction to spring expression language spel

Published on 30 Sep 2026

Explanation

In Servlet-JSP MVC, the Servlet acts as Controller, Java objects and services form the Model, and JSP acts as the View.

Code:

Browser
   |
   v
Controller Servlet
   |
   v
Service / Model
   |
   v
Database
   |
   v
Controller
   |
   v
JSP View

Explanation

The servlet receives the request and calls the appropriate service or business logic.

Code:

@WebServlet("/students")
public class StudentServlet extends HttpServlet {

    protected void doGet(HttpServletRequest req,
                         HttpServletResponse resp)
                         throws ServletException, IOException {

        List<Student> students = service.findAll();
        req.setAttribute("students", students);
    }
}

Explanation

The servlet stores model data in request attributes before forwarding the request to the JSP.

Code:

req.setAttribute("students", students);

req.getRequestDispatcher("students.jsp")
   .forward(req, resp);

Explanation

The JSP uses EL and JSTL to display the data received from the controller.

Code:

<c:forEach var="student"
           items="${students}">
    <p>${student.name}</p>
</c:forEach>

Explanation

This separation keeps request handling, business logic, database operations, and presentation responsibilities separate.

Code:

Controller
    ↓
Service
    ↓
DAO
    ↓
Database

Controller
    ↓
JSP View
    ↓
HTML Response

🚀 Learn Spring Boot with real-world projects

💡 Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
⚛️

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
☕

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community