-1

I'm calling a url like this:

http://localhost:8080/abc/income?content=%E0%B6%B8%E0%B6%9C%E0%B7%99+%E0%B6%B1%E0%B6%B8+%E0%B6%BD%E0%B6%9A%E0%B7%8A%E0%B6%B8%E0%B7%8F%E0%B6%BD%E0%B7%8A.&SOURCE_PRV=%20HTTP/1.1

and in the backend (tomcat) I'm decoding the string.

But I get the content as "??? ?? ???????" (several question marks).

How can I fix this?

Enamul Hassan
  • 5,266
  • 23
  • 39
  • 56
Lakmal Vithanage
  • 2,767
  • 7
  • 42
  • 58
  • Show your decoding code. – Steffen Harbich Aug 05 '16 at 12:19
  • The request header should contain a header with the encoding, that should have been used for the URL encoding. Use that for the URL decoding. Here it seems that maybe a `request.setCharacterEncoding("UTF-8");` went missing, One thing: **make sure that the question mark you see is indeed that**: dump the code points of the string or such. Maybe the output was encoded ISO-8859-1. – Joop Eggen Aug 05 '16 at 14:50
  • Welcome to Stack Overflow! I edited your question as far as I could guess your problem. However, add code and description so that more people with knowledge of the subject will see it. Please edit in the specific error-message you're encountering in case that's necessary to identify the specific problem. Good Luck! – Enamul Hassan Aug 07 '16 at 14:14
  • Also see http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q8 – Roman Aug 07 '16 at 15:14

1 Answers1

0

The java.net.URI class can help; in the documentation of URL you find

Use one of the constructors with more than one argument, like:

URI uri = new URI(
    "http", 
    "search.barnesandnoble.com", 
    "/booksearch/first book.pdf",
    null);

URL url = uri.toURL();
//or String request = uri.toString();
sinsuren
  • 1,745
  • 2
  • 23
  • 26
Afnan alam
  • 9
  • 1
  • 1
  • 12