Advanced Java Essentials – Episode 12: JSP, JSTL and the MVC Architecture Pattern (Updated June 2026) (Updated June 2026)
What most people do not realize about JSP is that it is not a legacy relic — it is still actively deployed in thousands of Indian banking systems, government portals, and enterprise applications, and understanding it thoroughly sets you apart from developers who only know modern frameworks. NASSCOM estimates India's IT services exports will cross $300 billion by 2027, and a significant share involves maintaining, migrating, and extending JSP-based systems. Episode 12 of our Advanced Java series covers JSP from syntax basics through JSTL and Expression Language to the MVC architecture pattern that every Java web framework follows — knowledge that makes you effective in both legacy maintenance and new development.
- JSP lets you embed dynamic Java content in HTML pages — the Servlet container compiles JSP to Servlet at runtime
- JSTL (JSP Standard Tag Library) replaces messy Java scriptlets with clean, readable tag-based logic
- Expression Language (EL) accesses request and session data without any Java code in the page
- MVC separates concerns: Model handles data, View (JSP) handles display, Controller (Servlet) handles logic
- JSP skills transfer directly to Thymeleaf and Freemarker used in Spring Boot applications
What Is JSP and How Does It Differ from Servlets?
JSP (JavaServer Pages) is a view technology that lets you create dynamic HTML pages with embedded Java logic. A JSP file looks like an HTML file with special tags and expressions — the Servlet container (Tomcat) compiles each JSP into a Servlet automatically the first time it is requested. Subsequent requests use the compiled Servlet, so JSP performance after the first request is identical to writing a Servlet by hand. This is the crucial insight: JSP is just a more convenient way to write Servlets for generating HTML output. While Servlets require mixing HTML into Java string concatenation (ugly and hard to maintain), JSP lets you write HTML naturally and embed only the dynamic parts. The tradeoff: JSP files mix presentation and business logic when scriptlets are used carelessly, which is why JSTL and EL exist — to push logic back to the Controller Servlet and keep the JSP pure presentation. Companies from Infosys and TCS to smaller Pune-based IT firms maintain large JSP-based applications. Developers who understand JSP internals — not just syntax — are more valuable for maintenance and migration roles.

JSP Syntax: Directives, Scriptlets, Expressions and Declarations
JSP has four main syntax elements. Directives configure the JSP itself: the page directive sets page-level configuration, the include directive statically includes another file at compile time, and the taglib directive imports a tag library. Scriptlets embed Java statements into the page — avoid these in modern code, they are hard to read and test. Expressions output a value directly into the HTML — equivalent to out.print(). Declarations declare instance variables or methods on the generated Servlet class. Actions are XML-style tags for common operations like include and forward. JSP comments are stripped at compile time and never reach the browser, unlike HTML comments. The most important rule: zero scriptlets in modern JSP. If you find yourself writing Java logic in a JSP page, move it to a Servlet or service class and access the result through Expression Language.
| Feature | JSP + JSTL | Thymeleaf | Freemarker |
|---|---|---|---|
| Syntax Style | Tag-based XML | HTML5 attributes | Directive-based |
| IDE Support | Good | Excellent | Good |
| Spring Boot Default | No (needs config) | Yes | Supported |
| Java in Template | Possible (scriptlets) | Not allowed | Not allowed |
| Learning Curve | Low | Low | Low |
| Enterprise Use India | Very common (legacy) | Growing (new projects) | Common |
JSTL: Writing Clean JSP Without Java Scriptlets
JSTL (JSP Standard Tag Library) is the solution to JSP's scriptlet problem. Instead of embedding Java loops and conditionals inside angle-bracket HTML, JSTL provides XML-style tags that do the same thing in a format that HTML tools can parse and designers can understand. The four main JSTL libraries: Core (c:) handles output, conditionals, loops, and URL handling. Formatting (fmt:) handles number formatting, date formatting, and internationalization. SQL (sql:) executes database queries directly from JSP — convenient for learning but never use in production. Functions (fn:) provides string manipulation utilities. The tags you will use constantly: c:if for conditionals, c:choose/c:when/c:otherwise for if-else chains, c:forEach for iteration, c:out for safe output that escapes HTML special characters. The escaping behavior of c:out prevents XSS vulnerabilities — a security reason to prefer it over raw EL expressions for user-supplied content.

