• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Eduardo Cobian's mock question 4

 
Timber Lee
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given the following jsp line select the correct statements:
<% public void jspInit() { ...java code...} %>
1) It is a valid line that can be used to initialize the servlet that implements the jsp file.
2) It won't compile as no identifer can start with jsp not _jsp.
3) It will serve as the servlet initialization if the function's name is _jspInit.
4) There is no way to initialize a jsp's implementation class servlet.
correct answer is 1) , why?
i think the statement shuld be <% public void jspInit() { ...java code...} %> if the right answer is 1). what is your answer?
 
See El
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had the same problem when doing this mock exams. I think, with intention of the author, the answer 1 is correct but the code should be
<%! public void jspInit() { ... } %>
(there was missing exclamation "!")
otherwise it would even compile because you can't declare method directly in the scriptlet section, as these go inside _jspService(..) method.
[ November 17, 2002: Message edited by: See El ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic