File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes HTML Number encoding - User Input Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "HTML Number encoding - User Input" Watch "HTML Number encoding - User Input" New topic
Author

HTML Number encoding - User Input

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Guys,

I have a password field. The user enters some characters in it (say asdfgh12). Is there a way in HTML that before I send this password to the server, I can encode it in the HTML Number format (like {) for all the characters? Is there a special HTML function or do I have to encode it explicity using a javascript function?


SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60049
    
  65

There is no such thing as an "HTML function". Any scripting on a page is done in JavaScript.

What kind of encoding are you after, and for what reason?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

I want to have all the characters as &#xyz; encoded when they reach my server.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18118
    
    8

So, instead of sending "ABC" to the server you want to send "ABC"? I'm sure you could write some Javascript to do that. The key step would be finding a Javascript function to convert a character to its Unicode code point value.

But the point of doing that escapes me too. What's the reason for doing that?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60049
    
  65

I hope that you are not thinking that this affords you any level of security.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

A legacy app needs support for special characters. Migrating database to UTF-8 seems expensive. I tried with some of the characters that are supported by the current charset of the legacy app and when they reach the server, I see them by default coded as ř

For example if I enter the following hjkläb, when they reach the server, I see them as hjklêb.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Paul Clapham wrote:So, instead of sending "ABC" to the server you want to send "ABC"? I'm sure you could write some Javascript to do that. The key step would be finding a Javascript function to convert a character to its Unicode code point value.

But the point of doing that escapes me too. What's the reason for doing that?


Already wrote a javascript function that would do this for me.
 
Don't get me started about those stupid light bulbs.
 
subject: HTML Number encoding - User Input
 
Similar Threads
Encoding
Opening an popup.
help me
basic http authentication
URLEncoder & URLDecoder