×
☰ See All Chapters

Expression tag in JSP

Expression is a replacement for out.println();.  Notice the semicolon carefully after out.println();. So we should not use semi colon at the end of expression. All the expressions inside the JSP will be placed inside the jspService() method. Expressions cannot be used inside a scriptlet. Syntax of JSP expression tag is:

<%= "Statement" %>

The code is a short cut form of the below code.

<%

        out.println("Statement");

%>

JSP Expression tag example

Project directory structure

jsp-expression-0
 

expressionsDemo.jsp

<html>

<head>

<title>Scripting elements – Expressions Demo</title>

</head>

<body>

        <%="Hello World !"%>

</body>

</html>

Output

jsp-expression-1
 

 


All Chapters
Author