Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

passing ServletContext  RSS feed

 
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I get ServletContext object form ServletConfig?
Is ServletContext object passed somehow?
 
Author and ninkuma
Marshal
Posts: 66352
155
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you bother to even look at the javadoc?
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 66352
155
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you know already know how to get it, then I do not understand the question.
 
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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...
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ServletConfig is passed to init(...) method of a servlet. How is ServletContext passed to ServletConfig object?
 
Ankit Garg
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, thanks Ankit. It is clear.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!