Bill,

Let me see if I understand this correctly.  

You are correct.  I use formBean throughout various pages, so I understand
the need for session scope.  However, when I call CCSubmit.jsp, this is the
last page of my webapp so I think request scope for transaction is
appropriate(?).  It is not until I call CCSubmit.jsp that I want to
instantiate transaction and set some of the properties equal to properties
of formBean.  At that point the transaction bean is used to submit to my
payment processor and return information to CCSubmit.jsp.  Once CCSubmit.jsp
displays the returned information and the user has completed the
transaction, I no longer need the data stored in transaction...  The user
can either exit or go back to the home page to pay more fees if they decide
to.  

Question #1: Correct me if I am wrong, but the way I understand it is that
even if the user decides to enter the app again and pay more fees, at this
point when the user reaches CCSubmit.jsp again, this is a new request so
transaction would be instantiated again even it is the same session.

You wrote:
>>What I was pointing out is that any <jsp:setProperty ...> that is nested
within a <jsp:useBean ...> ... </jsp:useBean> acts as a first-time
initialization (sort of like a "constructor").  If the >>bean has already
been constructed, then it won't be called again.  To set the property every
time, you need to place the <jsp:setProperty ...> tag outside of the
<jsp:useBean ...> tag.

I understand what you are saying about using your suggested code to set the
properties every time, and its making me think that this may be what I need
for formBean, not transaction.  When my user submits the form for the first
time, it calls CCProcess.jsp where formBean is instantiated (setProperty
tags are nested within the useBean tag and there is no existing instance).
Then if the data is not valid, they are brought to Retry.jsp which displays
the errors for the offending fields.  Once that form is resubmitted, again
there is a call to CCProcess.jsp.  

Question #2:  Are you saying that since my scope is now "session",  in
CCProcess.jsp I should have the formBean setProperty tags outside of the
useBean tag? This way each time the form is submitted, the new (and
supposedly corrected) data gets written to the bean? (Which if I understand
this right this was happening previously and working correct but that was
because each time I call CCProcess.jsp it was a new request so the bean was
always getting instantiated.)  I could see how this could be the cause of my
current snag (which is a never ending Retry.jsp loop and select lists not
maintaining state), but I would like to hear back of whether or not I am
understanding this correctly.

Thank you!!!

Denise 


