In my app there is an issue regarding the password.The problem occurs when a password ends with a + symbol,and while posting the url i got the response as user not found.If any one know the solutions plz help..I think the problem is with encoding of + symbol.so how can i send a password contain + symbol to the server?This is my code for posting url.’
public void doPost (String email,String password) throws UnsupportedEncodingException, SprinklrHttpException{
try{
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
OutputStream ostream=connection.getOutputStream();
String serverMsg=null;
serverMsg="email="+email+"&password="+password;
Log.i("tag","servermsg="+serverMsg);
ostream.write(serverMsg.getBytes());
ostream.close();
InputStream istream=connection.getInputStream();
response=convertStreamToString(istream);
istream.close();
}catch(Exception e){
e.printStackTrace();
}
}
private void executeRequest(HttpUriRequest request) throws SprinklrHttpException{
HttpResponse httpResponse;
InputStream inputStream = null;
HttpClient httpClient = new DefaultHttpClient();
httpClient.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY);
try {
httpResponse = httpClient.execute(request, this.httpContext);
this.responseCode = httpResponse.getStatusLine().getStatusCode();
Log.i("webResponse","responsecode"+this.responseCode);
this.message = httpResponse.getStatusLine().getReasonPhrase();
HttpEntity entity = httpResponse.getEntity();
if (entity != null) {
inputStream = entity.getContent();
this.response = convertStreamToString(inputStream);
}
}catch (ClientProtocolException e) {
httpClient.getConnectionManager().shutdown();
e.printStackTrace();
}catch (IOException e) {
httpClient.getConnectionManager().shutdown();
e.printStackTrace();
throw new SprinklrHttpException(1000,"");
}finally {
if (inputStream != null){
try {
inputStream.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
REPLACE
WITH