Win a copy of Head First Android this week in the Android forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

How to find out the Browser's Encoding through Javascript?

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I am working with a Web Application, where in there is a text area, where the user can enter free text. Now, this page submits to a servlet, which in turns store the data from the webpage into an Oracle Database.

While sending the data from the textarea to the servlet, i am using the javascript's method. Now, the problem is, when i get the data from the browser to the servlet, the text of the textarea, comes in an encoded format. Now, before putting the data in the database, i would like to decode the content.

Now, i am unable to use the , since i cannot use javascript inside the servlet. I am planning to use function of Java, but to use that function, i need to get the encoding in which the browser's content is being encoded. Now my question, is how can we determine the encoding of a Browser in the servlet. I have tried the http headers, but of no use.

Just for your information, i am not using the attribute of html tag. This may seem a small problem to you all, but it wasn't for me.

Request you all to help me in this regard.

Thanks
Chaitanya V
 
Sheriff
Posts: 67595
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

While sending the data from the textarea to the servlet, i am using the javascript's
code encodeURIComponent()

Why?

The text will be automatically url-encoded as part if the form submission. By doubly-encoding it, you are just creating a mess.
[ November 11, 2008: Message edited by: Bear Bibeault ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic