Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on nesting JSP elements

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The below one is also from David Bridgewater,

10. What is the result of attempting to access the following JSP page source? (Choose one.)
<% <%-- for (int i = 0; i < 10; i++) {
<%-- if(i==3) System.out.println("i is 3!");--%>
System.out.println("i squared is " + i * i);
} %> --%>
A. Doesn�t translate because the page source is incomplete.
B. Doesn�t compile because nesting comments in this way is illegal.
C. The JSP page would compile if the terminating curly brace were removed.
D. The JSP page would compile if one of the percent (%) signs were removed.
E. Runs as is and produces output (possibly not the output intended).

Why the answer should be D?
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd say E
 
kathir vel
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think ans D is right.Bcoz this code will compile succssfully if one of the <% pair or <%-- pairs are removed.Otherwise this code gives the following error.

Syntax error on tokens, delete these tokens
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can now reason out this. But the question framed was not that clear!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic