Expression tag is used to print the java language expression.
To execute java language expression in JSP file expression tag is used.
In expression tag, you don’t need to write out.print() to print .java
<% = java expression %>
In this example we are declaring the field and printing the value of the declared field using the jsp expression tag.
<% =5*5 %>
In this example, we have created two files index.html and home.jsp. The index.html file gets the first name and last name from the user and the home.jsp file prints the First name and last name with hello message.
<!DOCTYPE html>
<html>
<head>
<title>Hello World</title>
</head>
<body>
<form action="home.jsp">
<input type="text" placeholder="first name" name="fname"> <br><br>
<input type="text" placeholder="last name" name="lname"> <br> <br>
<input type="submit" value="submit"><br>
</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JSP Scriptlet tag</title>
</head>
<body>
<%
String fname=request.getParameter("fname");
String lname=request.getParameter("lname");
%>
<%= "Hello "+fname +lname%>
</body>
</html>