Expression Language: Accessing Data the Right Way
Expression Language (EL) is what makes JSTL practical by providing clean access to data stored in page, request, session, and application scopes. The syntax is simple: dollar-sign with curly braces around the expression. Accessing the name property of an object named user in any available scope: ${user.name}. Reading the email request parameter: ${param.email}. Accessing the cart object from session scope: ${sessionScope.cart}. EL resolves scope automatically in order: page, request, session, application — whichever scope contains the named attribute first is used. Arithmetic works directly in EL. Comparison and ternary operators are also supported. The practical workflow: the Controller Servlet processes request data, calls service methods, stores results using req.setAttribute("students", studentList), then forwards to the JSP. The JSP uses EL to access the list and c:forEach to render it. No Java code in the view, no view logic in the controller — clean separation that makes both halves independently maintainable.
Implementing MVC Pattern with JSP and Servlets
MVC (Model-View-Controller) is the architectural pattern that separates an application into three distinct roles, and JSP/Servlet applications naturally implement it. The Model is your data — Java objects, POJOs, entity classes that represent the business domain (Student, Order, Product). The View is the JSP file — responsible only for displaying data in HTML, with no business logic. The Controller is the Servlet — receives HTTP requests, calls service methods to fetch or process data, stores results in request or session scope, and forwards to the appropriate JSP view. The flow: browser sends a request to the StudentServlet (Controller). StudentServlet calls StudentService.getAllStudents() (Model). Results stored via req.setAttribute("students", list). Request forwarded to students.jsp (View). JSP reads the students list and renders the HTML table. Response sent to browser. This separation is why frameworks like Spring MVC, Struts, and Jakarta Faces were built — to formalize and automate the controller routing piece. Understanding the pattern without a framework first makes every framework make intuitive sense.
From JSP to Modern Template Engines: What Changes and What Stays
The transition from JSP to modern template engines is smoother than most developers expect because the underlying pattern — template receives data from controller, renders HTML — is identical. In Spring Boot with Thymeleaf, a @Controller method puts data in a Model object (model.addAttribute("students", list)) and returns a view name. Thymeleaf reads the data using th:each and th:text attributes — syntax different from JSTL but conceptually identical. Freemarker uses ${student.name} and list directives — again different syntax, same pattern. The critical skill that transfers fully: understanding scope (request vs session vs application), understanding data binding, and understanding that the template is presentation only. What changes: syntax and the build setup. What stays: MVC pattern, separation of concerns, data flow from controller to view. This is why employers value JSP knowledge even for Spring Boot positions — it signals that a developer understands the web tier architecture, not just how to use one specific template syntax.
Maharashtra's CMYKPY scheme provides Rs 6,000–10,000 monthly stipends to youth enrolled in approved skill training programs. ABC Trainings is an empanelled CMYKPY center for IT training. Our Advanced Java course covering JSP, Servlets, Hibernate, and Spring Boot qualifies. Enquire at our nearest center or call +91 7039169629.Get the IT Training Brochure + Fees + Batch Dates on WhatsApp
Free 1:1 counselling. Placement track record. CMYKPY/PMKVY eligibility check.
💬 Get Brochure on WhatsApp📞 Call 7039169629About the author: Amit Kulkarni. 8 yrs leading IT training at ABC Trainings, ex-Infosys.
Visit Our Centers
- Wagholi (Pune): 1st Floor, Laxmi Datta Arcade, Pune-Ahilyanagar Highway. Call 7039169629
- Hadapsar (Pune HQ): 1st Floor, Shree Tower, opp. Vaibhav Theater, Magarpatta. Call 7039169629
- Cidco (Chh. Sambhajinagar): Kalpana Plaza, opp. Eiffel Tower, N-1 Cidco. Call 7039169629
- Osmanpura (Chh. Sambhajinagar): S.S.C Board to Peer Bazar Road, near Jama Masjid. Call 7039169629
- Sangli: Shubham Emphoria, 1st Floor, Above US Polo Assn., Sangli-Miraj Rd, Vishrambag. Weekend batches available. Call 7039169629
FAQs
Is JSP still used in real Indian enterprise projects in 2026?
Yes — JSP is still actively used in thousands of Indian enterprise applications, particularly in banking, insurance, government, and large IT services accounts. Companies like Infosys, TCS, Wipro, and HCL have enormous JSP codebases they maintain, extend, and gradually modernize. Developers who understand JSP well are consistently needed for this work. New greenfield projects in product companies typically use Thymeleaf or a React/Angular frontend instead, but JSP proficiency remains valuable in the IT services market that employs the majority of Indian developers.
What is JSTL and why should I use it instead of Java scriptlets in JSP?
JSTL (JSP Standard Tag Library) provides XML-style tags that replace Java code embedded directly in JSP files. Java scriptlets (code in percent-sign blocks) are difficult to read, hard to test in isolation, and often result in business logic mixed into the presentation layer. JSTL's c:forEach, c:if, and c:out tags do the same operations in a format that is readable, toolable, and easier to maintain. The security benefit: c:out automatically escapes HTML special characters, preventing XSS vulnerabilities that raw output does not catch. Use JSTL for all logic in JSP pages and zero scriptlets.
How does JSP fit into the MVC architecture pattern?
In MVC with JSP and Servlets: the Model is Java objects containing your data. The Controller is a Servlet that receives HTTP requests, calls business logic methods, stores results in request scope using req.setAttribute(), and forwards to a JSP. The View is the JSP file that reads data from request scope using Expression Language and renders it as HTML. No logic in the view, no presentation in the controller. This clean separation makes applications maintainable — designers can edit JSP templates without touching Java code, and Java developers change business logic without touching view files.
Should I learn JSP or Thymeleaf for a Spring Boot project?
For a new Spring Boot project, use Thymeleaf — it is the officially recommended view technology, has excellent Spring Boot auto-configuration, works as valid HTML5 that browsers can preview without a server, and integrates cleanly with Spring Security and Spring MVC. Learn JSP if you are: joining an IT services team maintaining legacy enterprise applications, studying for senior Java interviews (JSP internals are still tested), or building on a Jakarta EE stack. The conceptual knowledge transfers directly — once you understand MVC with JSP, Thymeleaf takes a few hours to pick up.




