• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

EL expression ${pageContext.request}

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic