Comments

You can use JSP comments in JSP pages to describe what a scripting element or action is doing:

<%-- This is a comment --%>

All text between the start and stop tag is ignored by the JSP container and isn’t included in the response. The comment text can be anything except the character sequence representing the closing tag: --%>.

Besides describing what’s going on in the JSP page, comments can also be used to “comment out” portions of the JSP page, for instance during testing:

<jsp:useBean id="user" class="com.mycompany.UserBean" />
<%--
               <jsp:setProperty name="user" property="*" />
               <jsp:setProperty name="user" property="modDate" 
                 value="<%= new java.util.Date(  ) %>" />
               <% boolean isValid = user.isValid(  ); %>
               --%>

The action and scripting elements within the comment aren’t executed.

Get JavaServer Pages, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.