This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help on web counter...

 
vasu devan
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
vasu devan
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
sim sim
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic