Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In JSP Why Expression tag can not take the semicolon at end of statement

Tags:

jsp

Expression element in the JSP <%= … %> Only one java expression Ex:

 Index.jsp
 ----------
 Welcome to JSP scripting elements

  <%! int num1=10;
      int num2=20;
      int add;
   %> 

<% add=num1+num2 %>

   Addition is<%= add %> <@!-- Expression tag -->
like image 658
Mohsin Shaikh Avatar asked Dec 05 '25 03:12

Mohsin Shaikh


1 Answers

Because they're expressions, and not statements.

<%= add %>

is translated to

out.print(add);

So you really don't want a semicolon after the expression. It would lead to

out.print(add;);

which would not be valid Java.

like image 150
JB Nizet Avatar answered Dec 07 '25 00:12

JB Nizet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!