Home Tutorial Java Jsp COMMENT & HIDDEN COMMENT IN JSP

 
 

Share on Google+Share on Google+
COMMENT & HIDDEN COMMENT IN JSP
Posted on: June 16, 2010 at 12:00 AM
Advertisement
In this section , we will learn how to implements comment & hidden comment in JSP.

COMMENT & HIDDEN COMMENT IN JSP

In this section , we will learn how to implements comment & hidden comment in JSP.

COMMENT :

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.

Syntax :

 <!-- comment [ <%= expression %> ] -->

Examples :

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 <%-- and --%> characters.

Syntax :

    <%--    comment      --%>  

Example :

<%@ page language="java" %>

<html>

<head><title>A Comment Test</title></head>

<body>

<h2>A Test of Comments</h2>

<%-- This comment will not be visible in the page source --%>

</body>

</html>

Output:

Advertisement

Related Tags for COMMENT & HIDDEN COMMENT IN JSP :


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 16, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com