2

I'm not able to figure out how to send a confirmation link to anyone's email, who signs up on my JSP site. As soon as he clicks the link his profile should get activated. This is used by many site these days. Any help guys?

Roman C
  • 49,761
  • 33
  • 66
  • 176
Somye
  • 87
  • 5
  • 11

1 Answers1

4

Somye, this is not so difficult. Search on google, and you will find plenty of solutions waiting for you.

Split your problem in to parts.

1. Sending email
2. Read activation data

Part 1, about how to send an email. E.g. read here: Sending Email using JSP

Part 2,

in your email, add something like http://your-site.com/activate.jsp?u=< userid >&code=< some code >

When user gets the email (as described in part1), and now clicks the link. He will visit the activate.jsp page.

On that page, you take the information they sent and match it with what you have stored. For example you do a lookup of the userid and a code. In this way you are pretty sure the user must click the link to get the account activated.

Hope this helps you more in your way for solving this parts.

MrSimpleMind
  • 7,890
  • 3
  • 40
  • 45
  • i'd like to ask you 1 thing MrSimpleMind that is it safer to send a verification code in his email rather than sending a link?? – Somye Mar 31 '13 at 10:21
  • 1
    Both do the same, I like links as you dont need to enter something. Just a click. If you are concerned about security I would put more focus on how to create the codes... you could add parameters to increase the security, make it harder to guess for bots. E.g. add the user-email, and the user-unique-id and a hash in the url. It is all dependent on you requirement. – MrSimpleMind Mar 31 '13 at 10:24
  • you are welcome, there is another thread about how to generate an activation string (though in php) you can read it here http://stackoverflow.com/questions/876139/how-to-generate-a-secure-activation-string-in-php – MrSimpleMind Mar 31 '13 at 10:31