JSP Comments

13/05/2008

There is only one type of JSP comment available by JSP specification.

JSP Comment Syntax:
<%-- comment --%>

This JSP comment tag tells the JSP container to ignore the comment part from compilation. That is, the commented part of source code is not considered for the content parsed for ‘response’.

Example:
<%-- This JSP comment part will not be included in the response object --%>

Is this a JSP Comment?

<!-- comment --> is not a JSP comment. This is HTML comment. The JSP container treats this HTML comment tag as equal as any other HTML tags. When view source is done, the content given between this tag is visible. This is not anyway related to the JSP container, it is the expected behaviour of this HTML tag.

Example

<!-- This HTML comment part is included in the response object and can be seen in view source -->

// or /* comment */ used inside the <% %> scriplet tag is also not a JSP comment. This is just a java comment and JSP container doesn’t reserve any special treatment for this comments usage.

Therefore, there is nothing called as hidden comment or output comment in JSP by specification.

Hi. your site is good.

I have a question. Which is better to use.

JSP Comment
HTML Comment
JAVA Comment

SenthilKumar on December 27th, 2009 2:23 am

Hi

Its better to use JSP comment

jhhhhh on June 25th, 2010 11:04 am

@Senthilkumar,
JSP Comments or Java Comments or HTML Comments? It depends on the part of code you want to comment, since JSP comments can be used to comment out, HTML or scriplets also.

Joe on January 21st, 2011 2:12 am

hai,this is useful for easily understanding the jsp

ilanthamilan on March 28th, 2011 12:36 pm

it will depends on ur requirement
Jsp comment is best to use

chinna on April 15th, 2011 2:20 am

can i know how many types of jsp comments

dev on April 3rd, 2012 12:51 pm

joe, thanks… you are excellent buddy…

tuhin on April 14th, 2012 12:13 pm

can you please tell me the jsp or html codes for posting comments in a website?

sukanya nath on April 21st, 2012 6:07 pm

fdss

sukanya nath on April 21st, 2012 6:11 pm


Email:

about
I am Joe, author of this blog. I run this with loads of passion. If you are into java, you may find lot of interesting things around ...more about me. Google+
java badge
Home