Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Attributes for ServletConfig & ServletContext through web.xml

 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!