-----Original Message-----
From: Bill Barker [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 09, 2003 1:56 AM
To: [EMAIL PROTECTED]
Subject: Re: Java Bean Scope questions (a lengthy one)



"Denise Mangano" <[EMAIL PROTECTED]> wrote in message
5D83C44941AFD4118B6F0002B302984F43863C@EXCHANGE_SERVER">news:5D83C44941AFD4118B6F0002B302984F43863C@EXCHANGE_SERVER...
> Bill,
>
> I'm not sure what you mean.  The transaction Bean gets instantiated 
> when I call CCSubmit.jsp.  That is the first time it is "mentioned" 
> and CCSubmit
is
> only called once from Verify.jsp.  Is what you are saying effectively 
> the same as:

Taking a wild guess, I'm thinking that you want 'formBean' to have
scope="session", and 'transaction' to have scope="request".  This way,
'formBean' stays around between pages, but 'transaction' only stays around
for the one request that it is needed.

What I was pointing out is that any <jsp:setProperty ...> that is nested
within a <jsp:useBean ...> ... </jsp:useBean> acts as a first-time
initialization (sort of like a "constructor").  If the bean has already been
constructed, then it won't be called again.  To set the property every time,
you need to place the <jsp:setProperty ...> tag outside of the <jsp:useBean
...> tag.

>
> <jsp:useBean id="transaction" class = 
> "com.complusdata.beans.Transaction"
> scope="session" >

This code will only be executed if there is *no* "transaction" in the
session (and the JSP page needs to create a new one.  If you have previously
called CCSubmit.jsp (or if you had any other page that used "transaction")
at any point with this session, it will be skipped.

>   <jsp:setProperty name="transaction" property="email" 
> value="<%=formHandler.getEmail()%>"/>
>    ....
> </jsp:useBean>
>
> Thanks.
>
> Denise Mangano
> Help Desk Analyst
> Complus Data Innovations, Inc.
>
>
> -----Original Message-----
> From: Bill Barker [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 08, 2003 1:42 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Java Bean Scope questions (a lengthy one)
>
>
>
> "Denise Mangano" <[EMAIL PROTECTED]> wrote in message 
> 5D83C44941AFD4118B6F0002B302984F438636@EXCHANGE_SERVER">news:5D83C44941AFD4118B6F0002B302984F438636@EXCHANGE_SERVER...
> > Wow someone read all of that!! ;)
> >
> > For Question #1:  I should have mentioned this before... I tried to 
> > use session scope at one point (don't recall the exact reason but I 
> > thought of it as an attempt to resolve a different problem).  When I 
> > set the scope to session, it caused problems with my form 
> > validation. Currently if the
> form
> > is not validated, the user is brought back to Retry.jsp and error 
> > messages appear next to the offending input field.  When I used 
> > session scope, Retry.jsp would be reloaded, but the error messages 
> > would not be displayed... Any thoughts on that?  I am going to go 
> > back and attempt this again now that everything is working as it 
> > should up to Verify.jsp and see if I stand corrected...
>
> You need:
> <jsp:useBean id="transaction" class = 
> "com.complusdata.beans.Transaction"
> scope="session" />
>   <jsp:setProperty name="transaction" property="email"
> value="<%=formHandler.getEmail()%>"/>
> ....
>
>
> Note the final '/>' on jsp:useBean.  The way that you had it 
> originally,
the
> properties will only be set if the JSP page needs to create a new 
> instance of "transaction".  If it finds one in the session already, 
> the setters are skipped.
>
>
>
> >
> > For Question #2 - that's exactly what I needed to know!!
> >
> > For Question #3 - hopefully I can get the session scope to work, but 
> > then how would I program that button?  Would I just put 
> > onClick="Retry.jsp" ?
> >
> > Tim, thank you so much for taking the time!!
> > Denise :)
> >
> > -----Original Message-----
> > From: Tim Moore [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, January 07, 2003 9:24 PM
> > To: Tomcat Users List
> > Subject: RE: Java Bean Scope questions (a lengthy one)
> >
> >
> > > -----Original Message-----
> > > From: Denise Mangano [mailto:[EMAIL PROTECTED]]
> > > Sent: Tuesday, January 07, 2003 9:19 PM
> > > To: 'Tomcat Users List'
> > > Subject: Java Bean Scope questions (a lengthy one)
> > >
> > >
> > > Question #1: Why does CCSubmit.jsp not have access to formBean 
> > > properties. I am thinking this is because technically by 
> > > submitting a form with an action of "CCSubmit.jsp" control isn't 
> > > being forwarded to CCSubmit.jsp so the instance of formBean isn't 
> > > forwarded.  The scope of formBean is request. Is that the correct 
> > > scope to use?  **I need to have access to formBean properties from 
> > > the moment it is instantiated to the moment the application has 
> > > completed, but it has to be unique to each user of the
> > > webapp.**   How
> > > could I accomplish this?
> >
> > That's exactly what session scope is for. :-) Request scope means 
> > that the bean is gone at the end of the request (that is, when 
> > Verify.jsp finishes rendering).  If you put it in session scope 
> > you'll be set.
> >
> > > Question #2: Is it possible to use two beans within a single jsp 
> > > page?  I would imagine that it is, and if so I believe once I gain 
> > > access to formBean properties, my transaction properties will no 
> > > longer be null. (I included some code below... is this legal?)
> >
> > Absolutely!  As long as they have different id attributes, you can 
> > use as many beans as you like.
> >
> > > Question #3:  I include a button to give the option to go back and 
> > > make changes.  If the user should desire to go back and make 
> > > changes, control should be forwarded to Retry.jsp on button click. 
> > > I need to program this button in a way so that when Retry.jsp is 
> > > recalled it will still have access to formBean properties.How do I 
> > > program this? My last attempt using <jsp:forward> cause Retry.jsp 
> > > to load automatically when Verify.jsp was loaded (sorry again Noel 
> > > ;) ).
> >
> > As long as the bean is in session scope, you'll be able to access it 
> > from any page the user accesses.
> > --
> > Tim Moore / Blackboard Inc. / Software Engineer
> > 1899 L Street, NW / 5th Floor / Washington, DC 20036
> > Phone 202-463-4860 ext. 258 / Fax 202-463-4863
> >
> > --
> > To unsubscribe, e-mail: 
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail: 
> > <mailto:[EMAIL PROTECTED]>
>
>
>
>
> --
> To unsubscribe, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>




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

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

Reply via email to