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 accepting special characters in form fields 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 "accepting special characters in form fields" Watch "accepting special characters in form fields" New topic
Author

accepting special characters in form fields

M. Gagnon
Ranch Hand

Joined: Feb 18, 2004
Posts: 68
How can I accept special characters such as �, �, �, � in text and textarea input fields on an html form? I am using the accept-charset="utf-8" attribute in the form, but it doesn't seem to make a difference. The form submits to a servlet. Do I have to do some encoding on the server side? Also, I'd like users to be able to type the characters in using the keyboard rather than cutting and pasting from their own editors. Is that possible?
M. Gagnon
Ranch Hand

Joined: Feb 18, 2004
Posts: 68
p.s. -- I see someone managed to do it here on javaranch as I am seeing the characters I entered on the form for my question. Yeah! How did you do it?
M. Gagnon
Ranch Hand

Joined: Feb 18, 2004
Posts: 68
OK, the real problem, aside from allowing actual typing of these characters into the form fields rather than copy and paste, is saving the text to XML and to a relational database (MySQL to be specific). I need to convert any special characters to their numeric character entities for XML/HTML. That may actually be the best way to store them in the database as well. Is there a Java object with a method that already does this? I'd hate to reinvent the wheel for this problem.

As far as typing special characters into HTML form fields is concerned, I think it will involve a lengthy javascript method capturing all keystrokes and converting the input to numeric character entities. By the way if I simply capture text entered through copy and paste in a String object contained by a bean, I can redisplay the text using a call to a getProperty() method that returns the String, but only on my home machine using Apache Tomcat, not on my live site which uses Caucho Resin!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: accepting special characters in form fields