dcsimg
January 19, 2017
Hot Topics:

Data access via the Web

  • May 25, 1999
  • By Piroz Mohseni
  • Send Email »
  • More Articles »


import java.util.*;
import java.net.*;
import java.io.*;

public class testHTTP
{
  public static void main( String argv[] ) throws IOException
  {
    String cgiscript = 
       " http://www.gamelon.com/somedir/getinfo.cgi";
    String query = null;
    String line = "";
    query = "lname=jones&id=123";
 
// if your Java program is running behind the firewall and you need to 
// set a proxy, use the following lines
//    System.getProperties().put( "proxySet", "true" );
//    System.getProperties().put( "proxyHost", 
//          "proxy url goes here");
//    System.getProperties().put( "proxyPort", "8000" );

   
    try
    {
      URL url = new URL(cgiscript);
      URLConnection connection = 
          url.openConnection();
      connection.setDoInput( true );
      connection.setDoOutput( true );

      DataOutputStream output = new DataOutputStream( 
           connection.getOutputStream() ); 
      output.writeBytes( query );
      output.close();

      BufferedReader input = new BufferedReader(new 
        InputStreamReader( 
           connection.getInputStream())); 

      while ((line = input.readLine()) != null)
      { 
         System.out.println(line);
  }
      input.close();
    }
    catch( Exception e ) {}
  }
}





Page 3 of 3



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel