Among other tools you can use "java mail" package to send emails direclty from your application. Here's the link to API docs Java Mail API
So the scenario could be like the following:
- User account is created. It's in unconfirmed state now;
- You generate a unique confirmation ID to your applicaiton. The easiest way is to use java.util.UUID.randomUUID().toString(). UUID is a random globally unique value.;
- You store the ID (e.g. 0123)+account to the database for future use;
- Send the URL+ID (http://yourapp.com/confirm?id=0123) as an email using javamail to the user;
- Do not show the ID in browser now;
- The user checks inbox and see your letter;
- The user clicks the link and request is sent to your site confirmaion servlet;
- Confirmation servlet will search for the account associated with the specified confirmation id;
- Confirmaion servlet set account to "confirmed state" as obvously the user has access to the specified mail box