synchronization Multiuser system

I have a problm that i am creating multi user system. On my JSP form i am showing autogenerated code to the user. but if i am loging as different user then same code is displaying. So i have to syschronized my code.How i proceed?
[236 byte] By [anshul_malpania] at [2007-10-3 1:58:50]
# 1

That would depend on how you are generating said code. If you do it with some method, then you can synchronize that method.

private int code = 0;

public synchronized int getCode()

{

return ++code;

}

But then you have to make absolutely sure that this method is the ONLY way you fetch the code.

gimbal2a at 2007-7-14 18:57:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...