Reputation: 851
I'm preparing for an interview so while reading some questions I found that the "JSP comment is called hide comment whereas html comment is called output comment". And the answer says that if we try to view source in JSP, the comments will not be shown whereas in HTML, it will be shown.
But I'm able to see the comment in the view source section. Can anybody clear this doubt?
Thanks in advance.
Upvotes: 7
Views: 13073
Reputation: 91
Well, technically if you use a typical JSP comments , like
<%-- This is a comment --%>
, and do a veiw source , you wont see it on the client side , if you however do an HTML style comment
<!-- This is a comment -->
, you can see view source and see that on the client side . needless to say , you can comment like the normal java style too , inside the jsp tags . hope it helps .
Upvotes: 4
Reputation: 255
Html comments don't prevent jsp from evaluating values
<!-- <%! int x = 0; %> -->
This line will declare x variable.
Upvotes: 2
Reputation:
There are two types of comments are allowed in the JSP. These are hidden and output comments. A hidden comments does not appear in the generated output in the html, while output comments appear in the generated output.
Example of hidden comment:
<%-- This is hidden comment --%>
Example of output comment:
<!-- This is output comment -->
Upvotes: 19