Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

request.getCharacterEncoding - corresponding client header?  RSS feed

 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell me how to manually set the character encoding in the client header (i.e., which header request property it is) so it will be picked up by a servlet's request.getCharacterEncoding()?

Thanks,
James
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For anyone who's interested, to be detectable by a servlet's request.getCharacterEncoding() method, the client's request property, "Content-Type" needs to be set when the client makes the request to: mimeType + ";charset=" + charset

e.g., con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=IS08859_1"; ...will work with the servlet's request.getCharacterEncoding().

but, con.setRequestProperty("Accept-Charset", "IS08859_1"); ...will not work with the servlet's request.getCharacterEncoding().
[ October 24, 2008: Message edited by: James Hodgkiss ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!