struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "" <>
Subject Is there a way to store a bean property value in a variable in view (JSP)?
Date Tue, 18 Dec 2007 21:23:23 GMT
Hi all,

I need to build a path to an image file in a JSP based on the value passed
to the JSP's action, either using an English button from <context
or using a French button from <context path>/*fr*/closeBtn.gif. Suppose the
parameter is called lang so the URL is like* .../login.action?lang=<en or
There are two approaches, each of which has a problem which I need to figure

*1. If the path is built in JSP*
In this case, I need to store the lang value in a variable and use it to
build the path like this:

<s:url value="/" includeParams="none" id="contextPath"/>

<img src="${contextPath}*???*/closeBtn.gif"/>

where ??? is either en or fr. How can I do it? I know lang can be streamed
out like <s:property value="lang"/> but it doesn't work if ??? is substitued
with <s:property value="lang"/>. Is there a way to read lang to a variable?

*2. If the path is built in the action class*

In this case, I need to get context path and use it to build the path. The
path can be stored as a bean property so its value can be accessed in view
using <s:property .../> tag.

The problem is how to get the context path from an action class?

Are there other ways to solve the problem?

Thanks a lot for any comments and help.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message