RE: Java Bean Scope questions (a lengthy one)

2003-01-11 Thread Denise Mangano
Noel,

I actually got this working by using Tim's suggestion of creating a reset
method in my bean, then in my controller between my useBean and setProperty
tags I call formBean.reset().

Works like a charm!!

Thanks for your help!!
Denise 

-Original Message-
From: Noel J. Bergman
To: Tomcat Users List
Sent: 1/10/2003 8:12 PM
Subject: RE: Java Bean Scope questions (a lengthy one)

Denise,

You might code the buttons as something like:

   input type=submit name=formAction value=OK
   input type=submit name=formAction value=CANCEL

Then within your webapp controller, you can call
request.getParameter(formAction), and if formAction is CANCEL, you can
reset your bean.

--- Noel


--
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]




RE: Java Bean Scope questions (a lengthy one) [getting desperate]

2003-01-10 Thread Ralph Einfeldt

As already was pointed out you have to reinitialise
sindex before you run the while loop.

There at least to options to do that:
- define a method like initStateList() and call it 
  before you enter the loop.
- reset the value in hasMoreStates() when false is returned

 -Original Message-
 From: Denise Mangano [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, January 09, 2003 10:00 PM
 To: 'Tomcat Users List'
 Subject: RE: Java Bean Scope questions (a lengthy one) [getting
 desperate]
 
 % while(formBean.hasMoreStates()) {  % 
option value=%= formBean.getStateList()%%=
 formBean.getStateList()%/option 
 % }

 
   public boolean hasMoreStates()
   {
 if (sindex  stateArray.length)
 return true;
 else
 return false;
   }

 //int sindex=-1; declared at beginning of class
 public String getStateList()
   {
   sindex++;
   String stemp = stateArray[sindex];
   return stemp;
   }
 

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




Re: Java Bean Scope questions (a lengthy one)

2003-01-10 Thread Bill Barker

Denise Mangano [EMAIL PROTECTED] wrote in message
5D83C44941AFD4118B6F0002B302984F438642@EXCHANGE_SERVER">news:5D83C44941AFD4118B6F0002B302984F438642@EXCHANGE_SERVER...
 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.

Exactly.


 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.


Yes, you are understanding correctly.  I haven't seen much for formBean, so
I'm going to fake it:
jsp:useBean id=formBean class=com.complusdata.beans.FormBean
scope=session /
%-- set all properties from the Request --%
jsp:setProperty name=formBean property=* /



 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 Man

RE: Java Bean Scope questions (a lengthy one) [getting desperate]

2003-01-10 Thread Tim Moore
 -Original Message-
 From: Ralph Einfeldt [mailto:[EMAIL PROTECTED]] 
 Sent: Friday, January 10, 2003 3:24 AM
 To: Tomcat Users List
 Subject: RE: Java Bean Scope questions (a lengthy one) 
 [getting desperate]
 
 
 
 As already was pointed out you have to reinitialise
 sindex before you run the while loop.
 
 There at least to options to do that:
 - define a method like initStateList() and call it 
   before you enter the loop.
 - reset the value in hasMoreStates() when false is returned

Personally, I'd prefer a third option:

Move the state list iteration into another class (say,
StateListIterator) and put a getStateListIterator method on the form
bean that returns a new instance of that class each time it's called.
Then get a new iterator each time the page is called.  That's more in
line with how collection iterators work in the JDK, and I think it's
just easier to understand in general.

-- 
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

 
  -Original Message-
  From: Denise Mangano [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, January 09, 2003 10:00 PM
  To: 'Tomcat Users List'
  Subject: RE: Java Bean Scope questions (a lengthy one) [getting 
  desperate]
  
  % while(formBean.hasMoreStates()) {  % 
 option value=%= formBean.getStateList()%%= 
  formBean.getStateList()%/option
  % }
 
  
public boolean hasMoreStates()
{
  if (sindex  stateArray.length)
  return true;
  else
  return false;
}
 
  //int sindex=-1; declared at beginning of class
  public String getStateList()
{
  sindex++;
  String stemp = stateArray[sindex];
  return stemp;
}

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




RE: Java Bean Scope questions (a lengthy one)

2003-01-10 Thread Denise Mangano
Thanks to everyone for their help.  This is the LAST issue with this form -
that is a promise.

Because of all your help, I have managed to work out every previous issue I
was having with my beans.   However, by changing the scope to session a new
issue has come up that I would really appreciate your help with.

I've now run into a problem when the user cancels in the middle of the
transaction.  When the user cancels they are brought back to the beginning
of the webapp (HTML page served by Apache) where they select the fee they
are paying .  The problem occurs when I get to the form for the second time
and submit, if any fields are left blank on the second try, the bean still
has the previous values, so those are displayed. 

What I need to do is either cancel the session and start a new one when the
user clicks cancel (the cancel button calls a javascript which calls
location.href(link) and from what I understand I can't invalidate the
session from within the javascript).  Instead I would rather  reset the
bean if this is possible.  From the books I have the most I have seen is
that when leaving a field in an HTML form blank this will not overwrite the
existing value of the bean variable.  This must be handled separately -
usually by assigning default values to the bean variable.  I think I have
done this because during my declaration all variables set equal to null or
to empty String.

Basically what I am looking to do is once the HTML form is submitted, and
the call to CCProcess.jsp is executed (where I have my jsp:setProperty
tag), I want ALL bean variables over written. I thought that this is what is
happening when I use:

jsp:useBean id=formBean class=com.Greenwich.beans.FormBean
scope=session/
jsp:setProperty name=formBean property=*/

But apparantley, when the field is left blank it isn't writing an empty
string back to the bean so the previous value is recalled.  I would like all
variables, blank and completed fields to be written back..  The only way I
could think to accomplish this is with a lot of code and addressing each
property separately, for example something to the effect of 

jsp:setProperty name=formBean property=*/
% 
 if (request.getParameter(name) == null)  //or is it == 
formBean.setName();
 if (request.getParameter(address) == null)
   formBean.setAddress();
 .
%

I would imagine this would be work, but I would also imagine there is an
easier way and I'm hoping that someone here will know :)

Thanks!!!
Denise

Denise Mangano
Help Desk Analyst
Complus Data Innovations, Inc.


-Original Message-
From: Bill Barker [mailto:[EMAIL PROTECTED]] 
Sent: Friday, January 10, 2003 4:03 AM
To: [EMAIL PROTECTED]
Subject: Re: Java Bean Scope questions (a lengthy one)



Denise Mangano [EMAIL PROTECTED] wrote in message
5D83C44941AFD4118B6F0002B302984F438642@EXCHANGE_SERVER">news:5D83C44941AFD4118B6F0002B302984F438642@EXCHANGE_SERVER...
 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.

Exactly.


 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,

RE: Java Bean Scope questions (a lengthy one)

2003-01-10 Thread Tim Moore
 -Original Message-
 From: Denise Mangano [mailto:[EMAIL PROTECTED]] 
 Sent: Friday, January 10, 2003 5:02 PM
 To: 'Tomcat Users List'
 Subject: RE: Java Bean Scope questions (a lengthy one)
 
 

[snip]

 Basically what I am looking to do is once the HTML form is 
 submitted, and the call to CCProcess.jsp is executed (where I 
 have my jsp:setProperty tag), I want ALL bean variables 
 over written. I thought that this is what is happening when I use:
 
 jsp:useBean id=formBean class=com.Greenwich.beans.FormBean
 scope=session/
 jsp:setProperty name=formBean property=*/
 
 But apparantley, when the field is left blank it isn't 
 writing an empty string back to the bean so the previous 
 value is recalled.  I would like all variables, blank and 
 completed fields to be written back..  The only way I could 
 think to accomplish this is with a lot of code and addressing 
 each property separately, for example something to the effect of 
 
 jsp:setProperty name=formBean property=*/
 % 
  if (request.getParameter(name) == null)  //or is it == 
 formBean.setName();
  if (request.getParameter(address) == null)
formBean.setAddress();
  .
 %
 
 I would imagine this would be work, but I would also imagine 
 there is an easier way and I'm hoping that someone here will know :)

Here's a thought.  You could define a reset method on your form bean
that blanks out all of the properties.  Then:

jsp:useBean id=formBean class=com.Greenwich.beans.FormBean
scope=session/
% formBean.reset(); %
jsp:setProperty name=formBean property=*/

-- 
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]




RE: Java Bean Scope questions (a lengthy one)

2003-01-10 Thread Denise Mangano
Thank you!! Thank you!! Thank you!! 

Tim -
The reset worked like a charm.  Thank you very much for ALL your help!!  I
could not find a single other problem with this form validation, so it looks
like this is it!! (keeping fingers crossed)

I ended up resetting the index first thing in the validate method and that
works.  I agree with your mention of the Iterator class, but for now I want
to get the rest of my app completed then will look into that when I go back
for fine tuning.

Thanks again!!!
Denise

-Original Message-
From: Tim Moore
To: Tomcat Users List
Sent: 1/10/2003 5:21 PM
Subject: RE: Java Bean Scope questions (a lengthy one)

 -Original Message-
 From: Denise Mangano [mailto:[EMAIL PROTECTED]] 
 Sent: Friday, January 10, 2003 5:02 PM
 To: 'Tomcat Users List'
 Subject: RE: Java Bean Scope questions (a lengthy one)
 
 

[snip]

 Basically what I am looking to do is once the HTML form is 
 submitted, and the call to CCProcess.jsp is executed (where I 
 have my jsp:setProperty tag), I want ALL bean variables 
 over written. I thought that this is what is happening when I use:
 
 jsp:useBean id=formBean class=com.Greenwich.beans.FormBean
 scope=session/
 jsp:setProperty name=formBean property=*/
 
 But apparantley, when the field is left blank it isn't 
 writing an empty string back to the bean so the previous 
 value is recalled.  I would like all variables, blank and 
 completed fields to be written back..  The only way I could 
 think to accomplish this is with a lot of code and addressing 
 each property separately, for example something to the effect of 
 
 jsp:setProperty name=formBean property=*/
 % 
  if (request.getParameter(name) == null)  //or is it == 
 formBean.setName();
  if (request.getParameter(address) == null)
formBean.setAddress();
  .
 %
 
 I would imagine this would be work, but I would also imagine 
 there is an easier way and I'm hoping that someone here will know :)

Here's a thought.  You could define a reset method on your form bean
that blanks out all of the properties.  Then:

jsp:useBean id=formBean class=com.Greenwich.beans.FormBean
scope=session/
% formBean.reset(); %
jsp:setProperty name=formBean property=*/

-- 
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]




