Search code examples
javajspjstlstrutsstruts-1

Struts tag inside another tag STRUTS 1.3


I've got a problem. I've been searching for the answer on different forums but unfortunatelly I didn't find the answer. I need this because I'm creating a webpage where you can change language so it cannot be hard coded.I need to do sth like this:

<html:option value="<bean:message key="region"/>"><bean:write name="region"/></html:option>

So I want to have the value in html tag set to the string taken from my messages.properties file.The above solution doesn't work. I'd be really grateful for answer because I spend too much time on this....


Solution

  • You can use the code using struts tags

    <bean:define id="regionId"><bean:message key="region"/></bean:define>
    <html:option value="<%=regionId%>"><%=regionId%></html:option>
    

    or better using JSTL

    <fmt:message key="region" var="regionId"/>
    <html:option value="${regionId}">${regionId}</html:option>