I'm new to Android development.
Basically I need to submit data from 3 editTexts of my android app to a webpage and display the response returned. The webpage uses sessions with jSessionId.
I don't have any idea how to post request to the webpage,get the cookie,store it and use it while sending the above said data by attaching the jSessionId to the url. I've been searching about this from past 2 days. but couldn't get anything to work. No idea where to start and how to.
A detailed answer is what I'm looking because I've tried answers from stackoverflow also. Still no luck
I've managed to retrieve the jsessionid so far.
public boolean send() {
String givenDob = dobET.getText().toString();
String givensurname = surnameEt.getText().toString();
String givenCaptcha = captchaET.getText().toString();
String url = "https://mysite/getinfo.html";
try {
URLConnection connection = new URL(url).openConnection();
InputStream response = connection.getInputStream();
List<String> cookies = connection.getHeaderFields().get("Set-Cookie");
Log.d("Link Response", String.valueOf(response));
Log.d("Cookie", String.valueOf(cookies));
String value = cookies.get(0);
if (value.contains("JSESSIONID")) {
int index = value.indexOf("JSESSIONID=");
int endIndex = value.indexOf(";", index);
String sessionID = value.substring(
index + "JSESSIONID=".length(), endIndex);
Log.d("id " ,sessionID);
}
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
Now how do I use this sessionid and send the edittext data to retrieve informaion?