RE: Java Bean Scope questions (a lengthy one)

2003-01-10 Thread Noel J. Bergman
Denise,

You might code the buttons as something like:

   input type=submit name=formAction value=OK
   input type=submit name=formAction value=CANCEL

Then within your webapp controller, you can call
request.getParameter(formAction), and if formAction is CANCEL, you can
reset your bean.

--- Noel


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




RE: Java Bean Scope questions (a lengthy one)

2003-01-09 Thread Denise Mangano
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 b

RE: Java Bean Scope questions (a lengthy one) [getting desperate]

2003-01-09 Thread Denise Mangano
Ok, I'm sorry for beating a dead horse, but I am completely at a loss and I
am starting to get concerned that I won't get this to work.

As suggested I changed the scope of my bean to session.  This caused some
problems that if not resolved my webapp will not work.  The code that I use
for setting a select field to the display the selected option if it is
valid, or repopulating the list no longer works since changing the scope to
session.  This has caused me to end up in a never ending loop for the form
Retry because these select fields are never valid.  For example one of my
select fields is for the user to select their state.  

My HTML form  (served through Tomcat although all other HTML pages are
served through Apache) uses the long hand select tag where I list each
state individually.  My bean contains an array of state abbreviations and
state names ( all one array in the format NY,New York,MA,
Massachussetts,AL,Alabama...).  In Retry.jsp I have the following
code:
jsp:useBean name=formBean class=com.complusdata.beans.FormBean
scope=session/
...
select name=state size=1
%if (!formBean.hasStateError()) 
  { %
 option value=%=formBean.getState()%
selected%=formBean.getStateName()%/option 
%}  
  else  {  %
 option value= selectedb--Please select your
state--/b/option
% while(formBean.hasMoreStates())  
   {  % 
   option value=%= formBean.getStateList()%%=
formBean.getStateList()%/option 
% }
   }  %
