6.1. JSP Scripting Elements

Perhaps the easiest way to start with JSPs is doing something known as “scriptlets.” This is a good way to learn JSP, but a bad way to use JSP. With scriptlets, you embed the Java code directly in your JSP, and the code will be compiled and executed at the time the page is accessed. One obvious problem here is that the initial page load will be slow; just how slow depends upon the complexity of the servlet that needs to be generated and the power of the server.

An even bigger problem is the unwieldy development process. If you write Java code that has errors (not that you ever would), and compile the code with the javac compiler, many errors will be caught by the compiler before you even attempt to run the code. With ...

Get J2EE™ and JAX™: Developing Web Applications and Web Services 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.