• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how create a new method in JSP file?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic