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 JSP

 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please clear the following doubt

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.

Ans give n is 1

I think Answer given is wrong.But what ever is placed inside scriptlet is translated inside _jspService method,which should cause compiler error.Please let me know correct answer

Source : http://www.javaranch.com/carl/SCWCD.htm#Question%204)
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is that it would be valid only if it used a declarative scriptlet ( <%! %> ). Otherwise, it should give a compilation error.
 
Frederic Esnault
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I confirm, it would be right if it was a declaration <%! ... %>

Scriptlets like this one are put in the _jspService method body.
To declare a method (and so to redefine the init method), you must use declaration.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic