Expression Tag in JSP

JSP Expression Tag

Expression Tag is used to print out java language expression that is put between the tags. An expression tag can hold any java language expression that can be used as an argument to the out.print() method. Syntax of Expression Tag
<%= Java Expression %>
 
When the Container sees this

<%= (2*5) %>
 
It turns it into this:

out.print((2*5));
 
Note: Never end an expression with semicolon inside Expression Tag. Like this:

<%= (2*5); %>

Example of Expression Tag

<html>
    <head>
        <title>My First JSP Page</title>
    </head>
    <%
       int count = 0;
    %>
   <body>
        Page Count is <%= ++count %>   
   </body>
</html>

Comments