wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes passing ServletContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "passing ServletContext" Watch "passing ServletContext" New topic
Author

passing ServletContext

Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

How can I get ServletContext object form ServletConfig?
Is ServletContext object passed somehow?


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

Did you bother to even look at the javadoc?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

Yes, I did read it. I try to ask smart guestions
I know that there is a method getServletContext() in ServletConfig but how does that reference appear in ServletConfig?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

If you know already know how to get it, then I do not understand the question.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Lukas Smith wrote:I know that there is a method getServletContext() in ServletConfig but how does that reference appear in ServletConfig?

The question is not very much clear, but the container puts the ServletContext in the ServletConfig object...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

ServletConfig is passed to init(...) method of a servlet. How is ServletContext passed to ServletConfig object?
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

The container can call the ServletConfig.setServletContext to add the ServletContext object to ServletConfig. The container may use any other technique like reflection but whatever it is, the container has the responsibility of doing this work...
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

OK, thanks Ankit. It is clear.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: passing ServletContext
 
Similar Threads
ServletContext Object?
ServletContext object
ServletContext Doubt / Poll
Context Path Issue in Struts
What is the name of the object that is created/maintained by the Servlet Container and contains all