Comments
makes the program more readable. Suppose you wrote a thousand lines
of program, with out proper documentation, after some time, for the
owner of the application also, it is very difficult to figure out
what was written.
JSP
supports two types of comments.
a.
Hidden Coments
b.
HTML style comments
Hidden
comments are available to jsp page itself. They are not visible out
side.
Syntax
<%--
This is a hidden JSP comment --%>
HTML
style comments are passed to the response output stream and
are included in the generated HTML.
Syntax
<!--
This is included in the generated HTML-->
<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="java.util.*"%> <%-- This is a hidden JSP comment --%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Generate Random Number</title> </head> <body> <!-- This is included in the generated HTML--> <h1>Random Number: <% Random rand = new Random(); out.print(rand.nextInt()); %> </h1> </body> </html>
Run
the above jsp and right click on the browser and see the view source
of this page. Observe the below image, Hidden comments are not
available in the source of this jsp page.
No comments:
Post a Comment