| Author |
passing ServletContext
|
Lucas Smith
Ranch Hand
Joined: Apr 20, 2009
Posts: 804
|
|
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: 56153
|
|
|
Did you bother to even look at the javadoc?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Lucas Smith
Ranch Hand
Joined: Apr 20, 2009
Posts: 804
|
|
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: 56153
|
|
|
If you know already know how to get it, then I do not understand the question.
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
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
|
|
|
ServletConfig is passed to init(...) method of a servlet. How is ServletContext passed to ServletConfig object?
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
|
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
|
|
|
OK, thanks Ankit. It is clear.
|
 |
 |
|
|
subject: passing ServletContext
|
|
|