• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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

 
Ranch Foreman
Posts: 1905
13
  • 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.
 
Creator of Enthuware JWS+ V6
Posts: 3346
303
Android Eclipse IDE Chrome
  • 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 Foreman
Posts: 1905
13
  • 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 Foreman
Posts: 1905
13
  • 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 Foreman
Posts: 1905
13
  • 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>

 
Bartender
Posts: 3648
16
Mac OS X Firefox Browser 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
 
Everybody's invited. Even this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic