This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Implementation of init parameters being set on ServletConfig Object  RSS feed

 
sage erosenin
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
#newbieAlert

ServletConfig is implemented by the GenericServlet Class and has config as an instance variable.

How are the init params set ? They are name value pairs but i donot see what data structure holds those name value pairs. I do know that getInitParam***() would get you those values.

Tx
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sage erosenin wrote:but i donot see what data structure holds those name value pairs


It is not specified. The implementation is free to store the names and values any way it pleases as long as it satisfies the contract of the interface.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They're passed in using the init(ServletConfig) method. Whatever object is passed in there implements the ServletConfig interface, and has a data structure to store those values (as opposed to the GenericServlet class which also implements ServletConfig, but just passes those method calls through to the ServletConfig object passed to it via the init method).

If you want to know which class it is, do a getServletConfig().getClass().getName() on it and print the result. It will depend on whichever servlet container you're using. If it's Tomcat, then it's probably some org.apache.tomcat.... class.
 
sage erosenin
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, precisely what i was looking for.

The class is org.apache.catalina.core.StandardWrapperFacade which in itself gets a StadardWrapper config object into its constructor.
Is it right for me to assume that some where in the apache classes there is a ? if yes, is it possible for me to see that impl ? and thus in the GenericServlet implementation of ServletConfig when you say :



It actually calles the getInitParameterNames() of StandardWrapper on the config object passed to the GenericServlet ?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's how it likely works. Those classes are part of the Tomcat source code, which you can download at http://tomcat.apache.org/download-70.cgi
 
sage erosenin
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i dont necesarily want to look at the source code. Wanted to make sure my understanding was correct.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The point is: you don't need to know. That's the whole point of interfaces.
 
sage erosenin
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I understand. Was just curious to know if it worked that way under the hood.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're curious, that's when you need to look at the source code of an implementation. Note that different implementations could be wildly different as long as they all adhere to the contract of the interface. If you don't want to look at source code, then you're likely not all that curious.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!