[
https://issues.apache.org/struts/browse/WW-3093?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Wes Wannemacher updated WW-3093:
--------------------------------
Fix Version/s: 2.2.x
Lucian, I am not sure if we've ever supported JSP as a template technology. All
the other templates are implemented in freemarker because JSP can't really live
outside of a servlet container. If you can provide a patch that fixes your
problem, do so and we'll likely include it.
> Cannot create nested Struts 2 components using JSP templates.
> --------------------------------------------------------------
>
> Key: WW-3093
> URL: https://issues.apache.org/struts/browse/WW-3093
> Project: Struts 2
> Issue Type: Bug
> Affects Versions: 2.1.6
> Environment: Windows XP, Java 1.6.0_07, Tomcat 6.0.18
> Reporter: Lucian Furtos
> Fix For: 2.2.x
>
>
> The page contex is cleared after the body of the parent tag is rendered but
> is not replaced with the initial page context when the rendering returns to
> the parent tag.
> Details:
> Struts is configured to use JSP templates:
> <constant name="struts.ui.templateSuffix" value="jsp"/>
> We create an action and a tiles result for this action that takes us to a JSP
> file which contains the struts tags which use JSP templates.
> the JSP page contains the following snippet:
> <s:component theme="myJspTheme" template="components/box"
> cssStyle="background-color:aqua;">
> <s:param name="content">
> <s:textfield theme="myJspTheme" name="name" label="Name"/>
> <s:textfield theme="myJspTheme" name="password" label="Password"/>
> </s:param>
> </s:component>
> The template of the box component is
> (/template/myJspTheme/components/box.jsp):
> <div id="<s:property value="%{parameters.id}"/>" class="<s:property
> value="%{parameters.cssClass}"/>" style="<s:property
> value="%{parameters.cssStyle}"/>">
> <s:property value="%{parameters.content}" escape="false"/>
> </div>
> The error is:
> SEVERE: Servlet.service() for servlet jsp threw exception
> java.lang.NullPointerException
> at org.apache.struts2.components.Include.include(Include.java:245)
> at
> org.apache.struts2.components.template.JspTemplateEngine.renderTemplate(JspTemplateEngine.java:58)
> at org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:559)
> at org.apache.struts2.components.UIBean.end(UIBean.java:513)
> at
> org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
> at
> org.apache.jsp.test_jsp._jspx_meth_s_005fcomponent_005f0(test_jsp.java:124)
> at org.apache.jsp.test_jsp._jspService(test_jsp.java:73)
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> ...
>
> This is thrown because the page context doesn't contain a request, response
> or session anymore. The page context was cleared and returned to the pool but
> is still referred by the ValueStack.
> In the rendering process there are 2 instances of page context used: one for
> the outer component and one for the inner component(s). Let's call them
> outerPageContext and innerPageContext.
> When rendering of the outer component starts the outerPageContext is created
> and saved also in the struts value stack.
> Next the rendering of the inner component starts and this results in the
> creation of the innerPageContext instance. THis will replace the previous
> page context in struts value stack.
> When rendering of the inner text field is complete the innerPageContext is
> released (by tomcat) that means that it's request/response members are
> cleared and the instance itself is returned to the pool.
> However the innerPageContext instance is still referred by the struts value
> stack.
> In the UIBean.end() processing of the outer component the pageContext
> instance retrievied for rendering is no longer valid, and therefore the above
> error.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.