Apache Struts 2 Documentation > Home > FAQs > Cookbook > Exposing framework objects to JSTL, with a JSTL and DisplayTag Example
Added by sutter2k, last edited by Dave Newton on Feb 04, 2007  (view change)
<s:set name="jobz" value="jobs" scope="request" />

The full example below shows a Struts 2/OGNL variable "jobs" being exposed as "jobz" to the request scope and being used with jstl and the display tag.

<%@ taglib uri="/WEB-INF/tlds/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tlds/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tlds/displaytag-el-12.tld" prefix="display" %>
<%@ taglib uri="/struts-tags" prefix="s" %>

<s:set name="jobz" value="jobs" scope="request" />

<h1><fmt:message key="title.listAllJobs"/></h1>
<display:table name="jobz" class="simple" id="row" >
  <display:column  titleKey="label.global.actions" >
  		<c:url var="viewurl" value="/viewJobDetail.action">
			<c:param name="name" value="${row.name}"/>
  			<c:param name="groupName" value="${row.group}"/>
		</c:url>
  		<c:url var="exeurl" value="/viewJobDetail.action">
			<c:param name="name" value="${row.name}"/>
  			<c:param name="groupName" value="${row.group}"/>
  			<c:param name="executeJobAction" value="execute"/>
		</c:url>
  		<c:url var="editurl" value="/viewJobDetail.action">
			<c:param name="name" value="${row.name}"/>
  			<c:param name="groupName" value="${row.group}"/>
  			<c:param name="editAction" value="edit"/>
		</c:url>
	<a href='<c:out value="${viewurl}"/>'><fmt:message key="label.global.view"/></a> |
	<a href='<c:out value="${editurl}"/>'><fmt:message key="label.global.edit"/></a> |
	<a href='<c:out value="${exeurl}"/>'><fmt:message key="label.global.execute"/></a> &nbsp;
  </display:column> 

  <display:column property="group" titleKey="label.job.group" sortable="true"   />
  <display:column property="name" titleKey="label.job.name" sortable="true"  />
  <display:column property="description" titleKey="label.job.description" />
  <display:column property="jobClass" titleKey="label.job.jobClass" sortable="true"  />

</display:table>

Please note, at the time of this writing the "titleKey" attribute of the display tag's column tag is not yet released into a final version. It is a feature that is currently only available through cvs.