Scriptlet

Scriptlet let developers write java code within jsp file. Though this is not a recommended practice from the code maintenance perspective its widely used in the initial version of jsp applications.

JSP Scriptlet Syntax

<% java code fragment %>

Simple Example (github)

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ourownjava.com</title>
</head>
<body>
<!-- scriptlet example -->
<%out.println("Today is "+new java.util.Date()); %>
</body>
</html>

JSP Scriptlet sample program

https://github.com/sanjuthomas/jsp-play-ground

Run JSP Scriptlet example program