I have an object tag that I'm using its data attribute to call a servlet like the code bellow. I'm passing a parameter to this url . in case the value of this parameter is not english > arabic for example. then when I get this parameter value in the specified servlet > its value looks something like this "يجب التØقق من.pdf"

I tried to add some other query string parameter like &&useUnicode=yes&&characterEncoding=UTF-8 to the url but with no luck. I also tried to use some code like request.setCharacterEncoding("UTF-8"); to the servlet but with no luck too.

this is how my code look like :

<object data="servletName.ex?fileName=${fileNameValue}">click</object>

I want to get the arabic value as it is when i get the value of the file name parameter.

1 Answers

0
Mick On

You need to URL-encode fileNameValue. You cannot tell the server which encoding to use for the URL by adding this info to the URL. The server needs to know BEFORE it reads the query - which is not possible. ;) Nowadays, you can safely assume that the server expects UTF-8. Makes sense - it should be prepared to understand those 2-byte Unicode Sequences. The only catch: URLs are not allowed to contain those characters. This is the reason for URL-Encoding / percent escaping.

If your filename would be "Über" - your request would be: "%C3%9Cber". This is a 2-byte url-encoded utf-8 encoded value of that first special character.