Search code examples
javahtmljspstrutsstruts-1

Variable property name in html:text tag


I'm using struts-1 and want to use a concatinated string as a property name in a html:text tag. The string is composed of a static String and a parameter given from a jsp:include tag.

The include part

    <jsp:include page="test.jsp">
        <jsp:param name="language" value="DE" />
    </jsp:include>

The html:text

    Param: ${param.language}
    <html:text property="propertyDE" name="bean" />

The not working html:text code

    Param: ${param.language}
    <html:text property="<%="property" + param.language%>" name="bean" />

Is there a way to use a dynamic value in the property attribute in html:text? How can I achieve this?


Solution

  • You could use :

    <c:set var="language" value="DE" />
    

    importing <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

    and then use the variable as ${language}