dcsimg
November 28, 2020
Hot Topics:

Data access via the Web

  • 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



This article was originally published on May 25, 1999

Enterprise Development Update

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


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