• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt on a jsp snippet

 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Given the following jsp snippet:
1. <!--x-->
2. <%=A.b() %>
3. <!--<%=A.b() %>-->
4. <%--y--%>

Assume that a call to A.b() is valid and returns the text test. What is the output of the following jsp?

A. <!--x-->test<!--<%=A.b()%>-->
B. <!--x-->test<!--test-->
C. test
D. <!--x-->test<!--<%=A.b()%>-->
<%--y--%>
E. test<%--y--%>

Can you tell me what is the correct answer.


Padma priya N.G.
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,
I understood the right way to proceed to get the answer. The answer is option B.
With regards,
Padma priya N.G.
 
khushhal yadav
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Priya

I didn't get it, how output will be B???
It would be C.

Though <!-- --> is not a comment for your jsp and will be sent as a part of response.
But they would be comment to browser. Right. So Browser won't display them. And you won't see them in output.
It's mainly used to include javascipt snippets in your JSPs. But do we ever see them on browser display. NO...

So output will be C not B.

Yes, in case of XML documents, they are visible on screen..

Regards,
Khushhal
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic