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



Home Jsp Simple-jsp-example Comments in Jsp

Related Tutorials


 
 

Share on Google+Share on Google+

Comments in Jsp

Advertisement
In a jsp we should always try to use jsp- style comments unless you want the comments to appear in the HTML.

Comments in Jsp

        

In a jsp we should always try to use jsp- style comments unless you want the comments to appear in the HTML. Jsp comments are converted by the jsp engine into java comments in the source code of the servlet that implements the Jsp page. The jsp comment don't appear in the output produced by the jsp page when it runs. Jsp comments do not increase the size of the file,  jsp page are useful to increase the readability of the jsp page.

In Jsp two types of comments are allowed in the Jsp page:

1) Hidden comment: This comment will not appear in the output.

<%-- Hidden comment --%>

2) Output comment: This type of comment will appear in the output.

<!-- Output comment>

If we have to pass the comment inside the directive then there we use a single line comment i.e. //

Code of the program is given below:

<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> </br>
			
&lt;&#37;&#45;&#45; <br>

&nbsp;&nbsp; &lt;&#37;<br>

  &nbsp;&nbsp;&nbsp;&nbsp;System.out.println
            ("Roseindia.net");<br>

&nbsp;&nbsp; &lt;&#37;<br>
		
         &lt;&#37;&#45;&#45;
			</td>
		</tr>
		<tr>
		<td></td>
		</tr>
		</table>
  </BODY>
</HTML>

Download this example.


 
Advertisement

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: February 6, 2008

Related Tutorials

Discuss: Comments in Jsp   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:4
khasha
May 23, 2012
www.dsdete

ds detective is best company
Anusha
July 27, 2012
jsp

can u post some more information regarding to jsp comments......
Sanjana
November 8, 2013
ques

how to make a comment box using html in a website and how to post those comments
Smithd247
May 25, 2014
John

I'm truly enjoying the design and layout of your blog. It's a very easy on the eyes which makes it much more pleasant for me to come here and visit more often. Did you hire out a developer to create your theme? Outstanding work! dbgfeafcdebaekkf
DMCA.com