• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Using pageContext in EL

Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The source code for this question is taken from the HFSJ book by KBB 2nd Edition, CH 8 page 380. Only the jsp is mine based on the source code.





So all the above work. But I want to access the "person" attribute using pageContext implicit object.
If I use the following I get an error.

From the PageContext API I found that the implicit object "request" is a ServletRequest. Then I tried the following in a scriptlet and it works.

So I am wondering if I can conclude that the did not work because the request is a ServletRequest and not a HttpServletRequest?
So the follow up question is do any of you know how I can access person's name using pageContext?

Sorry if the question seems lengthy but I thought it would be easy to follow if the code is pasted as well.


Posts: 14691
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You need to use the requestScope implicit object instead. It's a Map. ${pageContext.request} returns a ServletRequest instance, that's why ${pageContext.request.person} won't work. (There's is no getPerson() method in the ServletRequest class)
Don't mess with me you fool! I'm cooking with gas! Here, read this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic