Meaningless Drivel is fun!
The moose likes HTML, CSS and JavaScript and the fly likes md5 jsp javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "md5 jsp javascript" Watch "md5 jsp javascript" New topic

md5 jsp javascript

ankur mawandia

Joined: Jan 10, 2011
Posts: 12

i want to use a javascript to md5 a given string in my jsp page
how can i include the javascript and call the function in the javascript to manipulate the variables

may the force be with you
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63866

You'll need to find an MD5 implementation in JavaScript and use it according to its directions.

Are you sure this is something you want to do on the client? This is something usually done on the server.

[Asking smart questions] [About Bear] [Books by Bear]
Blaidd Gwael

Joined: Oct 01, 2009
Posts: 13

See MD5 function

You create a md5.js file that contains that code.
Include the md5.js file in your jsp:

do something like:

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

And then I do a view source and I can see exactly what is getting hashed and how. Not only that, but MD5 isn't really a trusted hash anymore these days.

GenRocket - Experts at Building Test Data
ankur mawandia

Joined: Jan 10, 2011
Posts: 12

thank you for your reply
how can i store this javascript variable value in a another jsp variable for posting in the database

thanks again
Blaidd Gwael

Joined: Oct 01, 2009
Posts: 13

the jsp is executed on the server while the js code is executed by the browser on the client, so you can't store it.
You can always run a method on the server:

For javascript you'll have to modify the link that goes on the server. If you have

Now when you will click the second link you will modify the first one (it contains a parameter named "md5" with the desired value).
Anyone can see your js function code, so be careful.
I don't know what you really want but i hope this example will help you.

I agree. Here's the link:
subject: md5 jsp javascript
It's not a secret anymore!