Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes jspInit() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "jspInit() method" Watch "jspInit() method" New topic

jspInit() method

Steven Colley
Ranch Hand

Joined: Feb 18, 2005
Posts: 290

can i overwrite the original "jspInit()" method just using scriptlet(<%%> , or is it mandatory to utilize declaration(<%! %> for that?

I mean, is it valid?

public void jspInit(){




SCJP | SCWCD | SCBCD | SCWSD 5 | SCEA (I) 1.4 | SCEA 5 | IBM SOA 669
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

All methods need to be declared <%! %>

A good workman is known by his tools.
Saurabh Chaubey
Ranch Hand

Joined: Oct 16, 2005
Posts: 101
Hi Felipe,
By <% insert code here %> you are specifying that you want this code to be inserted inside the _jspService() method. So, doing <% jspInit(){} %> you mean that you want to declare the Init method inside the _jspService() method. Method decleration inside another method does not seem to be correct. So it is invalid. However if you do <%! jspInit() %> you mean that you have overriden the jspInit() method in the container generated servlet class. Now this class has two seperate method declerations, one for jspInit() which you can override and the container generated implementation of the _jspService() method.

I hope this helps you.

Steven Colley
Ranch Hand

Joined: Feb 18, 2005
Posts: 290
So if i got this on exam <% jspInit() %> no way..cut it out , right?

Tks marc and Saurabh !
I agree. Here's the link:
subject: jspInit() method