• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt in syntaxin jsp page

 
geeta vemula
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is from enthuware

Which of the follwing JSP fragments correctly define a method?

1.
<% public void m1() { ... } %>
2.
<%! public void m1() { ... } %>
3.
<%@ public void m1() { ... } %>
4.
<%! public void m1() { ... }; %>
5.
<% public void m1() { ... }; %>

answer is 2,4
I coudn't get it. why option 1 is wrong? well I thought the answer would be 1,2.
Kindly clear my doubt.

Thanks,
Geeta
 
Kay Li
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In java, 'public void m1() { ... };' and 'public void m1() { ... }' have the same effect.

You cannot do this: <% public void m1() { ... } %>.
<% ... %> will put the content inside into _jspService() method, not like <%! ... %> which declares class number.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic