Urgent>> How to generate a random code such as registration code?

I would like to ask that how to generate a random code?For example, when you register a E-mail account, you need to enter the code for activation. I would like to create a java Bean to do this job. Would you help me?
[230 byte] By [Eddie@HongKonga] at [2007-11-26 17:40:43]
# 1
Typically for so-called urgent posts, you left off some of your requirements. Just because you think it's urgent, that doesn't excuse you from thinking about the problem.Like for example, what's a "code"? A number? A string of some length?
DrClapa at 2007-7-9 0:08:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Also, please break down your task into smaller tasks, and ask specific questions.

What part of the code do you need?

Do you need to know how to create a JavaBean?

Do you need the JSTL code to interact with a JavaBean?

If you search on your favorite search engine for

"Random Password Generation Java" , you'll see some sample code on how to generate a code at random.

To create a JavaBean you will need to create a class, with variables and getter and setter methods for those variable and a public constructor.

Inside the getter method add code to generate a random code.

Message was edited by:

appy77

appy77a at 2007-7-9 0:08:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

In fact, I would like to set a 10 digi codes randomly (such as FH654CS081, MKO624VG9f) for user input when they register the forum account. This random code will be sent to the user's email. User have to input this code to a JSP web site. Also, the code which is inputed by user will be matched with the database. If user input success, the forum account will be activated.

By generating this 10 digi codes, I want to handle this generation by using java bean.

1) Any thing else i need to import ? (such as <% page import="java.......?")

2) Any functions can handle this task?

3) Any example can be my reference?

Thank you very much

Eddie@HongKonga at 2007-7-9 0:08:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
To generate random code look at the source code for this Java Applet: http://mindprod.com/applets/password.htmlhere's another example: http://bobcat.webappcabaret.net/javachina/jc/share/PwGen.htmMessage was edited by: appy77
appy77a at 2007-7-9 0:08:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...