• 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

accepting special characters in form fields

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
get schwifty. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic