• Post Reply Bookmark Topic Watch Topic
  • New Topic

Code to generate Unique ID in web application  RSS feed

 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am newbie to web application. In j2ee web application how to Generate Unique ID, By using UUID class in utill package or some other classes available for this.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, using the unique ID stuff would do it (that's why they call it that ;)

Why do you *need* to do it?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the Unique ID only has to be used during a single session, why not use the built in javax.servlet.http.HttpSession mechanism?

On the other hand if this Unique ID will have to endure over a long time you need another mechanism so the key question is - how long will this ID be in service?

Bill
 
Alpesh Padra
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use session id and use hashing algorithm for that.
 
Devaka Cooray
Marshal
Posts: 5325
575
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Love Java", please check your private messages regarding an important administrative matter.
 
Pallav Bora
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess if that unique ID is going to be used across sessions, across users , across clusters etc then some central mechanism should be used , like a db sequence or a pinned EJB (EJB that has only one instance and deployed on only one server)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!