This week's giveaway is in the Java/Jakarta EE forum.
We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line!

Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what you seem to by trying to do is include javaScript, which runs on the client, inside a java Scriptlet, which runs on the server. No way is this going to work!

The process you have to follow is:
  • create a jsp or even just a plain html document with a <form> tag and an action attribute pointing to the jsp containing your JDBC logic.
  • The JSP with the <form> tag must also have a password field and a submit button. The Jsp with the JDBC logic will be called when the user presses the submit button.
  • Somewhere in your second JSP (The one with the JDBC logic) you should put the statement: "String newPassword = request.getParameter("NewPassword");" This statement retrieves the value passed on by the previous form.
  • use the variable newPassword when building your SQL statement.

  • If you want, both the form JSP and the JDBC jsp can be the same document, but you will have to include logic to determine what state you are in. Am I in the state where the user first brings up the page? or am I in the state where the user has already submitted the page and needs a confirmation that the change worked? Hint: If request.getParameter("NewPassword") returns null, you are in the first state.

    I hope this helps.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!