Search code examples
jspstruts2jspinclude

Setting a default value to a param in s:include


I am writing a small widget in struts which I want to include. The height of the widget should be auto unless I pass in a param of height. For example:

# Example 1:
<s:include value="myWidget.jsp">
  <s:param name="height">300 px</s:param>
</s:include>

# Example 2:
<s:include value="myWidget.jsp">
</s:include>

Inside myWidget.jsp I can access the value of height using ${param.height}. But if I don't pass the height param it simple comes across as blank. I want to set the value explicitly to "auto", how can I do this?


Solution

  • You could use c:out in the JSTL core tags.

    <c:out value="${param.height}" default="auto"/>