org.apache.cocoon.servletservice
Interface ServletConnection

All Known Implementing Classes:
AbsoluteServletConnection, AbstractServletConnection, RelativeServletConnection

public interface ServletConnection

Contract to connect to a servlet service. The implementing classes differ from how they look up the servlet service.

This class was designed similar to URLConnection.

Since:
1.0.0
Version:
$Id: ServletConnection.html 1422810 2012-12-17 09:13:50Z ilgrosso $

Method Summary
 void connect()
          Connect to the servlet service.
 String getContentType()
          Get the mime-type of the servlet-service.
 String getHeaderField(String name)
          Get a response header with the given name.
 Map<String,String> getHeaders()
          Get all response header fields.
 InputStream getInputStream()
          Read the input stream from the servlet service response.
 long getLastModified()
          Get the last modification date of the servlet service.
 OutputStream getOutputStream()
          Get an output stream that writes as POST to this connection.
 int getResponseCode()
           
 URI getURI()
          Get a URI representing this servlet connection.
 void setIfModifiedSince(long ifmodifiedsince)
          Set the last modification date if you want to make use of caching.
 

Method Detail

setIfModifiedSince

void setIfModifiedSince(long ifmodifiedsince)
Set the last modification date if you want to make use of caching. This method has to be called before any of the other methods of this interface is invoked.

Parameters:
ifmodifiedsince - The timestamp of the last known resource.

getOutputStream

OutputStream getOutputStream()
Get an output stream that writes as POST to this connection.

Returns:
An output stream that writes as POST to this connection.

connect

void connect()
             throws IOException,
                    javax.servlet.ServletException
Connect to the servlet service. Establishing a connection means that the service is executed and the response is available.

Throws:
IOException - The connection to the servlet service can't be established.
javax.servlet.ServletException - Any other problem when connecting to a servlet service.

getInputStream

InputStream getInputStream()
                           throws IOException,
                                  javax.servlet.ServletException
Read the input stream from the servlet service response.

Returns:
An input stream on the servlet service response.
Throws:
IOException - The connection to the servlet service can't be established.
javax.servlet.ServletException - Any other problem when connecting to a servlet service.

getResponseCode

int getResponseCode()
                    throws IOException
Returns:
The HTTP status code returned by the servlet service.
Throws:
IOException

getLastModified

long getLastModified()
Get the last modification date of the servlet service.

Returns:
The last modification date of the servlet service.

getContentType

String getContentType()
Get the mime-type of the servlet-service.

Returns:
The mime-type of the servlet-service.

getURI

URI getURI()
Get a URI representing this servlet connection.

Returns:
a URI representing this servlet connection.

getHeaderField

String getHeaderField(String name)
Get a response header with the given name.

Parameters:
name - The name of the header parameter
Returns:
The value of the header parameter

getHeaders

Map<String,String> getHeaders()
Get all response header fields.

Returns:
A Map that contains all response headers.


Copyright © 1999-2012 The Apache Software Foundation. All Rights Reserved.