*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Attributes for ServletConfig & ServletContext through web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Attributes for ServletConfig & ServletContext through web.xml" Watch "Attributes for ServletConfig & ServletContext through web.xml" New topic
Author

Attributes for ServletConfig & ServletContext through web.xml

Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 347

I just got this question while reading about ServletConfig and ServletContext. Why it's not possible to set an attribute through web.xml? Maybe something like this:


IMO, the container could construct an object for us from a file!
Niiraj Patel
Ranch Hand

Joined: Sep 17, 2011
Posts: 47
Hi Faisal,
nice question.

Can you think in which condition you want ready made objects from container?

Its not container's job.

Yeah container can handle your Db connection and datasource.
Mostly we want some basic plain text data from container to initialize application.
You can make/use your own application to fullfill your requirment..
Like dependency injection in Spring framework.

If any other has difference thinking can put his/her point..

Regards,
Niraj




Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 347

Perhaps, an object about container itself? I know, we can get this information through methods. But, just for an example. My idea is - let's do in terms of objects. IMO, database connection and data source perfectly match such requirement.

I've never been into big/complex enterprise applications. So, I am sure I'm missing many scenarios where we could implement this idea.
 
Consider Paul's rocket mass heater.
 
subject: Attributes for ServletConfig & ServletContext through web.xml
 
Similar Threads
Servlet Context Vs Servlet Config
When HttpSessionAttributeListener and HttpSessionBindingListener methods are called?
getInitParameter()
what's the corresponding method for init-param?
ServletConfig & Context ?