• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

attributes as objects in the context

 
Mathew Lee
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I read as servlet container place attributes as objects in the context to use by servlets.

Also i read as servlets provde reference to file in javax.servlet.context.tempdir.

I would like to know more about what author meant. When attributes as objects user, where, benefits of using it. How to invoke it. Why it needs to be used along with context. Any ideas, suggestions, sample code, resources, links highly appreciated. Thanks in advance
 
Javin Paul
Ranch Hand
Posts: 295
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since there is only one ServletContext exist for one web application it could be used as global respository to store global variable which could be used by different request or different session ,you just need to consider thread safety issue though because every request gets processed on there own thread b ut if you are just reading something from ServletContext you can safely do it.
 
dileep keely
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also i read as servlets provde reference to file in javax.servlet.context.tempdir.


There are some attributes that are supplied by webcontainer to the context.
All containers are responsible for creating a temporary directory. JSP .java and .class files and many things that get saved
in the tempdir(temporarily).

You can try : <%=application.getAttribute("javax.servlet.context.tempdir") %>
There are some attributes that are supplied to the context.The enumeration should not be empty
Edit1:to add last two lines
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic