Hi,

Thanks Craig. I got that. 

But I had some more issues. 

I downloaded the code from the given link
http://www.javaworld.com/javatips/jw-javatip136_p.html and deployed in
my server.
If I submit a page and then refresh it, it works as mentioned in the
document 

But while submitting if I click 2-3 times with quick succession it
throws a blank change.

If in the code of SynchroAction.java I replace the line
synchronized(session.getId()) with synchronized(session), it works fine.
Even if I click multiple times the page comes up. 
But in the comments of the code its written not to synchronize on
session as it is not guaranteed to be the same object on each request.
What exactly is the issue and what has to done for that?.

Another problem is when I use this code. If I click stop button after
submitting the page and then submit the form again. It shows me the
result corresponding to the data submitted before clicking stop.
How to handle this condition?

Thanks and Regards,
Kamakshya

-----Original Message-----
From: Craig R. McClanahan [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 05, 2004 3:36 PM
To: Struts Users Mailing List
Subject: Re: TokenProcesor and synchronization

Prasad, Kamakshya wrote:

>Hi,
>
>It might be a silly question... but curiosity...
>
>Why we need to synchronize at all? Each user session will be unique in
the server and so the extracted variables from that session.
>
>KP
>  
>
It's not a silly question ... this is an issue that *lots* of people 
don't understand.

It is trivially easy for a single user (inside a single session) to 
submit multiple simultaneous requests.  How, you might ask?  Here's just

a few of the possibilities:

* User submits a form, presses STOP, and submits the form again.

* User requests a page that has one or more <img> or <object>
  elements with URLs pointing in to the same webapp -- most browers
  will perform multiple simultaneous requests to retrieve the necessary
  data.

* User requests a frameset page ... the browser will typically perform
  simultaneous requests for the individual frames.

The net result is that application developers *must* assume that thread 
safety is an issue for access to session scope attributes, and must 
employ synchornization as needed to avoid problems.  Note that it's not 
an issue of whether the HttpSession.getAttribute() call is safe -- the 
servlet container takes care to ensure that this is always OK -- it's an

issue of what accesses you do on the attribute after retrieving it that 
matter.

Craig McClanahan



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


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

Reply via email to