Jukka Välimaa wrote:
Getting the context path in jsp is something struts doesn't really
support--something I've had trouble with many times. One way to get around
the problem is scriptlet like Jim showed you. Recently, we used url tag for
the same purpose:

<s:url id="saveImg" value="/images/save.gif" />

<s:submit type="image"  src="%{saveImg}" />


I agree it's strange it's not readily available in the valuestack. I avoid using it in struts tags myself. eg. I'd use <input type="submit" src="${pageContext.request.contextPath}/images/save.gif">

You're not obliged to use struts tags.

An alternative approach is to put it into scope using JSP and the get it out in the struts tag.

eg.
<% pageContext.setAttribute("contextPath", request.getContextPath());%>

<s:submit type="image"  src="%{#attr.contextPath}/images/save.gif" />


I don't do that because its prone to errors whereas the former approach is understood by all IDEs.

If you wanted to get clever you could place it into the context using an interceptor (although the framework should do it, but doesn't).



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to