| Author |
EL expression ${pageContext.request}
|
Colin Shine
Greenhorn
Joined: Aug 12, 2005
Posts: 26
|
|
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:
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
<img src="${pageContext.request.contextPath}/images/myimage.gif" /> Works for me. What container are you using?
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Colin Shine
Greenhorn
Joined: Aug 12, 2005
Posts: 26
|
|
Hi Ben, Thanks for the quick reply! I'm using Tomcat 5.5.12.
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
I just tried with 5.5.9 and Context Path: ${pageContext.request.contextPath} printed Context Path: /SimpleServlet
|
 |
Colin Shine
Greenhorn
Joined: Aug 12, 2005
Posts: 26
|
|
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:
|
 |
 |
|
|
subject: EL expression ${pageContext.request}
|
|
|