This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes jsp question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "jsp question" Watch "jsp question" New topic

jsp question

Sirisha Gajulapalli

Joined: Jun 12, 2003
Posts: 11
Hello Everyone,
I just started doing the mock exams and i am having difficulty in understanding the answer given for the following question from "Eduardo Cobian's" mock exam.
Given the following jsp line select the correct statements:
<% public void jspInit() { 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.
According to the solution given, it says option 1 is correct. But i thought that jspInit method should always be placed under a declaration.
<% public void jspInit() { code...} %>
As this becomes a scriplet, i thought this would be included under the service method when a servlet is generated and hence will result in an error. so according to me none of the answers are correct.
Please correct me if i am wrong.
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
The mock exam is wrong. If you put something like this into your JSP
<% public void jspInit() {System.out.print("hello");} %>
you will get a syntax error from the compiler.

Ron Newman - SCJP 1.2 (100%, 7 August 2002)
chi Lin
Ranch Hand

Joined: Aug 24, 2001
Posts: 348
thanks for the clarification !!

not so smart guy still curious to learn new stuff every now and then
Sirisha Gajulapalli

Joined: Jun 12, 2003
Posts: 11
Thanks for the reply Ron.
I agree. Here's the link:
subject: jsp question
It's not a secret anymore!