Meaningless Drivel is fun!*
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
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!
 
wood burning stoves
 
subject: How does the container set the context/config objects?
 
Similar Threads
How to Pick up server name as Browser page Title
JWebPlus SCWCD Mock Exam Question
init parameter.
Servlet context
What is the name of the object that is created/maintained by the Servlet Container and contains all