Class prominence.io.PostOutputStream
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class prominence.io.PostOutputStream

java.lang.Object
   |
   +----java.io.OutputStream
           |
           +----java.io.FilterOutputStream
                   |
                   +----prominence.io.PostOutputStream

public class PostOutputStream
extends FilterOutputStream
An OutputStream interface to a CGI POST operation.

Usage:

  • Create a PostOutputStream with a target URL.
  • Write data to this stream through the standard streams interface; some additional writing methods are supplied.
  • Call post() to perform the CGI POST operation; this method returns an InputStream to read the server's response.
    See Also:
    URL

    Variable Index

     o byteO
    A buffer for the data to be posted.
     o type
    The data content-type.
     o url
    The target URL.

    Constructor Index

     o PostOutputStream(URL)
    Creates a new PostOutputStream with the specified target URL and the default content-type "application/x-www-form-urlencoded".
     o PostOutputStream(URL, String)
    Creates a new PostOutputStream with the specified target URL and the specified content-type.

    Method Index

     o encode(char)
    Returns the URL-encoded String corresponding to the char parameter.
     o encode(String)
    Returns the URL-encoded form of the String parameter.
     o post()
    Performs a CGI POST of the buffered data, prefixed by Content-Type and Content-Length headers, and returns an InputStream from which the complete server response can be read.
     o writeBytes(String)
    Writes a String as a sequence of bytes by stripping the high-byte from each character.
     o writeTag(String, String)
    Writes a tag-value pair in URL-encoded form.
     o writeTags(Hashtable)
    Write the contents of a Hashtable as a sequence of tag-value pairs.

    Variables

     o byteO
      protected ByteArrayOutputStream byteO
    
    A buffer for the data to be posted.
     o url
      protected URL url
    
    The target URL.
     o type
      protected String type
    
    The data content-type.

    Constructors

     o PostOutputStream
      public PostOutputStream(URL url)
    
    Creates a new PostOutputStream with the specified target URL and the default content-type "application/x-www-form-urlencoded".
    Parameters:
    url - The URL to which the data should be posted
     o PostOutputStream
      public PostOutputStream(URL url,
                              String type)
    
    Creates a new PostOutputStream with the specified target URL and the specified content-type.
    Parameters:
    url - The URL to which the data should be posted
    type - The data content-type

    Methods

     o writeBytes
      public void writeBytes(String s) throws IOException
    
    Writes a String as a sequence of bytes by stripping the high-byte from each character.
    Parameters:
    s - The String to be written
    Throws: IOException
    Occurs if there is a problem writing the data.
     o writeTag
      public void writeTag(String tag,
                           String value) throws IOException
    
    Writes a tag-value pair in URL-encoded form.

    If data has already been written to the stream, a separating '&' is written. The URL-encoded tag name is then written, followed by '=', followed by the URL-encoded value.

    Parameters:
    tag - The tag name
    value - The tag value
    Throws: IOException
    Occurs if there is a problem writing the data.
     o encode
      public String encode(String s)
    
    Returns the URL-encoded form of the String parameter.
    Parameters:
    s - The String to be URL-encoded
    Returns:
    The URL-encoded String
     o encode
      public String encode(char c)
    
    Returns the URL-encoded String corresponding to the char parameter. URL-encoding replaces all non-ASCII characters, and the characters ' ', '+', '&', '=', '%', '/', and '~' with the corresponding escape sequence "%xx" where xx is the hexadecimal value of the character.
    Parameters:
    c - The char to be URL-encoded
    Returns:
    The URL-encoded String
     o writeTags
      public void writeTags(Hashtable h) throws IOException
    
    Write the contents of a Hashtable as a sequence of tag-value pairs.
    Parameters:
    h - The Hashtable of tag-value pairs.
     o post
      public InputStream post() throws IOException
    
    Performs a CGI POST of the buffered data, prefixed by Content-Type and Content-Length headers, and returns an InputStream from which the complete server response can be read.
    Returns:
    An InputStream from which the complete server response can be read.
    Throws: IOException
    Occurs if there was a problem connecting to the server or writing the POST request.

    All Packages  Class Hierarchy  This Package  Previous  Next  Index