Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When is PageContext needed?

 
Ken Duncan
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many things that a JSP might use, like request and respoonse are already available without a PageContext call. Local variables would, I assume, also be available. For example, instead of

I could have


So you can use EL or an expression to get at local variables. This means that the times that PageContext is actually needed is fairly limited. Or am I missing something? Thanks.

Ken
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ken Duncan:
So you can use EL... to get at local variables.

Have you tried this? You might be quite surprised!
 
Ken Duncan
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Marc Peabody:

Have you tried this? You might be quite surprised!


No, I haven't tried it. I guessed it would be true but since you've put it that way, I guess it is the case rather that EL has a big gap in its capabilities. Thanks.

ken
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ken Duncan:
... I guess it is the case rather that EL has a big gap in its capabilities.

I used to feel this way when I first started using EL. Since then I've found that if I don't write a bunch of scriptlet to create local variables (which I shouldn't be doing anyway), then this "gap in capabilities" isn't at all an issue.

In most cases [ie anything that's MVC] your bean setup code will not even be in a JSP, so you have to place your beans in some scope (most go in request scope) pretty much no matter what. In a real world context, EL is pretty stinkin' slick.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65338
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ken Duncan:
I guess it is the case rather that EL has a big gap in its capabilities.
To add to Marc's response...

No, there is no gap. The JSTL and the EL were purposefully designed to remove the need for scriptlets on the pages. The inability to reference scripting variables is quite deliberate as, when using the JSTL and EL, there shouldn't even be any scripting variables.
[ January 28, 2008: Message edited by: Bear Bibeault ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic