Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSP - what's the difference between “<% … %>” VS “<%= … %>”

While working with JSP files and servlets , I came across <% … %> and <%= … %> .

What's the difference between both cases ?

Thanks

like image 201
JAN Avatar asked Jul 14 '12 07:07

JAN


1 Answers

<%= … %> will echo out a variable, where as <% … %> denotes a script or some code that is executed.

Here are the links to the jsp documentation:

  • Expression (<%= … %>) : http://java.sun.com/products/jsp/tags/11/syntaxref11.fm4.html
  • Scriptlet (<% … %>) : http://java.sun.com/products/jsp/tags/11/syntaxref11.fm5.html
like image 96
Cristian Avatar answered Sep 30 '22 15:09

Cristian