prashant chindhade wrote:put this is Regestration servlet. and call it when you want to get id.
Prashant, I'm sure you're trying to be helpful, but please DontBeACodeMill (←click).
Also, your method (even corrected) mystifies me:
1. Why create a new Random object for each invocation? Completely unnecessary.
2. Why loop 10 times?
1. If this ID is related to a database table, then I would strongly urge you to use a sequence number obtained from the DB itself.
2. If not, there are a couple of Java classes for obtaining unique (or near-unique) IDs: java.rmi.server.UID and java.util.UUID. I suggest you also look at them before ploughing ahead too soon.
Isn't it funny how there's always time and money enough to do it WRONG?