This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have two questions.. 1. what is page level scope? 2. Can we access two different level attributes using a single object? Suppose that I have Session level object, can I use this object to get or set "request level" attribute because "session level" has broader scope (some thing like that) when compared to request level. Ofcourse, obviously we can use this to manipulate session level attribute.
1. Anything in page scope will be availabe in the page only. Which means that once the jsp will be displayed, the variable will be gone. 2. I don't quite understand the question. But you can put anything anywhere, so there should be no problem
Page Scope is the smallest scope, and is a representation of the PageContext object for your JSP. Each JSP has it's own page scope, so objects in the page scope of one JSP are not accessible to other JSPs. This is sorta like making a private variable in Java.
Session scope is the next lowest scope, represented by an HttpSession object. All requests from the same user are in the same session (unless you or they make it otherwise). Each user has his own session. If you want data to be referred to through multiple pages, after each page is displayed and the user requests a new page, then store the information in the session. Note, in order for sessions ot work, the user must have cookies on, or you must re-write the URLs. Take a look for maintaining sessions for more help on that.
The widest scope is the application scope, represented by the ServletContext object. All users share the same values of the application scope, as there is only one made for the web application. If you have some static material that all users should be able to access, then put it in the application, but be carefull. Each user will see the changes other users make, and certain threading issues can occur if not handled properly. So application scope is usually best used for Read-Only data.
<a href="http://www.jobklub.com" target="_blank" rel="nofollow">http://www.jobklub.com</a><br /> 'Add Job To Life'
Joined: Jan 30, 2007
Thanks for your reply. suppose that i have an attribute in the application scope. Now, can I use PageContext object, which has page scope, to access the application attribute?