/select
..

Relevant methods in FormBean:
public boolean hasStateError()
  {
if (state.equals())
   return true;
else
   return false;
  }

  public boolean hasMoreStates()
  {
if (sindex  stateArray.length)
return true;
else
return false;
  }
public String getState()
  {
return state;
  }

public String getStateName()
  {
 int z;
 for (z=0; zstateArray.length-1; z=z+2)
 {
   if (stateArray[z].equals(state))
  return stateArray[z+1];
 }
 return state;
 }

//int sindex=-1; declared at beginning of class
public String getStateList()
  {
sindex++;
String stemp = stateArray[sindex];
return stemp;
  }

My form calls CCProcess which instantiates an instance of FormBean which
attempts to validate the form. Now since I changed the scope if I test
leaving the select list without a state selected, this causes a problem.
After the first retry, my select lists are populated.  Any time after that,
it defaults to the Please select your State but it does not populate the
list - it is taking this as the State which is obviously not valid, and
reason for the loop. I also ran a test where I left the state blank of the
first try, and the select list was populated.  I selected a state then hit
submit again (with other errors on the form) and the bean did not save the
state of my selection and the list did not populate.

If anyone can offer any help I would appreciate it.  Perhaps give me a clue
if there is something wrong with my code, or maybe some code someone is
currently using to serve the same purpose.  The thing is, I really don't
think its my code because it does work when the scope of the bean is
request.

