7.5. Code Generation in JSP

JSP represents an entirely different use of code generation. JSP provides a web-content-oriented language that can include escapes to blocks of Java code. The idea is that web developers experienced with HTML and XML can design pages that have a substantial amount of static content, and then they can occasionally use escape sequences to introduce blocks of Java code. These blocks of Java code execute when the page is accessed and can add dynamic content to the page.

A JSP engine converts JSP syntax into a normal Java source file containing the code for a Java servlet, which it then compiles and executes. Listing 7-4 shows a simple Hello.jsp servlet that displays a greeting. Normal text in the page is sent directly ...

Get Component Development for the Java™ Platform 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.