I have a parent file where my JSP is statically included.
<%@include file=\"test.jsp\" %>
In the included file I want to access the v
You can't access the variable but you can access the variable from the the value stack using OGNL. See OGNL Basics to learn more about variables in Struts and how to use them.
Besides the examples and descriptions given above, there are a few major changes in the EL since WebWork 1.x. The biggest one is that properties are no longer accessed with a forward slash
/
but with a dot.
. Also, rather than using..
to traverse down the stack, we now use[n]
where n is some positive number. Lastly, in WebWork 1.x one could access special named objects (the request scope attributes to be exact) by using@foo
, but now special variables are accessed using#foo
. However, it is important to note that#foo
does not access the request attributes. Because XWork is not built only for the web, there is no concept of "request attributes", and thus#foo
is merely a request to another object in theOgnlContext
other than the root.
To include JSP content dynamically use s:include tag
Include a servlet's output (result of servlet or a JSP page).
Note: Any additional
params
supplied to the included page are not accessible within the rendered page through the<s:property...>
tag since no valuestack will be created. You can, however, access them in a servlet via theHttpServletRequest
object or from a JSP page via a scriptlet.How To access parameters
Parameters are passed as request parameters, so use the
${param.ParamName}
notation to access them. Do not use the property tag to access parameters in included files.
<s:include value="test.jsp"/>