Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Jsp Comments in Jsp

Related Tutorials


 
 

Share on Google+Share on Google+

Comments in Jsp

Advertisement
Here we have discussed the use of comments in JSP page and how they are displayed.

JSP comments are very similar to HTML. They are not displayed in the Output of the program when it is executed. They do not affect the size of the file. JSP page are used to understand the program in a much better way.

Two types of comments are allowed in a JSP page:

Hidden comment

Such comments written under <%-- Hidden comment --%> and does not appear in the output.

Output comment:

Such comments written under <!-- Output comment> and appears in the output.

// is used to pass the comment inside the directive.

Example:

<HEAD>
<TITLE> </TITLE>
</HEAD>
<BODY>
<font size="6" color ="#000080">JSP Comments</font><br> 

<% 
// System.out.println
("This is Single line comment inside scriptlet tags");
/*
System.out.println
("This is multiline comment inside scriptlet tags");
System.out.println
("This is multiline comment inside scriptlet tags");
System.out.println
("This is multiline comment inside scriptlet tags");

*/
%> 
<%-- 
<% 
if (Math.random() > .5) {
out.println("<b>You win!</b>");
} else {
out.println("Sorry, you lose. Try again.");
} 
%>
<%=userName %>

--%>
<!--
this is HTML tag
-->
<table>
<tr>
<td>
<b>Single line comment inside scriptlet tags:</b> </br>

// System.out.println("Roseindia.net");</br>
<b> Multiline comment inside scriptlet tags:</b></br>
/*</br>
System.out.println("Roseindia.net");</br>
System.out.println("Roseindia.net");</br>
System.out.println("Roseindia.net");</br>

*/</br>
<b>JSP Comment:</b> System.out.println
("Roseindia.net");<br>

<br>

</td>
</tr>
<tr>
<td></td>
</tr>
</table>
</BODY>
</HTML>

Resource:

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


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: October 9, 2013

Related Tutorials

Discuss: Comments in Jsp  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com