Search code examples
jspjstlstruts-1

how to mimic JSTL core set (c:set) in Struts 1.0.2


Yes, that's right. Legacy app maintenance.

How do I mimic the <c:set var='myvar' scope='requqst' value='val' /> in old school Struts 1.0.2?

Assume that I can't add JSTL to the application.


Solution

  • You could do it without touching Struts at all, using scriptlets – consider this a last resort:

    <%
        request.setAttribute("myvar", "val");
    %>
    

    I'm not sure about Struts 1.0.2 (it should be okay), but I know that in v1.3.8, this will also work:

    <bean:define id="myvar" type="java.lang.String" value="val"/>
    

    Be aware that the allowed types are extremely limited.