In this section , we will learn how to implements comment & hidden comment in JSP.
Comment generates a comment that is sent to the client. The comment use in JSP is very similar to HTML comment except that you can use expression in JSP comment . Both the comments can be viewed in the page source from your Web browser. The expression is dynamic and is evaluated when the page is loaded or reloaded in the Web browser. You can use any expression that is valid in the page scripting language.
<!-- comment [<%= expression %> ] -->
Ex.1 : <!-- This file displays records from table -->
Output: same as comment, displays in the page source.
<!-- This file displays records from table -->
Ex.2 : <!-- This page was loaded on <%= (new java.util.Date()).toLocaleString() %> -->
Output : Displays in the page source as :
<!-- This page was loaded on January 1, 2000 -->
HIDDEN COMMENT :
The hidden comment included in the JSP page but not sent to the client.A
hidden comment is not sent to the client, either in the displayed JSP page or
the page source. The JSP container does not process anything within the
<%-- comment --%>
<%@page language="java" %>
<head><title>A Comment Test</title></head>
<h2>A Test of Comments</h2>
<%-- This comment will not be visible in the page source --%>
Recommend the tutorial