Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
So, you are saying generate the Token inside the SendMailServlet (and save to database) and then append it like this:
Should I use a ServletFilter instead of Servlet?
Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
user.setConfirmed(false);
.http://locahost:8080/myapp/confirm?token= Your token value
user.setConfirmed(true);
Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
1. Why do I need RegiServlet? Why can't I set just the user.setConfirmed(false); inside my SendMailServlet?
2. What does the code look like in the doPost() or doGet() methods of the ConfirmServlet?
3. How can I send the confirm parameter (located in the URI) to my ConfirmServlet?
4. Will I need to set session attribute to user in SendMailServlet or RegiServlet and then get the session attribute from the ConfirmServlet?
Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
I give you reason why.
My ConfirmServlet:
view plaincopy to clipboardprint?
1. public class ConfirmServlet extends HttpServlet {
2. public void doGet(HttpServletRequest request, HttpServletResponse response) {
3. response.setContentType("text/html");
4. String key = "token";
5. String mailToken = request.getParameter(key);
6. User user = new User();
7. user.setUsername("John Doe");
8. user.setPassword("pizza");
9. user.setEmailAddress("john@gmail.com");
10. user.setConfirmed(false);
11.
12. Confirm confirm = new Confirm();
13. confirm.setUser(user);
14. confirm.setMailToken(mailToken);
15. user.setConfirm(confirm);
16. user.setConfirmed(true);
17. System.out.println("Mail Token: " + mailToken);
18.
19. // Print confirmed to screen
20. // Save Hibernate Session
21. }
22.
23. public void doPost(HttpServletRequest request, HttpServletResponse response) {
24. doGet(request, response);
25. }
26.
27. }
Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
https://localhost:8443/confirm?token=" + mailToken
Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
Now when user click on your url you get that key which is unique. Now just select user which contains that key.... So, first store token into user table and then select user with that token. Now just update confirm field for that user and update user table with new data.
I love a woman who dresses in stainless steel ... and carries tiny ads:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|