Thanks in advance.

Denise Mangano
Help Desk Analyst
Complus Data Innovations, Inc.


-Original Message-
From: Denise Mangano [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, January 08, 2003 2:29 PM
To: 'Tomcat Users List'
Subject: RE: Java Bean Scope questions (a lengthy one)


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:

jsp:useBean id=transaction class = com.complusdata.beans.Transaction
scope=session 
  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 
 sessi

RE: Java Bean Scope questions (a lengthy one) [getting desperate]

2003-01-09 Thread Tim Moore
The problem is that sindex is never reset.  The first time you load the
form page, it iterates through the list of states, but on each
subsequent time, it remains at the end of the list, so hasMoreStates
always returns false.  The reason you didn't see this before is because
a new FormBean instance was created each time you visited the page.  Now
it's accessing the same instance from the session each time.

-- 
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


 -Original Message-
 From: Denise Mangano [mailto:[EMAIL PROTECTED]] 
 Sent: Thursday, January 09, 2003 4:00 PM
 To: 'Tomcat Users List'
 Subject: RE: Java Bean Scope questions (a lengthy one) 
 [getting desperate]
 
 
 Ok, I'm sorry for beating a dead horse, but I am completely 
 at a loss and I
 am starting to get concerned that I won't get this to work.
 
 As suggested I changed the scope of my bean to session.  This 
 caused some
 problems that if not resolved my webapp will not work.  The 
 code that I use
 for setting a select field to the display the selected option if it is
 valid, or repopulating the list no longer works since 
 changing the scope to
 session.  This has caused me to end up in a never ending loop 
 for the form
 Retry because these select fields are never valid.  For 
 example one of my
 select fields is for the user to select their state.  
 
 My HTML form  (served through Tomcat although all other HTML pages are
 served through Apache) uses the long hand select tag where 
 I list each
 state individually.  My bean contains an array of state 
 abbreviations and
 state names ( all one array in the format NY,New York,MA,
 Massachussetts,AL,Alabama...).  In Retry.jsp I have the 
 following
 code:
 jsp:useBean name=formBean class=com.complusdata.beans.FormBean
 scope=session/
 ...
 select name=state size=1
 %if (!formBean.hasStateError()) 
   { %
  option value=%=formBean.getState()%
 selected%=formBean.getStateName()%/option 
 %}  
   else  {  %
  option value= selectedb--Please select your
 state--/b/option
 % while(formBean.hasMoreStates())  
{  % 
option value=%= formBean.getStateList()%%=
 formBean.getStateList()%/option 
 % }
}  %
 /select
 ..
 
 Relevant methods in FormBean:
 public boolean hasStateError()
   {
 if (state.equals())
return true;
 else
return false;
   }
 
   public boolean hasMoreStates()
   {
 if (sindex  stateArray.length)
 return true;
 else
 return false;
   }
 public String getState()
   {
 return state;
   }
 
 public String getStateName()
   {
  int z;
  for (z=0; zstateArray.length-1; z=z+2)
  {
if (stateArray[z].equals(state))
   return stateArray[z+1];
  }
  return state;
  }
 
 //int sindex=-1; declared at beginning of class
 public String getStateList()
   {
   sindex++;
   String stemp = stateArray[sindex];
   return stemp;
   }
 
 My form calls CCProcess which instantiates an instance of 
 FormBean which
 attempts to validate the form. Now since I changed the scope if I test
 leaving the select list without a state selected, this causes 
 a problem.
 After the first retry, my select lists are populated.  Any 
 time after that,
 it defaults to the Please select your State but it does not 
 populate the
 list - it is taking this as the State which is obviously 
 not valid, and
 reason for the loop. I also ran a test where I left the state 
 blank of the
 first try, and the select list was populated.  I selected a 
 state then hit
 submit again (with other errors on the form) and the bean did 
 not save the
 state of my selection and the list did not populate.
 
 If anyone can offer any help I would appreciate it.  Perhaps 
 give me a clue
 if there is something wrong with my code, or maybe some code 
 someone is
 currently using to serve the same purpose.  The thing is, I 
 really don't
 think its my code because it does work when the scope of the bean is
 request.
 
 Thanks in advance.
 
 Denise Mangano
 Help Desk Analyst
 Complus Data Innovations, Inc.
 
 
 -Original Message-
 From: Denise Mangano [mailto:[EMAIL PROTECTED]] 
 Sent: Wednesday, January 08, 2003 2:29 PM
 To: 'Tomcat Users List'
 Subject: RE: Java Bean Scope questions (a lengthy one)
 
 
 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:
 
 jsp:useBean id=transaction class = 
 com.complusdata.beans.Transaction
 scope=session 
   jsp:setProperty name=transaction property=email
 value

RE: Java Bean Scope questions (a lengthy one) [getting desperate]

2003-01-09 Thread Denise Mangano
I can't believe I missed that!!  Now I have to figure out what to do to
reset it.  I tried resetting it first thing in my validate() method which is
called after every Retry, but now I get an index out of bounds error in my
getStateList() method.  Time to do some tweaking.  

Thanks for taking the time to look.  If it still doesn't work I'll be
back... ; )

