Section A.1. Comments

   

A.1 Comments

JSP 1.2 allows two kinds of comments: JSP comments and HTML comments.

JSP comments are written as follows :

 <%-- This is a JSP comment. It is not visible in the source  returned to the client. --> 

HTML comments are written as follows:

 <!-- An HTML comment is visible in the source code returned to the client. --> 

Although you already know how to write HTML comments, they are included here for two specific reasons. First, it may be necessary to make the distinction that you can in fact write HTML comments from within JSP. Second, it is useful on occasion to utilize JSP from within an HTML comment, which is legal.

For instance, you can write the name of the current template and return it in the viewable source. This is done as follows:

 <!-- The current template is<%= request.getRequestURI() %>.  Today is <% Date today = new Date(); DateFormat formatter; formatter = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);%> <%= formatter.format(today) %> --> 

The above HTML comment would look something like this when the page source is viewed on the client:

 <!-- The current template is /javaforcf/comment.jsp.  Today is 7/30/02 --> 

   
Top


Java for ColdFusion Developers
Java for ColdFusion Developers
ISBN: 0130461806
EAN: 2147483647
Year: 2005
Pages: 206
Authors: Eben Hewitt

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net