Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Wiki MarkupThe application, session and request objects are available from within {{s}} tags in jsp wherever ognl can be evaluated. Use the #application, #session, or #request syntax to get the object and access values by their keys using \ ['key'\].

Code Block
titleAccessing scoped variables via <s:property.../> tags
<s:property value="#application\['foo'\]"/>
<s:property value="#session\['baz'\]"/>

Conversely, if you would like to make Struts 2 objects available to a JSP/JSTL scope, the s:set tag may be used like this:

Code Block
titleExpose OGNL 'jobs' value to JSP/JSTL scope 'jobz'
<s:set name="jobz" value="jobs" scope="request" />
<c:forEach items="${jobz} var="job">
...
</c:forEach>
Info
title"Auto-exposure"

In Struts 2 OGNL values are automagically exposed to JSP/JSTL; using <s:set.../> as described above may not be necessary.

A full example below shows a struts variable "jobs" being exposed as "jobz" and being used with jstl and the display tag.

...