Denise Mangano
Help Desk Analyst
Complus Data Innovations, Inc.


-Original Message-
From: Tim Moore [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 09, 2003 4:06 PM
To: Tomcat Users List
Subject: RE: Java Bean Scope questions (a lengthy one) [getting desperate]


The problem is that sindex is never reset.  The first time you load the form
page, it iterates through the list of states, but on each subsequent time,
it remains at the end of the list, so hasMoreStates always returns false.
The reason you didn't see this before is because a new FormBean instance was
created each time you visited the page.  Now it's accessing the same
instance from the session each time.

-- 
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


 -Original Message-
 From: Denise Mangano [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, January 09, 2003 4:00 PM
 To: 'Tomcat Users List'
 Subject: RE: Java Bean Scope questions (a lengthy one) 
 [getting desperate]
 
 
 Ok, I'm sorry for beating a dead horse, but I am completely
 at a loss and I
 am starting to get concerned that I won't get this to work.
 
 As suggested I changed the scope of my bean to session.  This
 caused some
 problems that if not resolved my webapp will not work.  The 
 code that I use
 for setting a select field to the display the selected option if it is
 valid, or repopulating the list no longer works since 
 changing the scope to
 session.  This has caused me to end up in a never ending loop 
 for the form
 Retry because these select fields are never valid.  For 
 example one of my
 select fields is for the user to select their state.  
 
 My HTML form  (served through Tomcat although all other HTML pages are 
 served through Apache) uses the long hand select tag where I list 
 each state individually.  My bean contains an array of state
 abbreviations and
 state names ( all one array in the format NY,New York,MA,
 Massachussetts,AL,Alabama...).  In Retry.jsp I have the 
 following
 code:
 jsp:useBean name=formBean class=com.complusdata.beans.FormBean
 scope=session/
 ...
 select name=state size=1
 %if (!formBean.hasStateError()) 
   { %
  option value=%=formBean.getState()%
 selected%=formBean.getStateName()%/option
 %}  
   else  {  %
  option value= selectedb--Please select your 
 state--/b/option
 % while(formBean.hasMoreStates())  
{  % 
option value=%= formBean.getStateList()%%= 
 formBean.getStateList()%/option
 % }
}  %
 /select
 ..
 
 Relevant methods in FormBean:
 public boolean hasStateError()
   {
 if (state.equals())
return true;
 else
return false;
   }
 
   public boolean hasMoreStates()
   {
 if (sindex  stateArray.length)
 return true;
 else
 return false;
   }
 public String getState()
   {
 return state;
   }
 
 public String getStateName()
   {
  int z;
  for (z=0; zstateArray.length-1; z=z+2)
  {
if (stateArray[z].equals(state))
   return stateArray[z+1];
  }
  return state;
  }
 
 //int sindex=-1; declared at beginning of class
 public String getStateList()
   {
   sindex++;
   String stemp = stateArray[sindex];
   return stemp;
   }
 
 My form calls CCProcess which instantiates an instance of
 FormBean which
 attempts to validate the form. Now since I changed the scope if I test
 leaving the select list without a state selected, this causes 
 a problem.
 After the first retry, my select lists are populated.  Any 
 time after that,
 it defaults to the Please select your State but it does not 
 populate the
 list - it is taking this as the State which is obviously 
 not valid, and
 reason for the loop. I also ran a test where I left the state 
 blank of the
 first try, and the select list was populated.  I selected a 
 state then hit
 submit again (with other errors on the form) and the bean did 
 not save the
 state of my selection and the list did not populate.
 
 If anyone can offer any help I would appreciate it.  Perhaps
 give me a clue
 if there is something wrong with my code, or maybe some code 
 someone is
 currently using to serve the same purpose.  The thing is, I 
 really don't
 think its my code because it does work when the scope of the bean is
 request.
 
 Thanks in advance.
 
 Denise Mangano
 Help Desk Analyst
 Complus Data Innovations

RE: Java Bean Scope questions (a lengthy one)

2003-01-08 Thread Denise Mangano
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:

jsp:useBean id=transaction class = com.complusdata.beans.Transaction
scope=session 
  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]




Re: Java Bean Scope questions (a lengthy one)

2003-01-08 Thread Bill Barker

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.

RE: Java Bean Scope questions (a lengthy one)

2003-01-07 Thread Tim Moore
 -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]




