Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

valid within a JSP page

 
naresh govindaswmay
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I have attached the question here please check it and let me know

Marks: 1 Which of the following are valid within a JSP page?

1)
<%! out.print("hello") %>
2)
<% out.print("hello") %>
3)
<%= out.print("hello") %>
4)
<%= out.print("hello"); %>
5)
<% out.print("hello"); %>
6)
<%@ out.print("hello"); %>

Choose one answer. a. 1
b. 2
c. 3
d. 4
e. 5



My answer is 2,but they said 5 is the answer .Please clear my doubt
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
3 is a expression which will be converted into

out.print(out.print("hello"));

which will not compile.

5 is a valid scriptlet code which ends with a semicolon.
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you think that 2 is correct and 5 is not?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic