wood burning stoves 2.0*
The moose likes JSP and the fly likes EL equivalent of pageContext.getAttribute( aVariable ) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "EL equivalent of pageContext.getAttribute( aVariable )" Watch "EL equivalent of pageContext.getAttribute( aVariable )" New topic
Author

EL equivalent of pageContext.getAttribute( aVariable )

Agoston Bejo
Greenhorn

Joined: Nov 23, 2007
Posts: 8
Hi!

I have a variable the value of which is a key to look up a value the way pageContext.getAttribute() does (i.e. going through the page, request, session, application scopes in a row). So the main point is that the value of the lookup key can VARY, it's not constant. (Otherwise I could say ${LookupKey} and that would be it.)

I.e. something like this:
<c:set var="theKey" value="LookupKey"/>
<c:if test="${pageContext[theKey]}"> ...

the above syntax doesn't work, of course (otherwise my question would've been automatically answered ), it's just a pseudo-code for you to get the idea.

Thanks!
Agoston
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

I think I see what you're after... you want one level of indirection and you want all scopes to be automatically searched. I'm afraid you can't have both.

For a scoped variable whose name is within another variable, you'll need to know what scope the variables is stored within and use syntax like:


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

Joined: Jan 10, 2002
Posts: 60774
    
  65

P.S. I think that it's the PageContext.findAttribute() method you were referring to.
Agoston Bejo
Greenhorn

Joined: Nov 23, 2007
Posts: 8
Yes, I was after that, and am sorry to hear that it's not possible.
And yes, I meant PageContext.findAttribute().
Agoston Bejo
Greenhorn

Joined: Nov 23, 2007
Posts: 8
And what I actually wanted to say was: thank you!
 
wood burning stoves
 
subject: EL equivalent of pageContext.getAttribute( aVariable )
 
Similar Threads
JSP Loading Time
map reference syntax ?
Problem in mock exam
Compile time error in client code for simple example
Doubt on a jsp file