RE: Java Bean Scope questions (a lengthy one)

2003-01-07 Thread Denise Mangano
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...

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]




RE: Java Bean Scope questions (a lengthy one)

2003-01-07 Thread Denise Mangano
Correction - I changed the scope to session and the error messages DO
appear, so that is ok.  

But this caused a never ending loop in Retry.jsp and control never gets
forwarded to Verify.jsp. And my code for populating the select boxes does
not do what it should (should repopulate if there was an error or default to
selected option if one was selected - now this is successful in the first
retry, but after that it defaults to the first entry and does not list the
rest.

Now I am also getting some errors in catalina.out:
Jan 7, 2003 9:42:59 PM org.apache.jk.server.JkCoyoteHandler action
SEVERE: Error in action code
java.lang.NullPointerException
at
org.apache.jk.server.JkCoyoteHandler.action(JkCoyoteHandler.java:386)
at org.apache.coyote.Response.action(Response.java:222)
at
org.apache.coyote.tomcat4.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:
310)
at
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:221)
at
org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:261)
at
org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:360)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:632)
at
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:590)
at
org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:707)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:530)
at java.lang.Thread.run(Thread.java:536)

The log code that I had placed before just shows a loop: 
2003-01-07 21:42:41 jsp: Entering CCProcess
2003-01-07 21:42:41 jsp: Error on form - forwarding to Retry.jsp
2003-01-07 21:42:41 jsp: Entering Retry.jsp - error on form
2003-01-07 21:42:51 jsp: Entering CCProcess
2003-01-07 21:42:51 jsp: Error on form - forwarding to Retry.jsp
2003-01-07 21:42:51 jsp: Entering Retry.jsp - error on form

