This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Servlets and the fly likes scope Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "scope" Watch "scope" New topic


bala.T murugan

Joined: Sep 09, 2005
Posts: 9
where are saying different scopes req,session, page where will their corresponding values ae stored ,how come it(server) can differentiate scope
Sravan Kumar
Ranch Hand

Joined: Sep 11, 2005
Posts: 121
It (container) stores the scope attributes in the corresponding objects. Request scope in ServletRequest, Session scope in HttpSession, page scope in JspContext and application scope in ServletContext.

When you try to get the attributes, you call getAttribute() method on the corresponding object and it returns the attribute in that scope.

keep smilin :: sravan<br /><a href="" target="_blank" rel="nofollow">I scribble here</a>
Eddy Lee Sin Ti
Ranch Hand

Joined: Oct 06, 2005
Posts: 135
You can access all the scope attributes in Jsp page, using the implicit variable pageContext of type javax.servlet.jsp.PageContext methods: getAttribute(String name, int scope) and setAttribute(String name, Object value, int scope) to access those attribute directly.

SCJP, SCWCD, SCJWS, IBM 700,IBM 701, IBM 704, IBM 705, CA Clarity Technical<br /> <br /><a href="" target="_blank" rel="nofollow"></a>
subject: scope