Advertisement
Guest User

Untitled

a guest
Mar 28th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. public class PostToPage {
  2.  
  3. public static void post(String link, String username, String password){
  4.  
  5. try {
  6. // open a connection to the site
  7. URL url = new URL(link);
  8. URLConnection con = url.openConnection();
  9. // activate the output
  10. con.setDoOutput(true);
  11. PrintStream ps = new PrintStream(con.getOutputStream());
  12. // send your parameters to your site
  13. ps.print("&Username=" + username);
  14. ps.print("&Password=" + password);
  15.  
  16. // we have to get the input stream in order to actually send the request
  17. con.getInputStream();
  18.  
  19. // close the print stream
  20. ps.close();
  21. } catch (MalformedURLException e1) {
  22. e1.printStackTrace();
  23. } catch (IOException e2) {
  24. e2.printStackTrace();
  25. }
  26.  
  27. // creating new product in background thread
  28. //new CreatePortfolio().execute();
  29.  
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement