Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Sending Information to a Remote Site

  • Just as it is easy to receive data from a server, it is also easy to send data to a server, or more likely, to a CGI script on a server.

  • In this case, we will use an output and print stream instead of an input stream as in the following example.

    try
      {
      Socket s = new Socket("www.extropia.com", 
                             80);
      OutputStream os = s.getOutputStream());
      PrintStream ps = new PrintStream(os);
      ps.println("POST /cgi-bin/test.cgi");
      ps.println("Content-type: plain/text");
      String string = "Hello CGI Script!";
      ps.println("Content-length: " + 
                 string.length + "\n");
      ps.println(string);
      }
    catch (IOException e)
      {
      System.out.println("Error: " + e);
      }
    

  • Of course, you could simply use the GET method by passing the data as URL encoded information by replacing the first println line above with something more like:

    ps.println("GET /cgi-bin/test.cgi?phrase=Hello+CGI+Script");

Additional Resources:

Getting Information from a Remote Site
Table of Contents
Threads


Up to => Home / Authoring / Scripting / Tutorial




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers