PDF-Forms is a service provided by PDFzone.com | http://www.pdfzone.com/
__________________________________________________________________
Richard,
The example I gave was overly simplistic in order to illustrate the problem
I was having.
I actually AM using a database to sequence the numbers to solve the multiple
user problem. But the database contains a list of valid numbers and am
keeping track which ones are used so there is a limit to the size of the
pool of numbers.
So while this does work, it grabs two numbers for each request - not the
worst fate on earth but not a clean solution.
I have to believe that there has got to be a solution but it escapes me.
Pete
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Richard Lynch
Sent: Monday, February 02, 2004 3:45 PM
To: [EMAIL PROTECTED]
Subject: Re: [PDF-Forms] IE6 / ASP / Acrobat 6
PDF-Forms is a service provided by PDFzone.com | http://www.pdfzone.com/
__________________________________________________________________
So here is an interesting puzzleŠ
I have an ASP page that increments a sequence number (by updating a
value in a text file) and returns the result in a form field. The
code works except for a major problem - the sequence number is being
incremented twice. So I'm seeing a sequence number of 1,3, 5, etc.
What, if anything, are you doing to insure that TWO surfers hitting
your page at exactly the same time don't both try to read the SAME
number from the file, and then write the same number to the file,
which will A) give two forms the same ID and B) probably completely
trash the file.
This is known as a "race condition" and it's why you shouldn't be
doing it this way. Tie your application to a database and use an SQL
statement to increment a SEQUENCE. Or if your database is too broken
to have sequences, create a silly little table with just an ID field
and do an INSERT and then retrieve the ID from that insert.
Exactly HOW you retrieve that ID changes from database package to
database package, but there is always a way to guarantee uniqueness
and that you've got the right ID.
The database gurus spent a lot of time getting this right. Don't try
to re-invent the wheel.
I can guarantee that unless you have a very special situation or some
external business logic that forces only ONE surfer at a time to be
getting an ID number that sooner or later you will get big if you
keep your current plan.
The code is correct because if I remove the
Response.ContentType = "application/vnd.fdf"
then I can see the raw FDF and it increments correctly. So it somehow
seems as if the ASP routine is being called twice if Acrobat is in
the picture. FDF toolkit is not in the picture because I am
generating my own FDF from scratch (and it is correct because the
form, with the form field data, is being brought up).
What is even more interesting is that Mozilla 1.6 works correctly and
the sequence number increments the way it should.
There is NOTHING you can do to stop Internet Exploder from accessing
the same URL as many times as it feels the need to while fetching
your document.
You could, perhaps, detect the user's browser, and if it was IE, send
them a unique COOKIE along with their ID, and if they come back
within X seconds just give them the same ID you just gave them,
rather than a new one.
Or you could just now worry about it, and deal with the fact that
some numbers will be skipped.
You probably have to do this anyway, as sooner or later some browser
crash will cause an unused ID number.
The ASP page is being invoked by directly calling it directly (i.e.
<http://localhost/TestSeqnum.asp>http://localhost/TestSeqnum.asp) in
the html. Environment is Windows XP Pro SP1 and Acrobat 6.0.1.
--
Like Music?
http://l-i-e.com/artists.htm
To change your subscription:
http://www.pdfzone.com/discussions/lists-pdfforms.html
To change your subscription:
http://www.pdfzone.com/discussions/lists-pdfforms.html