Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

EL expression ${pageContext.request}  RSS feed

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The EL expression returns a , not a .

This is a problem for me, because I want to prepend each 'src' attribute of my image tags with the application context path, i.e.

<img src="${pageContext.request.contextPath}/images/myimage.gif" />

There is no getContextPath() in ! Is there a way around this without some ugly hack like placing the context path as a context init param, so it's accessible through EL like: :roll:
 
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<img src="${pageContext.request.contextPath}/images/myimage.gif" />

Works for me.
What container are you using?
 
Colin Shine
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben,

Thanks for the quick reply! I'm using Tomcat 5.5.12.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just tried with 5.5.9 and
Context Path: ${pageContext.request.contextPath}
printed
Context Path: /SimpleServlet
 
Colin Shine
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, I've got it to work!

The problem was I was using these images on my login page, and since they were under a secure directory, Tomcat wasn't serving them until I was logged in.

When it wasn't working, I checked the spec and jumped to the wrong conclusion... :roll:
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!