• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EPractice Lab mock exam 3 question 51 (about printing a scriptlet declaration on a browser)

 
Himai Minh
Ranch Hand
Posts: 1360
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSP developer wants a comment to be visible in the final output to the browser. Which comment style needs to be used in a JSP page?
a, <!-- this is a comment -->
b. <% //this is a comment %>
c. <%-- this is a comment --%>
d. <%/**this is a comment **/%>

Answer: A
<!-- this is a comment--> is equivalent to HTML comment and it will be displayed in the browser.

When I tried option A, the "this is a comment" sentence is not printed on the browser.
None of the options are printed on the browser.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2531
112
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to check what the JSP specs say about it: JSP v2.2. chapter JSP.1.5 Comments
 
Himai Minh
Ranch Hand
Posts: 1360
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Frits, thanks for the document.
I try this in comments.jsp :

I run it, but I don't see the first line <!--this is a comment--> is output on the browser as the document mentions.
 
Himai Minh
Ranch Hand
Posts: 1360
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to this site :http://www.tutorialspoint.com/jsp/jsp_syntax.htm
<!-- this is a comment --/> is ignored by HTML.
That may explain why this is not visible on the browser.
 
Himai Minh
Ranch Hand
Posts: 1360
7
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know why. When I right click on the browser and select "view page source", I see this :


<html>
<body>
<!-- this is a comment -->



</body>
</html>

 
K. Tsang
Bartender
Posts: 3583
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTML comments can only be seen in the source file, not in the output. The question actually missed that you need to view source haha
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic