title: Java text modification on JSP
body: <p>I have a form on my .jsp page which sends a password back to the server.</p>
  
  <pre><code>&lt;form name="login" action="j_security_check" method="post"&gt;
      &lt;input type="text" name="j_username"&gt;
      &lt;input type="password" name="j_password"&gt;
      &lt;input type="submit" name="Login"&gt; &lt;/form&gt;
  </code></pre>
  
  <p>I would like to do some processing on the j_password before processing it.
  Previously, I managed to do this by implementing a JavaScript through some processing codes by calling on a function that performs something similar to below:</p>
  
  <pre><code>&lt;script type="text/javascript" src="sha256.js"&gt;
  &lt;script&gt; function hash() { document.login.j_password.value = '@' +
      sha256_digest(document.login.j_password.value); } &lt;/script&gt;
  ...
  ...
      &lt;input type="submit" value="Login" onClick="hash()"&gt; &lt;/form&gt;
  </code></pre>
  
  <p>Now, I am trying to implement a similar feature but instead of using JavaScript, I am trying to use Java. The main aim of my .java is to load a public.key, take the j_password, perform encryption, and replacing the j_password with its encrypted form.</p>
  
  <pre><code>// RSA.java Pseudocode
  1) Get string from textbox "j_password"
  2) Load public key from public.key
  3) Perform encryption on j_password with key
  4) Load cipher to textbox "j_password"
  </code></pre>
  
  <p>However, most examples I see implement a "&lt;% %>" calling but this gives me an impression that it would perform on page load, rather than on clicking the login button. I also noticed I could compile it as a .class with javac and load it as an "" but can this method be used to modify the input of j_password? While it is a .jsp and I can implement Java directly with "&lt;% %>", I don't think it is acceptable in current JSP standards. Does anyone have any recommendations or ideas to point me in the right direction?</p>
  
  <p>Thank you.</p>