org.apache.taglibs.scrape
Class HttpConnection

java.lang.Object
  extended by org.apache.taglibs.scrape.HttpConnection

public class HttpConnection
extends java.lang.Object

HttpConnection - the class that creates the http connection that the rest of the package uses

Version:
1.0
Author:
Rich Catlett

Constructor Summary
HttpConnection(java.net.URL url, int port, java.lang.String server, java.lang.String authstring, javax.servlet.jsp.PageContext pc)
          constructor creates an instance of HttpConnection and calls the super class HttpURLConnection, this instance of the class connects through a proxy server that requires authentication
HttpConnection(java.net.URL url, PageData pd, javax.servlet.jsp.PageContext pc)
          constructor creates an instance of HttpConnection and calls the super class HttpURLConnection
 
Method Summary
 void connect()
          Implementation of the abstract method defined in the URLConnection class establish a connection to an HTTP server and send request
 void disconnect()
          Implementation of the abstract method defined in the HttpURLConnection class cut the current connection this object has
 long getExpiration()
          Override default provided in URLConnection
 java.lang.String getHeaderField(int n)
          Override default provided in URLConnection
 java.lang.String getHeaderField(java.lang.String key)
          Override default provided in URLConnection
 int getHeaderFieldInt(java.lang.String key, int n)
          Override default provided in URLConnection
 java.lang.String getHeaderFieldKey(int n)
          Override default provided in URLConnection
 java.io.InputStream getInputStream()
          Override the default method provided in the URLConnection class
 long getLastModified()
          Override default provided in URLConnection
 java.io.OutputStream getOutputStream()
          Override the default method provided in the URLConnection class
 java.lang.String getRequestMethod()
          get the request method
 int getResponseCode()
          Override the default method provided in the HttpURLConnection class Get the response code for this connection
 java.lang.String getResponseMessage()
          Override the default method provided in the HttpURLConnection class Get the response message for the last request
 java.net.URL getURL()
          get the URL of this connection
 void sendRequest()
          send the request to the server
 void setRequestMethod(java.lang.String value)
          set the request method
protected  void setURL(java.lang.String value)
          Set the URL for this connection
 boolean usingProxy()
          Implementation of the abstract method defined in the HttpURLConnection class this implementation does not use proxy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpConnection

public HttpConnection(java.net.URL url,
                      PageData pd,
                      javax.servlet.jsp.PageContext pc)
constructor creates an instance of HttpConnection and calls the super class HttpURLConnection

Parameters:
url - - url of the http server to connect to

HttpConnection

public HttpConnection(java.net.URL url,
                      int port,
                      java.lang.String server,
                      java.lang.String authstring,
                      javax.servlet.jsp.PageContext pc)
constructor creates an instance of HttpConnection and calls the super class HttpURLConnection, this instance of the class connects through a proxy server that requires authentication

Parameters:
url - url of the http server to connect to
port - the port to use for the connection to the proxy server
server - the proxy server
secure - is the link going over https
name - user name for authentication
pass - password for authentication
Method Detail

connect

public void connect()
             throws java.io.IOException
Implementation of the abstract method defined in the URLConnection class establish a connection to an HTTP server and send request

Throws:
java.io.IOException - - if connection cannot be made

disconnect

public void disconnect()
Implementation of the abstract method defined in the HttpURLConnection class cut the current connection this object has


usingProxy

public boolean usingProxy()
Implementation of the abstract method defined in the HttpURLConnection class this implementation does not use proxy

Returns:
false proxy servers not used by this implementation

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Override the default method provided in the URLConnection class

Throws:
java.io.IOException

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Override the default method provided in the URLConnection class

Throws:
java.io.IOException

getRequestMethod

public java.lang.String getRequestMethod()
get the request method

Returns:
- the request method

setRequestMethod

public void setRequestMethod(java.lang.String value)
set the request method

Parameters:
String - GET or HEAD

getResponseCode

public int getResponseCode()
Override the default method provided in the HttpURLConnection class Get the response code for this connection

Returns:
- the response code of the connection, -1 if no valid response

getResponseMessage

public java.lang.String getResponseMessage()
Override the default method provided in the HttpURLConnection class Get the response message for the last request

Returns:
- the response message of the last request

sendRequest

public void sendRequest()
                 throws java.io.IOException
send the request to the server

Throws:
java.io.IOException

getHeaderField

public java.lang.String getHeaderField(int n)
Override default provided in URLConnection

Parameters:
n - - index of the desired header field

getLastModified

public long getLastModified()
Override default provided in URLConnection

Returns:
- LastModified header or 0 if LastModified does not exist

getExpiration

public long getExpiration()
Override default provided in URLConnection

Returns:
- the Expiration header or 0 if Expiration does not exist

getHeaderField

public java.lang.String getHeaderField(java.lang.String key)
Override default provided in URLConnection

Parameters:
key - - name of the desired header field

getHeaderFieldInt

public int getHeaderFieldInt(java.lang.String key,
                             int n)
Override default provided in URLConnection

Parameters:
n - value returned if header is null
key - header to retreive
Returns:
- header as an integer

getHeaderFieldKey

public java.lang.String getHeaderFieldKey(int n)
Override default provided in URLConnection

Parameters:
n - - index of the desired header field

setURL

protected void setURL(java.lang.String value)
               throws java.net.MalformedURLException
Set the URL for this connection

Throws:
java.net.MalformedURLException

getURL

public java.net.URL getURL()
get the URL of this connection

Returns:
- the URL for this connection


Copyright ? 2000-2004 The Apache Software Foundation. All Rights Reserved.