I changed the scope back to request.jsp and I get to Verify.jsp, but the
error message in catalina.out is still there.  What could be causing this?
And why would changing the scope to session cause me to enter into that
Retry.jsp loop?

Thanks!
Denise


-Original Message-
From: Denise Mangano [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, January 07, 2003 9:41 PM
To: 'Tomcat Users List'
Subject: RE: Java Bean Scope questions (a lengthy one)


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...

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

RE: Java Bean Scope questions (a lengthy one)

2003-01-07 Thread Tim Moore
 -Original Message-
 From: Denise Mangano [mailto:[EMAIL PROTECTED]] 
 Sent: Tuesday, January 07, 2003 10:13 PM
 To: 'Tomcat Users List'
 Subject: RE: Java Bean Scope questions (a lengthy one)
 
 
 Correction - I changed the scope to session and the error 
 messages DO appear, so that is ok.  
 
 But this caused a never ending loop in Retry.jsp and control 
 never gets forwarded to Verify.jsp. And my code for 
 populating the select boxes does not do what it should 
 (should repopulate if there was an error or default to 
 selected option if one was selected - now this is successful 
 in the first retry, but after that it defaults to the first 
 entry and does not list the rest.
 
 Now I am also getting some errors in catalina.out:
 Jan 7, 2003 9:42:59 PM org.apache.jk.server.JkCoyoteHandler action
 SEVERE: Error in action code
 java.lang.NullPointerException
 at
 org.apache.jk.server.JkCoyoteHandler.action(JkCoyoteHandler.java:386)
 at org.apache.coyote.Response.action(Response.java:222)
 at
 org.apache.coyote.tomcat4.CoyoteAdapter.postParseRequest(Coyot
 eAdapter.java:
 310)
 at
 org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.
 java:221)
 at
 org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:261)
 at
 org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:360)
 at 
 org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:632)
 at
 org.apache.jk.common.ChannelSocket.processConnection(ChannelSo
 cket.java:590)
 at
 org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:707)
 at 
 org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
 ThreadPool.jav
 a:530)
 at java.lang.Thread.run(Thread.java:536)

I don't know what that's about, actually. :-(

 
 The log code that I had placed before just shows a loop: 
 2003-01-07 21:42:41 jsp: Entering CCProcess
 2003-01-07 21:42:41 jsp: Error on form - forwarding to 
 Retry.jsp 2003-01-07 21:42:41 jsp: Entering Retry.jsp - error 
 on form 2003-01-07 21:42:51 jsp: Entering CCProcess 
 2003-01-07 21:42:51 jsp: Error on form - forwarding to 
 Retry.jsp 2003-01-07 21:42:51 jsp: Entering Retry.jsp - error on form
 
 I changed the scope back to request.jsp and I get to 
 Verify.jsp, but the error message in catalina.out is still 
 there.  What could be causing this? And why would changing 
 the scope to session cause me to enter into that Retry.jsp loop?

It's hard to say without seeing your code, but I'm guessing that
Retry.jsp tries to forward to CCProcess under some condition which only
triggers when one of your form bean properties is not null.  Then
CCProcess tries to validate, fails, forwards to Retry.jsp, which then
forwards back to CCProcess, etc.  When you use request scope, the form
bean is blanked out and you never enter the loop.

Good luck!

-- 
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


 
 Thanks!
 Denise
 
 
 -Original Message-
 From: Denise Mangano [mailto:[EMAIL PROTECTED]] 
 Sent: Tuesday, January 07, 2003 9:41 PM
 To: 'Tomcat Users List'
 Subject: RE: Java Bean Scope questions (a lengthy one)
 
 
 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...
 
 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

Re: Java Bean Scope questions (a lengthy one)

2003-01-07 Thread Bill Barker

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]