• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Auto generate link for newly registered user

 
Ranch Hand
Posts: 129
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am a beginner for web technology, developing one small web application.

How to generate a link to send to the user's mail, to use it to activate his/her account.

I have seen some links like: http://[Domain Name]/user/[user-id]/activate/[some 32 characters hash code]

please help..

 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



Hope that helps.
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ramnna, welcome to javaranch !

I can't give you the complete code but I can give you some hints. First of all in your database, there must be an additional column in the user table. The column will be a bit (or you can say boolean) column which will represent if the user's account is activated or not. When a user registers, his/her account will be deactivated (i.e. the column will have a value false or 0). You must also send an email to the user which should contain a link of this form

http://[Domain Name]/user/activate/[encrypted user-id]

You must also create a servlet which maps to /user/activate/* which will do the work of activating the user's account. When the user clicks on the link in the email, he/she will be taken to that servlet which will decrypt the user-id, set the activated column's value to true (or 1). After that the activation servlet must redirect the user to his/her home page...

(edit: added welcome message)
 
ramnna jain
Ranch Hand
Posts: 129
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to both of you Ankit & Ryan for your kind help.

Ankit! I need to map this url(user/activate/*) in web.xml. Here my servlet class will use [encrypted user id], but how to get this encrypted code out of this link. Is there any way!


ref. link: http://[Domain Name]/user/activate/[encrypted user-id]

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out the HttpServletRequest.getPathExtraInfo (or some such) method. It returns that part of the URL.
 
Ankit Garg
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ulf its HttpServletRequest.getPathInfo() ...
 
ramnna jain
Ranch Hand
Posts: 129
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using this link: http://localhost:8080/AddressBook/something/12345678

Made changes in my web.xml:








Result: HTTP Status 404 - /AddressBook/something/12345678


please help...
 
Ankit Garg
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are two problems with your code ramnna.

1. you have overridden doPost method and no doGet. So you can't access the servlet by entering a URL in the browser.

2. You have used System.out.println to output your message. This will not get sent to the browser. Instead usually this will go to the console of the servlet container.

A correct code would be

 
ramnna jain
Ranch Hand
Posts: 129
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I made some changes in my code & now it is done successfully ....

Thank you ... Ryan, Ankit, Ulf for your kind & prompt help.... thank you!


 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does doPost() really need to be implemented? You can just leave that away.
 
ramnna jain
Ranch Hand
Posts: 129
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes! right Get is idempotent, means not supposed to change any thing on the server.
 
These are the worst of times and these are the best of times. And this is the best tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic