How comment a JSP expression?

kmilo picture kmilo · Oct 21, 2008 · Viewed 243.6k times · Source

How can I comment a JSP expression like: <%= map.size() %>

Is there something like <%= // map.size() %>?

Answer

Jonny Buchanan picture Jonny Buchanan · Oct 21, 2008

Pure JSP comments look like this:

<%-- Comment --%>

So if you want to retain the "=".you could do something like:

<%--= map.size() --%>

The key thing is that <%= defines the beginning of an expression, in which you can't leave the body empty, but you could do something like this instead if the pure JSP comment doesn't appeal to you:

<% /*= map.size()*/ %>

Code Conventions for the JavaServer Pages Technology Version 1.x Language has details about the different commenting options available to you (but has a complete lack of link targets, so I can't link you directly to the relevant section - boo!)