wood burning stoves 2.0*
The moose likes JSP and the fly likes can request and session attribute share the same name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "can request and session attribute share the same name" Watch "can request and session attribute share the same name" New topic
Author

can request and session attribute share the same name

Kalyana Sundaram
Ranch Hand

Joined: Mar 18, 2005
Posts: 94
Can request and session attribute share the same name. In that case will there be any loss of attributes.
My question is, will I be able retrieve both the attributes in session and request that have same name...

Thanks in Advance


Only those who will risk going too far can possibly find out how far one can go !!!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60804
    
  65

"kalyan",

We're pleased to have you here with us on the Ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60804
    
  65

With regards to your question, the answer is yes.

Though be aware that in certain circumstances, the request-scoped variable will hide the session-scoped variable (e.g. in unqualified EL references to the scoped variable, or when using PageContext.findAttribute())
Kalyana Sundaram
Ranch Hand

Joined: Mar 18, 2005
Posts: 94
Assume that the attribute "name" is in bith session and request scope....
if i use someting like
<c ut value=${'name'}/>
So the request scope variable would hide the session scoped variable.
If i were to get the session scope variable , i will have to use
<c ut value=${'name'}scope="session"/>

Is this right ???
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60804
    
  65

Not quite. To retrieve the session-scoped variable you would use:



P.S. When posting code, be sure to click the 'disable smilies' checkbox near the bottom of the page. That way your <cut> tags will look less surprised.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can request and session attribute share the same name
 
Similar Threads
HFSJ question on session attribute
the lifespan of a request?
Thread safe about session and request scope
HTML tags and Filters
parameter vs attributes?