While working with JSP
files and servlets , I came across <% … %>
and <%= … %>
.
What's the difference between both cases ?
Thanks
While working with JSP
files and servlets , I came across <% … %>
and <%= … %>
.
What's the difference between both cases ?
Thanks
is same as
There are three types of Scriptlets :
Scriptlet Declarations of the form <%! code %> that are inserted into the body of the servlet class, outside of any existing methods. For ex:
In case of
<% ... %>
you are adding a server side code. And in case of<%= ... %>
you are adding a server side code that automatically prints something. It could be seen as a shortcut for<% out.print( something ) %>
.<%= … %>
will echo out a variable, where as<% … %>
denotes a script or some code that is executed.Here are the links to the jsp documentation:
<%= … %>
) : http://java.sun.com/products/jsp/tags/11/syntaxref11.fm4.html<% … %>
) : http://java.sun.com/products/jsp/tags/11/syntaxref11.fm5.html