<s:include>
tag includes a servlet’s output (result of servlet or a JSP page).
One can also pass the parameters while including a page/servlet using <s:param>
tag as follows
<s:include value="/WEB-INF/pages/include/menu.jsp">
<s:param name="tabName">aboutus</s:param>
</s:include>
How to access the parameters passed in included page
For accessing the parameter ‘tabName’ in menu.jsp, one can use Expression Language
${param.tabName}
.
According to Struts2 documentation on include tag
“Parameters are passed as request parameters, so use the ${param.ParamName}
notation to access them. Do not use the property tag to access parameters in included files”.
Note: Do NOT Use “${}” notation in the value attribute of <s:property>
tag. “${}” works when used in html code directly. Learn more about using Expression Language.
Parameter can also be accessed from request object in jsp
<%= request.getParameter("tabName")%>
I hope it helps.
I am still struggling in finding out that how can i use this parameter in struts test conditions. If you have an idea.. do leave a comment.
2 Moderators: please remove my previous 2 comments.
Another way to formulate the same thing:
To use this type of params in ‘s:if’ tag, you should first set a new var with ‘s:set’ tag, and then just reference the new variable in ‘s:if’.