How can I read GET or POST parameters that were encoded in an international character set? Also, when a user fills in an HTML Form using a custom Input Method Editor for, say, Japanese, how can my servlet/JSP know which encoding was used?

Jan Borchers



The HttpServletRequest object from 2.0 on provides a method for retrieving the client's character encoding. The follwing sample gets the parameter mytext and converts it to a java Unicode string.


public String getText(HttpServletRequest request)
  String value = request.getParameter("mytext");

    value = new String(value.getBytes(), request.getCharacterEncoding());
  }catch( ex){

  return value;

See also

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact