JSP expression tag

This tag is used to write a String or String returning expression to the Output Stream. In other words, this tag provides a shorthand mechanism of writing strings or String returning expressions to output stream.

Following is the syntax of JSP Expression:

				 <%=  statement %>
jsp expression

NOTE: Expression should not contain a semicolon between codes, as with Declaration tag.


Example of JSP expression tag that prints the user name

In this example, we are printing the username using the expression tag. The index.html file gets the username and sends the request to the welcome.jsp file, which displays the username.

index.jsp

 <html>
<body>
<%= "welcome to jsp" %>
</body>
</html>

welcome.jsp

<html>
<body>
<%= "Welcome "+request.getParameter("uname") %>
</body>
</html>