Search code examples
htmljspcommentsexpression

Are JSP expressions evaluated inside HTML comments of a JSP page?


Are JSP expressions evaluated inside HTML comments of a JSP page?

i.e What would server output in this case?

<!--
Jeremy <%="Flowers"%>
--> 

Will the expression be resolved or will it remain as an expression in the HTML comment

a)

<!--

Jeremy <%="Flowers"%>

-->

or b)

<!--

Jeremy Flowers

-->

Solution

  • Yes, the expressions will be resolved. The JSP page doesn't even know it is writing in HTML format, so it doesn't interpret anything HTML-specific.

    You can also write plain text using JSP, or JSON, or whatever you like.