17.06.04

How-To: Comments in JSPs

There are two kind of comments possible in a JSP. HTML comments (or visible comments) and JSP comments (hidden comments).
<!-- my comment visible for the client -->
<%-- my comment not send to the client --%>

In one of my projects the JSPs were documented very well with big blocks of comments. Navigating to the point of interest within the JSP code was very fast. That was very good and helped a lot. Unfortunately all comments where in HTML style, so first of all everybody could read them (which was not a problem in our case) but they also caused latency in the download and increased the web traffic (which was not good in our case).
Changing the comments to not generated output comments reduced a webpage for about 20%.
So in general I recommend to use only hidden JSP comments. The only reason I see in HTML style comments is to use it for debug reasons like:
<!-- Debug: myVariable = <%= myVariable %> -->

Posted by Karsten at 17.06.04 22:16 | TrackBack
Comments
Post a comment









Remember personal info?