Wiki Markup |
The application, session and request objects are available from within ww s
tags in jsp wherever ognl can be evaluated. Use the #session syntax to get the object and access values by their keys using \[OS:#application, #session, or #request syntax to get the object and access values by their keys using ['key'].
Code Block |
---|
title | Accessing scoped variables via <s:property.../> tags |
---|
|
<s<ww:property value="#application\[OS:'foo'\]"/>
<ww<s:property value="#session\[OS:'baz'\]"/>
|
Conversely, if you would like to make webwork Struts 2 objects availible to say the jsp/jstl request scope. The property tag can available to a JSP/JSTL scope, the s:set
tag may be used like this.:
Code Block |
---|
title | Expose OGNL 'jobs' value to JSP/JSTL scope 'jobz' |
---|
|
<s<ww:set name="jobz" value="jobs" scope="request" />
<c:forEach items="${jobz} var="job">
...
</c:forEach>
|
Info |
---|
|
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 webwork struts variable "jobs" being exposed as "jobz" and being used with jstl and the display tag.
Example, exposing webwork Exposing framework objects to JSTL, with a JSTL and DisplayTag Example