JSP - what's the difference between "<% ...%>" VS "<% = ...%>"
<%= … %> will call a variable, where <% … %> denotes a script or some code that is executing.
Here are links to 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
<%= new java.util.Date() %> coincides with
<% out.println(new java.util.Date()) %> There are three types of scripts:
- Form script expressions <% = expression%> that are evaluated and inserted into the output file
- Script of the form <% code%> that is inserted into the servlet service method
Script form declarations <%! code%> , which are inserted into the body of the servlet class outside of any existing methods. For example:
<%! public int sum(int a, int b) { return a + b; } %>