You didn't list the code for your form bean or JSP so I can only make guesses. It looks like your action is storing an instance of the form bean in session scope under the key resultForm and that you're able to access it explicitly in result.jsp, but that the <html:form/> tag in the JSP isn't being associated with that bean, despite the name="resultForm" on the action mapping. Is that right?

Things to check:

 - what's the base type of the action form?
 - what's the action on the form in result.jsp?

The 'name' attribute on the '/result' action mapping tells Struts to instantiate / populate a requestForm bean when that action is invoked. I'm not sure, but that might be causing Struts to call reset() on the bean that's already in the session from IndexAction.

Next, result.jsp is rendered. It contains a <html:form/> tag (I assume), so Struts will lookup / instantiate a bean to associate with the form. Depending on what class your form bean extends and what action that form tag points at, this may or may not be the requestForm bean you already populated. Unless that form points at /request.do, it's probably expecting to use some other form bean, based on the config you posted below.

If you still can't figure out what's happening, post your form bean code and JSPs so we can see more clearly what you're doing.

L.

Kevin wrote:

Hi
I want to trasnfer data from One action to another
using a form bean.

How can i access the form bean data in the second
action.

I have attached my struts config and action class.

The submitIndex forwards to result action.

But in result page i want to show data i have
populated in the ActionBean for the page.

What is the appropriate way to dispaly it on the
result page.

This does not work but was wondering why ??
<html:text maxlength="20" property="name">
</html:text></td>

or
This works.
<bean:write name="resultForm" property="name"/>
</html:form>

Help is greatly appretiated.

Thanks
Navin



                
__________________________________ Do you Yahoo!? Yahoo! Mail - Find what you need with new enhanced search. http://info.mail.yahoo.com/mail_250


------------------------------------------------------------------------

/*
 * Created on Aug 14, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.loginapp;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 * @author navin.shenoy
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class IndexAction extends Action
{

    /* (non-Javadoc)
     * @see 
org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, 
org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, 
javax.servlet.http.HttpServletResponse)
     */
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) throws 
Exception
    {
IndexForm indexForm=(IndexForm)form;
        System.out.println(indexForm);
ResultForm result=new ResultForm();
        result.setName("aaa");
        request.getSession().setAttribute("resultForm" ,result);
        return mapping.findForward("success");
    }
}


------------------------------------------------------------------------

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
          "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd";>

<!--
     This is a blank Struts configuration file with an example
     welcome action/page and other commented sample elements.

     Tiles and the Struts Validator are configured using the factory defaults
     and are ready-to-use.

     NOTE: If you have a generator tool to create the corresponding Java classes
     for you, you could include the details in the "form-bean" declarations.
     Otherwise, you would only define the "form-bean" element itself, with the
     corresponding "name" and "type" attributes, as shown here.
-->


<struts-config>

<!-- ============================================ Data Source Configuration -->
<!--
<data-sources>
<data-source type="org.apache.commons.dbcp.BasicDataSource">
    <set-property
      property="driverClassName"
      value="org.postgresql.Driver" />
    <set-property
      property="url"
      value="jdbc:postgresql://localhost/mydatabase" />
    <set-property
      property="username"
      value="me" />
    <set-property
      property="password"
      value="test" />
    <set-property
      property="maxActive"
      value="10" />
    <set-property
      property="maxWait"
      value="5000" />
    <set-property
      property="defaultAutoCommit"
      value="false" />
    <set-property
      property="defaultReadOnly"
      value="false" />
    <set-property
      property="validationQuery"
      value="SELECT COUNT(*) FROM market" />
</data-source>
</data-sources>
-->

<!-- ================================================ Form Bean Definitions -->

    <form-beans>
        <form-bean
            name="loginForm"
            type="com.loginapp.LoginForm"/>

        <form-bean
            name="indexForm"
            type="com.loginapp.IndexForm"/>

        <form-bean
            name="resultForm"
            type="com.loginapp.ResultForm"/>
<!-- sample form bean descriptor for an ActionForm
        <form-bean
            name="inputForm"
            type="app.InputForm"/>
    end sample -->

    <!-- sample form bean descriptor for a DynaActionForm
        <form-bean
            name="logonForm"
            type="org.apache.struts.action.DynaActionForm">
            <form-property
                name="username"
                type="java.lang.String"/>
            <form-property
                name="password"
                type="java.lang.String"/>
       </form-bean>
    end sample -->
    </form-beans>


