aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Implicit objects in jspInit() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Implicit objects in jspInit() method" Watch "Implicit objects in jspInit() method" New topic
Author

Implicit objects in jspInit() method

Jacob Thomas
Ranch Hand

Joined: May 06, 2003
Posts: 51
Are implict objects available in jspInit() method or are they available in _jspService() method? For example, can the following code rewritten using implicit objects?

Senthil Kumar
Ranch Hand

Joined: Mar 13, 2006
Posts: 264
jacob,
config and application objects are always availabe inside the jspInit().Bcoz they are given by the container which you can use it to initialize the jsp's servlet.


when you really want something, all the universe always conspires in your favour.<br /> <br />SCJP1.5-77%<br />SCWCD-89%
Jacob Thomas
Ranch Hand

Joined: May 06, 2003
Posts: 51
Thanks very much for your reply Senthil. I was confused because all the implicit objects seem to be explicitly initialized in the _jspService() method of the example given in the HFSJ book. If they are explicitlt initalized in the _jspService() method, how are they available in the jspInit() method?
Michael M. Adkins
Greenhorn

Joined: Aug 12, 2012
Posts: 1
Senthil Kumar wrote:jacob,
config and application objects are always availabe inside the jspInit(). Because, they are given by the container which you can use it to initialize the jsp's servlet.


Senthil,

I just tried to access the config object in the jspInit method and I had an error come up. Both a compile error and a run-time error.

So, you're completely wrong about the config and application objects being available in the jspInit method.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1696
    
  25

Hi All
Are implict objects available in jspInit() method or are they available in _jspService() method? For example, can the following code rewritten using implicit objects?


Good question, and you can't really get a clear answer from the specs, but you can deduct an answer from it.

JSP.11.2.1 API Contracts
void jspInit() Method is optionally defined in JSP page. Method is invoked when the JSP page is initialized. When method is called all the methods in servlet, including getServletConfig are available

No talk about implicit objects here, so we assume they are not available yet, going further into the specs:

Code Example JSP.11-2 The Java Class Generated From a JSP Page

Deduction from above: The implicit objects are only available in the _jspService() method.

Regards,
Frits
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Implicit objects in jspInit() method