Meaningless Drivel is fun!
The moose likes JSP and the fly likes EL jsp scope issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "EL jsp scope issue" Watch "EL jsp scope issue" New topic

EL jsp scope issue

Mauricio Lopes Bonetti

Joined: May 07, 2012
Posts: 2

That code should print "Sara". Am I wrong? It prints nothing.
"list" is in pageScope. EL should not look for it?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63540

Mauricio Lopes Bonetti wrote:That code should print "Sara". Am I wrong?

You are wrong.

"list" is in pageScope.

It is not. Where did you place it into page scope?

[Asking smart questions] [About Bear] [Books by Bear]
Mauricio Lopes Bonetti

Joined: May 07, 2012
Posts: 2
That's the generated Servlet:

Can't I get local objects using EL without specifying a scope?
Stefan Evans

Joined: Jul 06, 2005
Posts: 1518
Declaring it as a local java variable on the page does not add it as an attribute in any scope.
If you want to access it in EL, you need to put it there explicitly.

And now of course to complete the example, you pull the scriptlet code out into a servlet where it belongs, and forward to the JSP.
I agree. Here's the link:
subject: EL jsp scope issue
jQuery in Action, 3rd edition