java - What encoding should I use for an HTTP servlet input stream if none was specified? -


while reading servletinputstream team doing this:

br = new bufferedreader(new inputstreamreader(servletinputstream)); 

this unsurprisingly gave red flag on code analyzer encoding not specified , rely on whatever default system encoding is.

the first step try encoding request:

string encoding = request.getcharacterencoding(); if (encoding != null) {   br = new bufferedreader(new inputstreamreader(servletinputstream), encoding); } 

however, this related answer told me, browsers don't send encoding, cause encoding null above. in case, how on earth supposed know encoding is?

do browsers not send encoding because:

  1. there universally-agreed default encoding http requests used if none specified? (if , standard defines should used), or,
  2. there other way determine encoding is? (if it? surely not trying different encodings , seeing whether garbage or parseable?)

since dynamic web application, you'd expected have control on encoding clients post request. utf-8.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -