output comment v/s hidden comment

Posted: June 22, 2009 in Java
Tags:

Output Comment

A comment that is sent to the client in the viewable page source.The JSP engine handles an output comment as uninterpreted HTML text, returning the comment in the HTML output sent to the client. You can see the comment by viewing the page source from your Web browser.JSP Syntax
<!– comment [ <%= expression %> ] –>

Example 1

<!– This is a commnet sent to client on
<%= (new java.util.Date()).toLocaleString() %>
–>

Displays in the page source:
<!– This is a commnet sent to client on January 24, 2004 –>

Hidden Comment

A comments that documents the JSP page but is not sent to the client. The JSP engine ignores a hidden comment, and does not process any code within hidden comment tags. A hidden comment is not sent to the client, either in the displayed JSP page or the HTML page source. The hidden comment is useful when you want to hide or “comment out” part of your JSP page.

You can use any characters in the body of the comment except the closing –%> combination. If you need to use –%> in your comment, you can escape it by typing –%\>.
JSP Syntax
<%– comment –%>

Examples
<%@ page language=”java” %>
<html>
<head><title>A Hidden Comment </title></head>
<body>
<%– This comment will not be visible to the colent in the page source –%>
</body>
</html>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s