Wednesday, January 20, 2010

How to pass jsp:param in jsp:include and access from struts 2 tag

1. Include a jsp file in the first page by passing the parameters like "text" as follows:

first.jspx:
..
..
<jsp:include page="/WEB-INF/jsp/middle.jspx">
<jsp:param name="text" value="Good Morning!!!" />
</jsp:include>
..
..

2. middle.jspx
..
..
<jsp:include page="/WEB-INF/jsp/last.jspx">
<jsp:param name="text" value="${param.text}" />
</jsp:include>
..
..

3. last.jspx

..
..
<c:set var="text" value="${param.text}"/>

Your Passed Text is == <s:property value="%{#attr.text}"/>
..
..

Note:Unfortunately you can't use JSTL in Struts 2 tags anymore. The above solution is a work around by using JSTL to set the parameter into page scope.

No comments:

Post a Comment