<!-- ========================================= Global Exception Definitions -->

    <global-exceptions>
        <!-- sample exception handler
        <exception
            key="expired.password"
            type="app.ExpiredPasswordException"
            path="/changePassword.jsp"/>
        end sample -->
    </global-exceptions>


<!-- =========================================== Global Forward Definitions -->

    <global-forwards>
        <!-- Default forward to "Welcome" action -->
        <!-- Demonstrates using index.jsp to forward -->
        <!--
        <forward
            name="welcome"
            path="/Welcome.do"/>
            -->
    </global-forwards>


<!-- =========================================== Action Mapping Definitions -->

    <action-mappings>
<action path="/login"
            forward="/WEB-INF/pages/login.jsp"        
                >            
                </action>

                <action path="/index"
            forward="/WEB-INF/pages/index.jsp"        
                >            
                </action>

                <action path="/result"
            forward="/WEB-INF/pages/result.jsp"                               
            name="resultForm"
            scope="session"
                >            
                </action>
                

                <action path="/submitLogin"
                        type="com.loginapp.LoginAction"
            name="loginForm"
            scope="request"
input="/login.do" >
                        <forward name="success"
                        path="/index.do" redirect="false"/>
                        <forward name="failure"
                        path="/login.do" redirect="false"/>
                        
                </action>

                <action path="/submitIndex"
                        type="com.loginapp.IndexAction"
            name="indexForm"
scope="request" >
                        <forward name="success"
                        path="/result.do" redirect="false"/>
                        <forward name="failure"
                        path="/result.do" redirect="false"/>
                        
                </action>

            <!-- Default "Welcome" action -->
            <!-- Forwards to Welcome.jsp -->
            <!--
        <action
            path="/Welcome"
            forward="/pages/Welcome.jsp"/>
-->
    <!-- sample input and input submit actions

        <action
            path="/Input"
            type="org.apache.struts.actions.ForwardAction"
            parameter="/pages/Input.jsp"/>

        <action
            path="/InputSubmit"
            type="app.InputAction"
            name="inputForm"
            scope="request"
            validate="true"
            input="/pages/Input.jsp"/>

            <action
                path="/edit*"
                type="app.Edit{1}Action"
                name="inputForm"
                scope="request"
                validate="true"
                input="/pages/Edit{1}.jsp"/>

    end samples -->
    </action-mappings>


<!-- ============================================= Controller Configuration -->

    <controller
       processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>


<!-- ======================================== Message Resources Definitions -->

    <message-resources parameter="MessageResources" />


<!-- =============================================== Plug Ins Configuration -->

  <!-- ======================================================= Tiles plugin -->
  <!--
     This plugin initialize Tiles definition factory. This later can takes some
         parameters explained here after. The plugin first read parameters from
         web.xml, thenoverload them with parameters defined here. All parameters
         are optional.
     The plugin should be declared in each struts-config file.
       - definitions-config: (optional)
            Specify configuration file names. There can be several comma
                    separated file names (default: ?? )
       - moduleAware: (optional - struts1.1)
            Specify if the Tiles definition factory is module aware. If true
            (default), there will be one factory for each Struts module.
                        If false, there will be one common factory for all 
module. In this
            later case, it is still needed to declare one plugin per module.
            The factory will be initialized with parameters found in the first
            initialized plugin (generally the one associated with the default
            module).
                          true : One factory per module. (default)
                          false : one single shared factory for all modules
           - definitions-parser-validate: (optional)
                Specify if xml parser should validate the Tiles configuration 
file.
                          true : validate. DTD should be specified in file 
header (default)
                          false : no validation

          Paths found in Tiles definitions are relative to the main context.
  -->

    <plug-in className="org.apache.struts.tiles.TilesPlugin" >

      <!-- Path to XML definition file -->
      <set-property property="definitions-config"
                       value="/WEB-INF/tiles-defs.xml" />
      <!-- Set Module-awareness to true -->
      <set-property property="moduleAware" value="true" />
    </plug-in>


  <!-- =================================================== Validator plugin -->

  <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property
        property="pathnames"
        value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
  </plug-in>

</struts-config>



------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--
Laurie Harper
Open Source advocate, Java geek: http://www.holoweb.net/laurie
Founder, Zotech Software: http://www.zotechsoftware.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to