Struts2 Include and Param tag usage example

When a repeatable, parameterized UI component is needed, let Struts2 include and param tags do most of the work. The example below uses JSP to create a single table row with two cells:

  1. Create JSP containing the parameterized UI component and save it in a file named tableRow.jsp:

    <%@ taglib prefix="s" uri="/struts-tags" %>
    <tr class='thisClassNameCouldBeAParameter'
      <td class="${param.tableColumn1Class}">
        <a class="${param.tableLinkClass}"
      <td class="${param.tableColumn2Class}">
  2. Use the
    and <s:param tags to include the output of the UI component JSP in another JSP:

    <s:include value="tableRow.jsp"> 
          <s:param name="tableRowUrl"
                   value="%{'/theUrl'}" />
          <s:param name="tableColumn1Content"
                   value="%{'Use Access Control'}" />
          <s:param name="tableColumn2Content"
                   value="%{#cfg.useAccessControl}" />
          <s:param name="tableColumn1Class"
                   value="%{'table-cell'}" />
          <s:param name="tableColumn2Class"
                   value="%{'table-cell'}" />
          <s:param name="tableLinkClass"
                   value="%{'table-link'}" />

About Terry Gardner

Terry Gardner was a leading directory services architect with experience with many large scale directory services installations and messaging server installations, and was a Subject Matter Expert in the field of Directory Services and Solaris (operating system) performance. Mr. Gardner also participated in the open-source software community. Mr. Gardner passed away in December, 2013.
This entry was posted in computing, Java and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s