| Author |
jsp question
|
Sirisha Gajulapalli
Greenhorn
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() { ...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. 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() { ...java 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
|
|
Ron, thanks for the clarification !!
|
not so smart guy still curious to learn new stuff every now and then
|
 |
Sirisha Gajulapalli
Greenhorn
Joined: Jun 12, 2003
Posts: 11
|
|
Thanks for the reply Ron. Siri
|
 |
 |
|
|
subject: jsp question
|
|
|