• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mock test doubt in jsp

 
Brijesh shah
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers;

In following example i tried this code and while deploying this code in jsp i found there was nothing on that page....

That means answer shoud be 2...But answer for following question is given as 4

I found the same issue in different mock test so if i et this type of question in exam then what to answer...

What will be the result of this jsp line if the user takes a look at the page source code?
<!-- Today is <%= new java.util.Date() %>.Hava a nice day -->

1) It won't compile
2) The user won't see the comment
3) The user will see the same jsp line as above
4) The user will see the comment with the current date because the expression is evaluated at runtime.

Regards;
Brijesh
 
Atul Samnerkar
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Brijesh,

The correct answer is 4.

This question is more on the JSP comments vs HTML comments.

As you said, the output is blank. However, if you see the source code of the page, then you will realize that its not blank. The expression is executed and date is displayed. Because of the HTML comments it is not visible in the browser. So user can see the comment (via source code ) hence answer 4 is correct.


If the code would have been in JSP comments then answer 2 would have been correct. <%-- JSP comment text --%>


Cheers,
Atul Samnerkar
 
Abilash Ravindran
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brijesh

As per the question - "would the user see the time if he sees the source " & i think the answer is yes. Trigger this jsp from ie & right-click -> view source, you would find the current datetime there. So i agree the answer to the question is option d.

Regards,
Abilash
 
Brijesh shah
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks i got it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic