The Artima Developer Community
Sponsored Link

Java Answers Forum
Send POST request to https

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Andy Grimm

Posts: 2
Nickname: grimm
Registered: Oct, 2002

Send POST request to https Posted: Jan 29, 2003 3:24 AM
Reply to this message Reply
Advertisement
hi
i programed this little tool:
String parms = "dateIn=29.01.2003" + "&beschIn=just a test";
		byte[] bytes = parms.getBytes();
		//Byte wird gebraucht f?r Output
		
		// Create a URL pointing to the servlet or CGI script and open an HttpURLConnection on that URL
		
		URL url = new URL("http://chr78939:50001/cgi-bin/formsave.pl");
		HttpURLConnection con = (HttpURLConnection) url.openConnection();
		
		// Indicate that you will be doing input and output, that the method is POST, and that the content
		// length is the length of the byte array
		
		con.setDoOutput(true);
		con.setDoInput(true);
		con.setRequestMethod("POST");
		con.setRequestProperty("Content-length", String.valueOf(bytes.length));
		
		// Write the parameters to the URL output stream
		
		OutputStream out = con.getOutputStream();
		out.write(bytes);
		out.flush();
		// Read the response
		BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
		   while (true) {
		       String line = in.readLine();
		       if (line == null) break;
		       System.out.println(line);
		   }
		in.close();
		out.close();
		con.disconnect();

it works fine, but my question is:
is this tool also working by a https site ?
or what have i to change ? (maybe you got a good web-site)
thx a lot

Topic: Array project - need help Previous Topic   Next Topic Topic: Clear screen

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use