This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Servlets and the fly likes How does the container set the context/config objects? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How does the container set the context/config objects?" Watch "How does the container set the context/config objects?" New topic
Author

How does the container set the context/config objects?

Ralf Allar
Greenhorn

Joined: Feb 26, 2002
Posts: 9
Hi,

I'm wondering how the container sets the ServletContext when there's no setter method inside the ServletContext class.

: )
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The ServletContext object that's passed to the application (the one that you can access) is usually just a facade to a another object that only the container can access.

For instance, if you drop the following line into a JSP and run it under Tomcat, you will see that the context object made available to you is an instance of org.apache.catalina.core.ApplicationContextFacade


This is the same with all the other object that the container exposes to the applications (request, response, session, etc...).

The real classes behind the facade have, in addition to the methods defined in the servlet spec, any methods and properties needed by the container for setup and housekeeping.
[ February 09, 2008: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ralf Allar
Greenhorn

Joined: Feb 26, 2002
Posts: 9
Ah, a facade... that makes sense.

Thank you!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How does the container set the context/config objects?