• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

request object and character encoding.....

 
Krishna Latha Grandhi
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How we can know "client hasn�t set character encoding and the request data is encoded with a different encoding than the default"..
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the spec :

SRV.4.9 Request data encoding

If the client hasn�t set character encoding and the request data is encoded with
a different encoding than the default as described above, breakage can occur. To
remedy this situation, a new method setCharacterEncoding(String enc) has
been added to the ServletRequest interface. Developers can override the
character encoding supplied by the container by calling this method. It must be
called prior to parsing any post data or reading any input from the request. Calling
this method once data has been read will not affect the encoding.
 
Krishna Latha Grandhi
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I posted this question after reading it in the spec..

we can verify the client set the encoding or not by using the method getCharacterEncoding()

My doubt is how we can know the request data is encoded with a different encoding..?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You know in which encoding the request should be encoded to.
Call getCharacterEncoding and compare.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic