• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Forgot Password returns null mail while entering in the textarea.

 
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No No. I guess in the following code i have to save the record. didn't modified code here. Its same like registration page



The following is forgotpassworddao.java



The following is forgotpasswordservlet.java

 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My fault. And now i receive the mail while requesting for password reset.



So now this works. After this what should i do? I have to validate the link by entering the tokenid in database. Am i right. If so at the mail sending part itself i have to enter the details?
 
Master Rancher
Posts: 2249
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mail sending part will just mail the link.  When the link is clicked, you should have a servlet that will retrieve the tokenid and validate.
 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What that means? Do i need to create one more servlet.java and have to insert the tokenid then i need to verify?
 
Swastik Dey
Master Rancher
Posts: 2249
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are confusing yourself.  

Step1 .  User registers you have a servlet that saves the record in users table and send a confirmation mail to the user with a login link (So this mail will have just the login link no need for any tokenid)

Step2   User clicks on forget password. You show a html/jsp page to take the email id as input.  This goes to a servlet where you create the resetlink with tokenid and send the mail  and save the record in the other table where you have tokenid field.

Step3  User clicks on the link sent to him/her in the email.  The request comes to another servlet where you retrieve the tokenid and do necessary validation and perform desired task.
 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Swastik Dey wrote:You are confusing yourself.  

Step1 .  User registers you have a servlet that saves the record in users table and send a confirmation mail to the user with a login link (So this mail will have just the login link no need for any tokenid)

Step2   User clicks on forget password. You show a html/jsp page to take the email id as input.  This goes to a servlet where you create the resetlink with tokenid and send the mail  and save the record in the other table where you have tokenid field.

Step3  User clicks on the link sent to him/her in the email.  The request comes to another servlet where you retrieve the tokenid and do necessary validation and perform desired task.



Fitst 2 steps I undersatand. But in second step say I have sendmail.java for sending mails with the resetlink along with tokenid, I have to save the record there itself? Means while sending the mail say sendingmail.java i need to insert the record in db. The following code i have pasted is it like this.?



step 3. I should keep another java file to retrieve the tokenid and display the reset password.jsp page. Am i correct. But how will i retrieve the tokenid?
 
Swastik Dey
Master Rancher
Posts: 2249
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Gayathri Gayu wrote:[ But how will i retrieve the tokenid?



 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fitst 2 steps I undersatand. But in second step say I have sendmail.java for sending mails with the resetlink along with tokenid, I have to save the record there itself? Means while sending the mail say sendingmail.java i need to insert the record in db. The following code i have pasted is it like this.?

Is this correct?
 
Swastik Dey
Master Rancher
Posts: 2249
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes i think. You can use my mailid let me see how the link looks.
 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok then first let me try that and let you know. And even then i got errors or i have doubts I will ask your help.

step 3. I should keep another java file to retrieve the tokenid and display the reset password.jsp page. Am i correct.

this one?
 
Swastik Dey
Master Rancher
Posts: 2249
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes
 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The above code is how i am trying to insert the token_id and email in database. But i don't know how will retrieve the email address on button click from ForgotPasswordDao.java in Sendmail.java. So that the token and email will be inserted in the separate table.
 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prints haicom.mysql.jdbc.JDBC4PreparedStatement@5b933bbc: SELECT * FROM userpwd where email=** NOT SPECIFIED **
 
Swastik Dey
Master Rancher
Posts: 2249
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As the code has the above statement, Do I need to create a bean file something like the following?
 
Swastik Dey
Master Rancher
Posts: 2249
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think so, you are passing the user(emailid) to this send mail method.  Though I missed one line

 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to initialize the string right. ? So what value will I give to these two?
 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because the statement throws the error. The method setString(int, String) in the type PreparedStatement is not applicable for the arguments (int, UUID)
 
Swastik Dey
Master Rancher
Posts: 2249
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also even now the output for executed query is SELECT * FROM Users where email=** NOT SPECIFIED ** The email id is not getting from the forgot password page.
 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Swastik Dey
Master Rancher
Posts: 2249
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which class is calling the method, show that code.
 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I gave the mailid directly. But I don't want to give it directly.  Have uncommented the statement and now the mailid is printing. But its not getting in if condition.

Where I am calling the send mail.
 
Swastik Dey
Master Rancher
Posts: 2249
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Does the above prints the value or is it printing blank?
 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its printing mailid, as i had
mentioned here. Earlier it was blank
 
Swastik Dey
Master Rancher
Posts: 2249
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't understand my question



If you retrieve as parameter does it print the value or blank?
 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In sendmail.java when i tried giving I got he error request cannot be resolved So I gave the id directly.
 
Swastik Dey
Master Rancher
Posts: 2249
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is in servlet class



Once you receive this you pass this to sendmail.

My question if you print the value in servlet does it print the value or blank.
 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Entire code of SendMail.java at this line i am getting error. So Servlet class code too the line was there. And when i Submit the forgot password button it returns blank
 
Swastik Dey
Master Rancher
Posts: 2249
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are not getting my point.




You can't have statement in SendMail class. This code is in the servlet class, and in servlet class after this statement if you print

 //what does this print?
 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The mail id is getting printed. with the error.
 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

At the insertion I am getting sql error.

java.sql.SQLException: No value specified for parameter 2gayathri13990@gmail.com

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2176)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1993)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922)
at com.gayathri.SendMail.send(SendMail.java:66)
at com.mvc.controller.RegisterServlet.processResetpasswordRequest(RegisterServlet.java:122)
at com.mvc.controller.RegisterServlet.doPost(RegisterServlet.java:42)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:808)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

 
Sheriff
Posts: 24754
59
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, yeah.



You specified a value for parameter 1 twice and didn't specify a value for parameter 2.
 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:Well, yeah.



You specified a value for parameter 1 twice and didn't specify a value for parameter 2.



Thanks for the reply. I changed the value now its inserted to database. Now how will i validate the link?
 
Swastik Dey
Master Rancher
Posts: 2249
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I told you before how you will validate the link.  I am telling once again.  In PasswordResetServlet retrieve the tokenId.




Now validate this tokenId from the table exists or not.  Though the question is what exactly you want to validate, because as you are sending and saving the same tokenid, it will always exist in database and match, only thing you have to retrieve the email/userid corresponding to this tokenid.
 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was going through your old post and tried validating the link the way you told. But the tokenId was returning null value. That's why asked again.

 
Swastik Dey
Master Rancher
Posts: 2249
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean when you click in the link in mail and retrieve tokenid in PasswordResetServlet you are getting tokenid as null?
 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes the above code is PasswordResetServlet code which prints the token id as null.
 
Swastik Dey
Master Rancher
Posts: 2249
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And this servlet is invoked when you click the link in mail?  If possible paste the complete code of passwordresetservlet.
 
Gayathri Gayu
Ranch Foreman
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Means?
 
Have you no shame? Have you no decency? Have you no tiny ad?
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!