I've just discovered that if in struts-config.xml my action specifies
request="session" (or does not specify a request in which case the default
is session), and my jsp contains a <%@ page session="false" %> directive,
the JSP does not see any of the form beans.
There is no warning and no messages, it's just as if the bean was never set
in the form.

This took me a while to debug so I'm posting in case anyone has any
information about this behaviour. Is this documented anywhere?

Here is the example. If the <action> definition contains scope="request" the
expected behaviour is observed. If scope="session" then the testbean is not
accessible by the jsp.

---------
from struts-config.xml:

   <form-bean name="testForm" type="org.apache.struts.action.DynaActionForm
">
       <form-property name="testbean" type="java.lang.String"/>
   </form-bean>
...
   <action name="testForm" path="/f" type="test.TestAction" input="
test.layout" scope="session">
   </action>

-------------
The test action (abbreviated):

 public ActionForward execute(ActionMapping mapping, ActionForm theForm,
     HttpServletRequest request, HttpServletResponse response)
     throws Exception {

   DynaActionForm form = (DynaActionForm)theForm;
   form.set("testbean", "hello");

   return mapping.getInputForward();
 }

--------------
the jsp (in tiles.xml the test.layout tile (I'm using Tiles) is mapped to
test.jsp

...
<%@ page session="false"%>

<logic:present name="testForm" property="testbean">
 <bean:write name="testForm" property="testbean"/>
</logic:present>

<logic:notPresent name="testForm" property="testbean">
Bean not set
</logic:notPresent>

-----------


Any comments, thoughts?
dok

Reply via email to