Programming Blog

This blog is about technical and programming questions and there solutions. I also cover programs that were asked in various interviews, it will help you to crack the coding round of various interviews

Wednesday 14 February 2018

Comments in Jsp

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.


Here is the Program --------------

<HEAD>
<TITLE> </TITLE>
</HEAD>
<BODY>
<font size="6" color ="black">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>

<b> Multiline comment inside scriptlet tags:</b></br>
/*</br>


*/</br>
<b>JSP Comment:</b> 

<br>

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

2 comments: