A scriptlet is a section of Java code embedded in a JSP page.
JSP consists of JSP tags, HTML, and scriptlets. The JSP compiler converts all of this into a Java Servlet. Scriptlet code is included as-is in the final servlet.
Scriplets are considered messy in a JSP page, as their functionality is often better moved to a JSP Tag File or JSP Custom Tag Library. However, they do have their place, such as in the simple example below.
Example:
<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
|
Someone has attached a JSP file called newreport.jsp (see the Attachments section below). This contains an example of scriplets used in a JSP page, mixed with HTML, normal JSP, and JavaScript.
--NealeRudd, 12-Dec-2006
| newreport.jsp | ![]() |
6514 bytes |