14.2. Scripting Elements

There are three types of scripting elements: scriptlets, declarations, and expressions.

14.2.1. Scriptlets

Scriptlets allow little Java code blocks to be written directly in your JSP. You can perhaps remember the definition of scriptlets because they are small Java code scripts (the way applets are small applications and servlets are small servers). A scriptlet takes another syntax, one that looks more like ASP:

<% SomeClass s = new SomeClass(param); %> 

There are certain things to notice about scriptlets. The code you write inside a scriptlet is pure Java code. You can instantiate objects, write methods, and you end your statements in a semicolon. Scriptlets cannot span multiple pages; that is, they must start and end ...

Get Java™ for ColdFusion® Developers 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.