Chapter 2

Using JavaServer Pages


check Seeing how servlets work in the MVC model.

check Learning about the life cycle of a JSP page

check Trying out expressions and JSTL tags

check Doing more with the Request object

check Looking at a complete, albeit simple, JSP application

In Book 7, Chapter 1, you discover how to create servlets that write HTML data directly to a page by using the PrintWriter object accessed through response.out. Although this technique works, it is far from the ideal way to develop web applications. Any sensible web application design separates the business logic (the Java code) from the presentation (the HTML). Generating HTML directly from a Java servlet was fine for introducing how servlets work, but it isn't a viable way to write actual web applications.

That’s where JavaServer Pages (a technology usually called JSP for short) comes in. A JavaServer Page is an HTML file that has Java servlet code embedded in it in special tags. When you run a JSP, all the HTML is automatically ...

Get Java All-in-One For Dummies, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.