Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String final_url = "http://localhost/makeup/index.php";
- public Grade() {
- // Empty constructor
- System.out.println("INITIALIZED");
- }
- public String getGrade( int stumark, int stunumber ) {
- String result = "";
- try {
- URL url = new URL(final_url);
- HttpURLConnection con = (HttpURLConnection) url.openConnection();
- con.setRequestMethod("POST");
- String urlparams = "stumark=" + Integer.toString(stumark) + "&stunumber=" + Integer.toString(stunumber);
- con.setDoOutput(true);
- DataOutputStream wr = new DataOutputStream(con.getOutputStream());
- wr.writeBytes(urlparams);
- wr.flush();
- wr.close();
- int responceCode = con.getResponseCode();
- System.out.println("Sending POST request to : " + final_url );
- BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream()) );
- String inputLine;
- StringBuffer response = new StringBuffer();
- while( (inputLine = in.readLine() ) != null ) {
- response.append( inputLine );
- }
- in.close();
- System.out.println("Result : " + response );
- result = response.toString();
- }catch( Exception e ) {
- System.out.println(e.getMessage());
- }
- return result;
- }
Add Comment
Please, Sign In to add comment