RE: thread problems?

2001-07-17 Thread Gogineni, Pratima

Thanks for your suggestion Martin. I understand that nothing is preserved
between requests.

I have  a fix (that I dont like) temporarily. I can detail below exactly
what is happening and what the three solutions I could think of were and the
one that I choose implement as a temporary fix. Would be glad to knwo what
people think of it.

My form bean has indexed properties that are displayed/modified in the jsp
page. The valid indices on this property can change between requests. When
the ActionServlet recieves a request - it sets all the properties on my form
bean. Now when I manage to send multiple requests from the browser almost
simultaneously - the first request executes properly as a result the valid
indices on my bean have changed. Now the second request is handled by the
actionservlet and it trys to set the same properties as the first one on the
form bean but unfortunately the valid indices have changed and there is an
error.

I was thinking that if the transactional tokens were checked in the
ActionServlet itself this problem would not have occurred.

Another possibility was modify the bean utils so that for indexed propertys
no errors are thrown if the indices have changed (I dont like this very
much). Or alternatively redirect back to the input page from here.

The third possibilty which I used as a temporary fix is this: In actionform
if an indexed proprety value outside its range is being set - dont throw an
error - Just do Nothing.

And the above solution works fine. 

Thanks
Pratima

-Original Message-
From: Martin Cooper [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 17, 2001 12:02 AM
To: Gogineni, Pratima
Cc: [EMAIL PROTECTED]
Subject: Re: thread problems?


I believe your problems are caused by your assumptions about the
preservation (or otherwise) of state between requests. Nothing is guaranteed
to be preserved unless you write code to make those guarantees.

--
Martin Cooper


- Original Message -
From: "Gogineni, Pratima" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 16, 2001 11:43 AM
Subject: thread problems?


> Hi,
>
> I have been fighting with the following situation and would appreciate any
> ideas/suggestions.
>
> I have a session scoped form bean "FBean", a jsp page that displays it
> "dispFBean" & an action FBeanAction.
>
> I have inserted transactional tokens to take care of duplicate posting.
>
> After changing a value in dispFBean, an enter or/and a click work fine &
> they do the same thing ie. call FBeanAction.
>
> when the 2 events are done in rapid succession - one event executes fine
> while the other event throws an exception because it is trying to access
> row#5 where as the previous action changed the number of rows to 4.
> Unfortunately the transactional tokens cant take care of this since this
> error is being thrown in BeanUtils.populate before it ever reaches an
> FBeanAction instance.
>
> I also tried declaring the jsp page threadsafe to check if that is the
> problem.
>
> Also note that the FBeanAction replaces FBean with a new Instance of
FBean.
>
> Thanks
> Pratima
>




Re: thread problems?

2001-07-16 Thread Rama Krishna



hmmm.

is it like in one session you can have multiple instances of the bean, with
different values???

if not,
 instead of static, use session variable.
you can make your method synchronized and inside that set/get the session
variable and make it required that any action would check for this static
variable first before doing anything else.
in this way at any instance only one action will be setting/getting the
values and another action will get the new value.




- Original Message -
From: "Gogineni, Pratima" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 16, 2001 1:44 PM
Subject: RE: thread problems?


> No I cant have a static variable - there could be more than one instance
of
> the bean each with a different number of values.
>
> -Original Message-
> From: Rama Krishna [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 16, 2001 1:42 PM
> To: [EMAIL PROTECTED]
> Subject: Re: thread problems?
>
>
> may be you can have some static variable pointing to the no. of values and
> check this before you construct your bean. if you think two threads access
> this to update this then it can be synchronized. this variable need not be
> in the same class.
>
>
>
>
> - Original Message -
> From: "Gogineni, Pratima" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, July 16, 2001 1:21 PM
> Subject: RE: thread problems?
>
>
> > I just put in an error message saying you are asking for something that
> > doesnt exist - I never really expected to see this scenario when I put
in
> > this message. The arrayIndexOutofBounds happens if I dont catch htis
case.
> >
> > Let me put it this way: I am displaying values 1-10 in a page. I post an
> > action that changes the number of values to be displayed to 5 so a new
> bean
> > with just five values is manufactured and put in the session - in the
> > meanwhile the second click is forwarded by the actionservlet through the
> > requestUtils to the BeanUtil to look for the accessors and mutators for
> > values 1-10 but we have now have only 5 values in the bean so this is an
> > error condition.
> >
> > The properties object sent to the BeanUtil seems to be sent from the old
> > form bean which had 10 values but the new form bean has only 5 values
> >
> > -Original Message-
> > From: David Winterfeldt [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, July 16, 2001 11:52 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: thread problems?
> >
> >
> > It sounds like you are throwing an Exception of some
> > sort from you ActionForm?  Is that right?  The
> > ActionForm should just be a container to hold the
> > values from the form.
> >
> > David
> >
> > --- "Gogineni, Pratima" <[EMAIL PROTECTED]>
> > wrote:
> > > Hi,
> > >
> > > I have been fighting with the following situation
> > > and would appreciate any
> > > ideas/suggestions.
> > >
> > > I have a session scoped form bean "FBean", a jsp
> > > page that displays it
> > > "dispFBean" & an action FBeanAction.
> > >
> > > I have inserted transactional tokens to take care of
> > > duplicate posting.
> > >
> > > After changing a value in dispFBean, an enter or/and
> > > a click work fine &
> > > they do the same thing ie. call FBeanAction.
> > >
> > > when the 2 events are done in rapid succession - one
> > > event executes fine
> > > while the other event throws an exception because it
> > > is trying to access
> > > row#5 where as the previous action changed the
> > > number of rows to 4.
> > > Unfortunately the transactional tokens cant take
> > > care of this since this
> > > error is being thrown in BeanUtils.populate before
> > > it ever reaches an
> > > FBeanAction instance.
> > >
> > > I also tried declaring the jsp page threadsafe to
> > > check if that is the
> > > problem.
> > >
> > > Also note that the FBeanAction replaces FBean with a
> > > new Instance of FBean.
> > >
> > > Thanks
> > > Pratima
> >
> >
> > __
> > Do You Yahoo!?
> > Get personalized email addresses from Yahoo! Mail
> > http://personal.mail.yahoo.com/
> >
>



RE: thread problems?

2001-07-16 Thread Gogineni, Pratima

No I cant have a static variable - there could be more than one instance of
the bean each with a different number of values.

-Original Message-
From: Rama Krishna [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 16, 2001 1:42 PM
To: [EMAIL PROTECTED]
Subject: Re: thread problems?


may be you can have some static variable pointing to the no. of values and
check this before you construct your bean. if you think two threads access
this to update this then it can be synchronized. this variable need not be
in the same class.




- Original Message -
From: "Gogineni, Pratima" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 16, 2001 1:21 PM
Subject: RE: thread problems?


> I just put in an error message saying you are asking for something that
> doesnt exist - I never really expected to see this scenario when I put in
> this message. The arrayIndexOutofBounds happens if I dont catch htis case.
>
> Let me put it this way: I am displaying values 1-10 in a page. I post an
> action that changes the number of values to be displayed to 5 so a new
bean
> with just five values is manufactured and put in the session - in the
> meanwhile the second click is forwarded by the actionservlet through the
> requestUtils to the BeanUtil to look for the accessors and mutators for
> values 1-10 but we have now have only 5 values in the bean so this is an
> error condition.
>
> The properties object sent to the BeanUtil seems to be sent from the old
> form bean which had 10 values but the new form bean has only 5 values
>
> -Original Message-
> From: David Winterfeldt [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 16, 2001 11:52 AM
> To: [EMAIL PROTECTED]
> Subject: Re: thread problems?
>
>
> It sounds like you are throwing an Exception of some
> sort from you ActionForm?  Is that right?  The
> ActionForm should just be a container to hold the
> values from the form.
>
> David
>
> --- "Gogineni, Pratima" <[EMAIL PROTECTED]>
> wrote:
> > Hi,
> >
> > I have been fighting with the following situation
> > and would appreciate any
> > ideas/suggestions.
> >
> > I have a session scoped form bean "FBean", a jsp
> > page that displays it
> > "dispFBean" & an action FBeanAction.
> >
> > I have inserted transactional tokens to take care of
> > duplicate posting.
> >
> > After changing a value in dispFBean, an enter or/and
> > a click work fine &
> > they do the same thing ie. call FBeanAction.
> >
> > when the 2 events are done in rapid succession - one
> > event executes fine
> > while the other event throws an exception because it
> > is trying to access
> > row#5 where as the previous action changed the
> > number of rows to 4.
> > Unfortunately the transactional tokens cant take
> > care of this since this
> > error is being thrown in BeanUtils.populate before
> > it ever reaches an
> > FBeanAction instance.
> >
> > I also tried declaring the jsp page threadsafe to
> > check if that is the
> > problem.
> >
> > Also note that the FBeanAction replaces FBean with a
> > new Instance of FBean.
> >
> > Thanks
> > Pratima
>
>
> __
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
>



Re: thread problems?

2001-07-16 Thread Rama Krishna

may be you can have some static variable pointing to the no. of values and
check this before you construct your bean. if you think two threads access
this to update this then it can be synchronized. this variable need not be
in the same class.




- Original Message -
From: "Gogineni, Pratima" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 16, 2001 1:21 PM
Subject: RE: thread problems?


> I just put in an error message saying you are asking for something that
> doesnt exist - I never really expected to see this scenario when I put in
> this message. The arrayIndexOutofBounds happens if I dont catch htis case.
>
> Let me put it this way: I am displaying values 1-10 in a page. I post an
> action that changes the number of values to be displayed to 5 so a new
bean
> with just five values is manufactured and put in the session - in the
> meanwhile the second click is forwarded by the actionservlet through the
> requestUtils to the BeanUtil to look for the accessors and mutators for
> values 1-10 but we have now have only 5 values in the bean so this is an
> error condition.
>
> The properties object sent to the BeanUtil seems to be sent from the old
> form bean which had 10 values but the new form bean has only 5 values
>
> -Original Message-
> From: David Winterfeldt [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 16, 2001 11:52 AM
> To: [EMAIL PROTECTED]
> Subject: Re: thread problems?
>
>
> It sounds like you are throwing an Exception of some
> sort from you ActionForm?  Is that right?  The
> ActionForm should just be a container to hold the
> values from the form.
>
> David
>
> --- "Gogineni, Pratima" <[EMAIL PROTECTED]>
> wrote:
> > Hi,
> >
> > I have been fighting with the following situation
> > and would appreciate any
> > ideas/suggestions.
> >
> > I have a session scoped form bean "FBean", a jsp
> > page that displays it
> > "dispFBean" & an action FBeanAction.
> >
> > I have inserted transactional tokens to take care of
> > duplicate posting.
> >
> > After changing a value in dispFBean, an enter or/and
> > a click work fine &
> > they do the same thing ie. call FBeanAction.
> >
> > when the 2 events are done in rapid succession - one
> > event executes fine
> > while the other event throws an exception because it
> > is trying to access
> > row#5 where as the previous action changed the
> > number of rows to 4.
> > Unfortunately the transactional tokens cant take
> > care of this since this
> > error is being thrown in BeanUtils.populate before
> > it ever reaches an
> > FBeanAction instance.
> >
> > I also tried declaring the jsp page threadsafe to
> > check if that is the
> > problem.
> >
> > Also note that the FBeanAction replaces FBean with a
> > new Instance of FBean.
> >
> > Thanks
> > Pratima
>
>
> __
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
>



RE: thread problems?

2001-07-16 Thread Gogineni, Pratima

Hi,

Thanks for your reply - but there doesnt seem to be a lock. The problem is
that the actionservlet is getting a request based on an old form bean but in
the meantime a new form bean is put into the session.

Also I decided to check if declaring the page thread safe (singlethreaded)
would solve the problem, it doesnt.

Pratima

-Original Message-
From: Pathangi, Rao H. [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 16, 2001 12:30 PM
To: '[EMAIL PROTECTED]'
Subject: RE: thread problems?


I have been through this before. Its more like 2 client requests in
succession/ The session seems to be locked at some point in time and the
other request keeps on waiting for ever. Once I made the underlying servlet
implement single thread model it went away. Iam not sure about it in a
struts environment but this is a well known case. 

But experts advise against single thread model usage(A different topic
anyway..)

The Jguru page had the same problem in the very beginning (They use jsp's).
But they somehow unlocked the session  and made it attend the second request
too. As a consequence every bit  of jsp content appeared twice on the page.

later
pathangi r



-Original Message-
From: Gogineni, Pratima [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 16, 2001 1:44 PM
To: '[EMAIL PROTECTED]'
Subject: thread problems?


Hi,

I have been fighting with the following situation and would appreciate any
ideas/suggestions.

I have a session scoped form bean "FBean", a jsp page that displays it
"dispFBean" & an action FBeanAction.

I have inserted transactional tokens to take care of duplicate posting. 

After changing a value in dispFBean, an enter or/and a click work fine &
they do the same thing ie. call FBeanAction.

when the 2 events are done in rapid succession - one event executes fine
while the other event throws an exception because it is trying to access
row#5 where as the previous action changed the number of rows to 4.
Unfortunately the transactional tokens cant take care of this since this
error is being thrown in BeanUtils.populate before it ever reaches an
FBeanAction instance.

I also tried declaring the jsp page threadsafe to check if that is the
problem. 

Also note that the FBeanAction replaces FBean with a new Instance of FBean.

Thanks
Pratima



RE: thread problems?

2001-07-16 Thread Gogineni, Pratima

I just put in an error message saying you are asking for something that
doesnt exist - I never really expected to see this scenario when I put in
this message. The arrayIndexOutofBounds happens if I dont catch htis case. 

Let me put it this way: I am displaying values 1-10 in a page. I post an
action that changes the number of values to be displayed to 5 so a new bean
with just five values is manufactured and put in the session - in the
meanwhile the second click is forwarded by the actionservlet through the
requestUtils to the BeanUtil to look for the accessors and mutators for
values 1-10 but we have now have only 5 values in the bean so this is an
error condition. 

The properties object sent to the BeanUtil seems to be sent from the old
form bean which had 10 values but the new form bean has only 5 values

-Original Message-
From: David Winterfeldt [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 16, 2001 11:52 AM
To: [EMAIL PROTECTED]
Subject: Re: thread problems?


It sounds like you are throwing an Exception of some
sort from you ActionForm?  Is that right?  The
ActionForm should just be a container to hold the
values from the form.

David

--- "Gogineni, Pratima" <[EMAIL PROTECTED]>
wrote:
> Hi,
> 
> I have been fighting with the following situation
> and would appreciate any
> ideas/suggestions.
> 
> I have a session scoped form bean "FBean", a jsp
> page that displays it
> "dispFBean" & an action FBeanAction.
> 
> I have inserted transactional tokens to take care of
> duplicate posting. 
> 
> After changing a value in dispFBean, an enter or/and
> a click work fine &
> they do the same thing ie. call FBeanAction.
> 
> when the 2 events are done in rapid succession - one
> event executes fine
> while the other event throws an exception because it
> is trying to access
> row#5 where as the previous action changed the
> number of rows to 4.
> Unfortunately the transactional tokens cant take
> care of this since this
> error is being thrown in BeanUtils.populate before
> it ever reaches an
> FBeanAction instance.
> 
> I also tried declaring the jsp page threadsafe to
> check if that is the
> problem. 
> 
> Also note that the FBeanAction replaces FBean with a
> new Instance of FBean.
> 
> Thanks
> Pratima


__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



RE: thread problems?

2001-07-16 Thread Pathangi, Rao H.

I have been through this before. Its more like 2 client requests in
succession/ The session seems to be locked at some point in time and the
other request keeps on waiting for ever. Once I made the underlying servlet
implement single thread model it went away. Iam not sure about it in a
struts environment but this is a well known case. 

But experts advise against single thread model usage(A different topic
anyway..)

The Jguru page had the same problem in the very beginning (They use jsp's).
But they somehow unlocked the session  and made it attend the second request
too. As a consequence every bit  of jsp content appeared twice on the page.

later
pathangi r



-Original Message-
From: Gogineni, Pratima [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 16, 2001 1:44 PM
To: '[EMAIL PROTECTED]'
Subject: thread problems?


Hi,

I have been fighting with the following situation and would appreciate any
ideas/suggestions.

I have a session scoped form bean "FBean", a jsp page that displays it
"dispFBean" & an action FBeanAction.

I have inserted transactional tokens to take care of duplicate posting. 

After changing a value in dispFBean, an enter or/and a click work fine &
they do the same thing ie. call FBeanAction.

when the 2 events are done in rapid succession - one event executes fine
while the other event throws an exception because it is trying to access
row#5 where as the previous action changed the number of rows to 4.
Unfortunately the transactional tokens cant take care of this since this
error is being thrown in BeanUtils.populate before it ever reaches an
FBeanAction instance.

I also tried declaring the jsp page threadsafe to check if that is the
problem. 

Also note that the FBeanAction replaces FBean with a new Instance of FBean.

Thanks
Pratima



Re: thread problems?

2001-07-16 Thread David Winterfeldt

It sounds like you are throwing an Exception of some
sort from you ActionForm?  Is that right?  The
ActionForm should just be a container to hold the
values from the form.

David

--- "Gogineni, Pratima" <[EMAIL PROTECTED]>
wrote:
> Hi,
> 
> I have been fighting with the following situation
> and would appreciate any
> ideas/suggestions.
> 
> I have a session scoped form bean "FBean", a jsp
> page that displays it
> "dispFBean" & an action FBeanAction.
> 
> I have inserted transactional tokens to take care of
> duplicate posting. 
> 
> After changing a value in dispFBean, an enter or/and
> a click work fine &
> they do the same thing ie. call FBeanAction.
> 
> when the 2 events are done in rapid succession - one
> event executes fine
> while the other event throws an exception because it
> is trying to access
> row#5 where as the previous action changed the
> number of rows to 4.
> Unfortunately the transactional tokens cant take
> care of this since this
> error is being thrown in BeanUtils.populate before
> it ever reaches an
> FBeanAction instance.
> 
> I also tried declaring the jsp page threadsafe to
> check if that is the
> problem. 
> 
> Also note that the FBeanAction replaces FBean with a
> new Instance of FBean.
> 
> Thanks
> Pratima


__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



thread problems?

2001-07-16 Thread Gogineni, Pratima

Hi,

I have been fighting with the following situation and would appreciate any
ideas/suggestions.

I have a session scoped form bean "FBean", a jsp page that displays it
"dispFBean" & an action FBeanAction.

I have inserted transactional tokens to take care of duplicate posting. 

After changing a value in dispFBean, an enter or/and a click work fine &
they do the same thing ie. call FBeanAction.

when the 2 events are done in rapid succession - one event executes fine
while the other event throws an exception because it is trying to access
row#5 where as the previous action changed the number of rows to 4.
Unfortunately the transactional tokens cant take care of this since this
error is being thrown in BeanUtils.populate before it ever reaches an
FBeanAction instance.

I also tried declaring the jsp page threadsafe to check if that is the
problem. 

Also note that the FBeanAction replaces FBean with a new Instance of FBean.

Thanks
Pratima