java
java
• Used to insert the value of a Java expression directly into the output (usually
HTML).
• It is evaluated at runtime, and the result is converted to a string and inserted into
the output stream.
Expression tags to display the sum of two numbers and the current date:
<%@ page language="java"
contentType="text/html;
charset=UTF-8"
pageEncoding="UTF-8“%>
<html>
<head>
<title>JSP Expression Tag Example</title>
</head>
<body>
<h2>Using JSP Expression Tag</h2>
<p>Today's Date: <%= new java.util.Date() %></p>
<% OUTPUT:
int num1 = 10; USING JSP EXPRESSION TAG
int num2 = 20; TODAY’S DATE:MON JUN 09
14:32:10 IST 2025
%> VALUE OF NUM1:10
<p>Value of num1: <%= num1 %></p> VALUE OF NUM2:20
<p>Value of num2: <%= num2 %></p> SUM(NUM1+NUM2):30
<p>Sum (num1 + num2): <%= num1 + num2 %></p>
</body>
</html>
SCRIPLET TAGS
• A scriptlet tag opens with <% and contains commonly used Java control
statements and loops. A scriptlet tag closes with %>
• Syntax: <%
//JAVA CODE
%>