File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes mock exam at Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "mock exam at" Watch "mock exam at" New topic

mock exam at

Tong Chen
Ranch Hand

Joined: Apr 26, 2002
Posts: 1011
<%@ page language="java" %>
The Following are the contents of test.jsp
1 <html>
2 <head><title>A Comment Test</title></head>
3 <body>
4 <h2>A Test of Comments</h2>
5 <!-- This is Html Hidden Comment -->
6 <%-- This is JSP Hidden Comment --%>
7 </body>
8 </html>
On executing test.jsp guess the correct output
a) Line 5 is inserted in response but Line 6 is not inserted in response
b) Line 5 and Line 6 are inserted in response
c) Both Line 5 and Line 6 are not inserted in response
d) Line 5 is not inserted in response but Line 5 is inserted in response
The anwser it gave me is a).
But I think it is c) and I grabbed the above code and tested it. neither line 5 nor line 6 was displayed.

Any comment? Thanks,
On executing test.jsp guess the correct output


Joined: May 02, 2002
Posts: 3
The reason is
<%-- is a comment of Jsp --%> compiler ignores these statments, so line 5 is not inserted in response.
<!-- is a comment of HTML --> compiler will insert statement as out.println("<!-- ... -->") into response.

Regards<br />Adous<br />Sun Certified Programmer for Java 2 platform<br />Sun Certified Web Component Developer for J2EE
seenu maj

Joined: Mar 12, 2002
Posts: 9
Where in is the exam?

what a wonderful world!
Chintan Rajyaguru
Ranch Hand

Joined: Aug 19, 2001
Posts: 341
Let me add this to what adous_sg (name not according to the naming policy) said,
<!-- date is <%=new java.util.Date()%> -->
If you have the above line in your jsp, you will not see any out put on your browser because it is an HTML comment. However, your Servlet engine will process this (because IT IS INCLUDED in the response) and produce date and put the date in HTML comment. So if you see VIEW SOURCE, you should see
<!-- date is Sunday (actual date).... -->
If you have <%-- something --%>, it is considered as JSP comment, servlet engine will not even process it and hence will not include in the response.
Conclusion: Answer is (a) - Coming soon!
R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5382
Originally posted by seenu maj:
Where in is the exam?

Yes .. where is Mock on even I register myself .. but there was some free mail service.. nothing abt mock ?

"Thanks to Indian media who has over the period of time swiped out intellectual taste from mass Indian population." - Chetan Parekh
R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5382
got it ..
its here
Vedhas Pitkar
Ranch Hand

Joined: Jan 27, 2001
Posts: 445
Hi Tong.
The answer maybe this:
If u rt click & view source the test.jsp then u;ll see the html comment but not the jsp comment.
Am i right or am i left?
Sumit Amar
Ranch Hand

Joined: Jun 08, 2002
Posts: 180
How many questions does it have?

SCJP, SCWCD, OCA, OCP-DBA 9i, <a href="" target="_blank" rel="nofollow">BCIP</a>, MCP, MCAD, MCSD.NET, MCDBA, MCTS (SQL 05), MCITP (DBD, DBA)
I agree. Here's the link:
subject: mock exam at
It's not a secret anymore!