• Post Reply Bookmark Topic Watch Topic
  • New Topic

how create a new method in JSP file?

 
Sebastian Urbank
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i am a newbie in jsp.

i have some jsps for create new user(names&passwords)
these are saved in a database (mysql).
for more details look here
here
http://javaknowledge.info/login-and-registration-example-in-jsp-with-session/

but passwords are saved withoud an encryption.
i want to save them with md5-encryption...
in internet i found a "method"?



but when i write that in my jsp-file then there show up
errors like these

An error occurred at line: 5 in the jsp file: /registration.jsp
MessageDigest cannot be resolved to a type
2:
3: <%!
4: private String createHash(String text){
5: MessageDigest md5;
6: StringBuffer sb = new StringBuffer();
7: try {

method for string-md5-encyption
example web-app for create new users and save it to database (mysql)
 
K. Tsang
Bartender
Posts: 3610
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

You shouldn't put java code in JSPs. Put them in a servlet.

Regarding your question, the MessageDigest class is the java.security.MessageDigest class.

Note that message digest are one way encryption.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Putting Java code in a JSP is a very poor practice that has been obsolete and discredited for over 14 years now. You should be writing JSPs to modern standards.
 
Sebastian Urbank
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:
You shouldn't put java code in JSPs. Put them in a servlet.


Thanks for the tip to take servlets ...
i startet with the folowing tutorial (which runs good - i use XAMPP with tomcat ;-)
http://helloworldprograms.blogspot.de/2010/08/servlet-hello-world.html
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!