Hi All, I am having a servlet page, in that I need to generate the number in sequence and again which needs to be unique. This number is like order number and I do not want them to be duplicated. Can any one suggest me how to proceed or Is there any site that has the help for this(like web counter). Looking forward for the reply.
Aleks V. Pascoal
Joined: Apr 21, 2002
It depends on what ever you want to do with it. You can set an attribute and increment it by listeneres...but the ideal is to put it on a database or in a file. Aleks
Joined: Apr 18, 2002
Hi Aleks, Thanks for the reply. As I am not allowed to use the database and at the same time if I keep the value in the file then I need to take other precaution that when one process reading the file I should not allow the other process to access the file till I increment the value in the file. Is there any way to do that, or can you suggest me some other option. Thanks in Advance, Vasu.
"Aleks", Your name still does not comply to the JavaRanch naming convention, described at http://www.javaranch.com/name.jsp. We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please edit your profile and select a new name which meets the requirements. Thanks. Dave
Joined: Jun 05, 2002
Hi Vasu, If u want to go with file option and u want only one thread accessing the code at a time then place the file reading part of code in a synchronized block.