Struts Forms question

Hello,

      Today a guy asked me if i could map one action to two forms !!  

      Can we do that ?? He says the first forms information he will store in the session, and then on the second form when the user will submit the form, he will store the two forms into the database. How can he store a forms information in session ?????????????????  

Thanks
letsbedecentAsked:
Who is Participating?
 
aozarovCommented:
An Action is associated with only one ActionForm.
You can store as many objects as you want in the Session. hence your action can create beans and add them to your session (but that has nothing to do with the above).
0
 
letsbedecentAuthor Commented:
yeah.. but isnt the information on the first form lost when the user goes to the second page !!! If the form is not associated with an action form ?

Or is he thinking about using request.getParameter() and storing all the information in a session !!
0
 
aozarovCommented:
The Form will "live" based on the scope defined in the Action.
e.g
<action
                path="/LogonSubmit"
                type="app.LogonAction"
                name="logonForm"
                scope="request"
                validate="true"
                input="/pages/Logon.jsp">
                <forward
                    name="success"
                    path="/pages/Welcome.jsp"/>
                <forward
                    name="failure"
                    path="/pages/Logon.jsp"/>
            </action>

This Action will create an instance of logonForm per request.
if you change scope="request to scope="session" (which is the default if you don't provide this attribute) then that logonForm will live for the whole session.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.