I keep getting the error above (title) when I try to make a HTTP-request to a server with a special character (the character 'å'). I have tried to call:
_login = URLEncoder.encode(_login, "utf-8");
But I still get exception. If I try to change the URL it works fine. Seems that it happends for whatever URL I try if it has special characters. Like for example http://www.ål.no
.
Anyone know about a work-around? One way could of course be to use the IP-address. But I would rather avoid that.
Thanks for any help!
Some of the source code:
private String _login = "http://www.ål.no";
HttpClient httpclient = new DefaultHttpClient();
try {
_login = URLEncoder.encode(_login, "utf-8");
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
HttpPost httppost = new HttpPost(_login);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
//nameValuePairs.add(new BasicNameValuePair("Mail", this.Email));
//nameValuePairs.add(new BasicNameValuePair("Password", this.Password));
try
{
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
BasicHttpResponse response = null;
try
{
response = (BasicHttpResponse) httpclient.execute(httppost);
}
catch (ClientProtocolException e)
{
System.out.println("BasicHttpResponse");
e.printStackTrace();
}
}
EDIT: Found a work around. Used Firebug to dig a little deeper. According to Firebug the server has another name when communicating (as far as I can see). This name does not contain any special characters and I successfully managed to communicate with the server using my application. Thanks for all help! :)