I have problem with getting sessionID with JSON. JSON is always returning new sessionID and when I'm trying to add sessionID to request response is wrong SessionID, it should return opened sessionID if it's open or open new sessionID and always return the same sessionID while it's opened.
It's my request class:
public abstract class RequestSender<T> {
private final String requestUrl;
DefaultHttpClient httpclient;
InputStream inputStream;
public RequestSender(String methodName) {
this.requestUrl = Settings.URL + methodName;
}
public void execute() throws IllegalStateException, IOException {
httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(requestUrl);
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
inputStream = entity.getContent();
}
private String convertResponseToString() throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(
inputStream, "UTF8"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
inputStream.close();
return sb.toString();
}
protected JSONObject parseToJSON() throws JSONException, IOException {
return new JSONObject(convertResponseToString());
}
public String getRequestUrl() {
return requestUrl;
}
public abstract T getResults() throws JSONException, IOException;
}
If anybody can help me I will be thankfull :).