Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- URL url = new URL("http://192.168.43.226:8080/Manager/LogInServlet?username=" + this.theUserName + "&password=" + this.thePassword);
- HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
- urlConnection.setRequestMethod("POST");
- urlConnection.setDoOutput(true);
- urlConnection.setDoInput(true);
- try {
- urlConnection.setRequestProperty("Cookie", cookie);
- InputStream in = new BufferedInputStream(urlConnection.getInputStream());
- cookie = urlConnection.getHeaderField("Set-Cookie");
- BufferedReader streamReader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
- StringBuilder responseStrBuilder = new StringBuilder();
- String inputStr;
- while ((inputStr = streamReader.readLine()) != null)
- responseStrBuilder.append(inputStr);
- JSONObject json = new JSONObject(responseStrBuilder.toString());
- return new Answer(json);
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- urlConnection.disconnect();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement