wood burning stoves*
The moose likes Servlets and the fly likes What are context attributes? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "What are context attributes?" Watch "What are context attributes?" New topic
Author

What are context attributes?

Sagar S Shah
Greenhorn

Joined: Jul 10, 2012
Posts: 6
I understand the context init parameters,servlet init parameters etc. but i dont seem to understand what context attributes exactly are and what are they used for???Can someone please explain it to me in simple words??

Thanks in advance.
Gaurangkumar Khalasi
Ranch Hand

Joined: Jun 02, 2012
Posts: 187
Sagar S Shah wrote:Can someone please explain it to me in simple words??

Context init parameters -- attached with web application...
Servlet init parameters -- attached with a specific servlet...
Sagar S Shah
Greenhorn

Joined: Jul 10, 2012
Posts: 6
Gaurangkumar Khalasi wrote:
Sagar S Shah wrote:Can someone please explain it to me in simple words??

Context init parameters -- attached with web application...
Servlet init parameters -- attached with a specific servlet...


yeah i get that...i want to know what are context attibutes.
Gaurangkumar Khalasi
Ranch Hand

Joined: Jun 02, 2012
Posts: 187
Sagar S Shah wrote:...i want to know what are context attibutes.

Attributes which will be shared by servlets of a particular Web application...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18666
    
    8

Sagar S Shah wrote:yeah i get that...i want to know what are context attibutes.


They are attributes of the web application. Data items which are specific to the web application as a whole.
Sagar S Shah
Greenhorn

Joined: Jul 10, 2012
Posts: 6
Are you guys saying that it is the data that is common to the entire web app???In that case how is it different from context init parameters??Also i think now i dont really understand what an attribute is.So what is an attibute exactly??

Thanks for all the help.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

If by "attribute" you mean scoped variables that are set and fetched from the various contexts using setAttribute() and getAttribute(), then they are very different from context parameters.

Context parameters are set in the deployment descriptor and are static.

Scoped variables places in application context are set by code and can be changed at any time.

A better and unambiguous term is scoped variables.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
jQuery in Action, 2nd edition
 
subject: What are context attributes?