WebObjects 5.1

com.webobjects.appserver
Class WOResponse

java.lang.Object
  |
  +--com.webobjects.appserver.WOMessage
        |
        +--com.webobjects.appserver.WOResponse
All Implemented Interfaces:
Cloneable, NSKeyValueCoding, NSKeyValueCoding.ErrorHandling, NSKeyValueCodingAdditions, WOActionResults

public class WOResponse
extends WOMessage
implements WOActionResults, Cloneable

A WOResponse object represents an HTTP response that an application returns to a Web server to complete a cycle of the request-response loop. The composition of a response occurs during the third and final phase of this loop, a phase marked by the propagation of the appendToResponse method through the objects of the application. The WOApplication object first invokes this method, passing in a newly-created WOResponse object as an argument. WOElement objects, which represent the dynamic and static HTML elements on a page, respond to the method by appending their HTML representation to the content of the WOResponse object. WOApplication, WOSession, and WOComponent objects can also respond to the method by adding information to the WOResponse object.

A WOResponse has two major parts: HTML content and HTTP information. The HTML content is what is displayed in a Web browser; it can include escaped HTML, which is HTML code shown "as is," uninterpreted. The HTTP information encapsulated by a WOResponse object is used when handling the response. This HTTP data includes headers, status codes, and an HTTP version string.

The WOMessage class -- from which WOResponse inherits -- declares most of the methods you use when constructing a response. These methods can be divided into two groups, those that add to a response's HTML content and those that read and set HTTP information. For images and other binary data, the user should use the method appendContentData declared in the WOMessage class. You can obtain and set the entire content of the message using WOResponse's content and setContent methods. The following example shows a sequence of appendContent invocations that compose an HTTP "POST" message:

 aResponse.appendContentString("<form method=\"POST \"action=\"");
 aResponse.appendContentHTMLAttributeValue(aContext.url());
 aResponse.appendContentCharacter('"');
 aResponse.appendContentString(">");
 

See Also:
WOMessage.appendContentData(NSData dataObject), WOMessage.setContent(NSData someData), WOMessage.content(), WOMessage

Inner classes inherited from class com.webobjects.foundation.NSKeyValueCoding
NSKeyValueCoding.DefaultImplementation, NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.Null, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.Utility, NSKeyValueCoding.ValueAccessor
 
Inner classes inherited from class com.webobjects.foundation.NSKeyValueCodingAdditions
NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility
 
Fields inherited from class com.webobjects.appserver.WOMessage
HTTP_STATUS_FORBIDDEN, HTTP_STATUS_FOUND, HTTP_STATUS_MOVED_PERMANENTLY, HTTP_STATUS_NO_CONTENT, HTTP_STATUS_NOT_FOUND, HTTP_STATUS_OK, TheDefaultResponseEncoding
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding
NullValue
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
KeyPathSeparator
 
Constructor Summary
WOResponse()
          Creates a WOResponse with HTTP status set to 200 (OK), client caching enabled, and the default string encoding set to ISO Latin 1.
 
Method Summary
 Object clone()
           
 void disableClientCaching()
          Attempts to disable caching in the client browser by appending a no-cache Cache-Control response directive to the HTTP response and by appending Expires and Date values that are equal and set to the current date and time.
 WOResponse generateResponse()
          WOResponse's implementation simply returns itself.
 void setStatus(int aStatus)
          Sets the HTTP status to aStatus.
 int status()
          Returns the HTTP return status of the WOResponse.
 String toString()
          Returns a String representation of the receiver.
 
Methods inherited from class com.webobjects.appserver.WOMessage
addCookie, appendContentCharacter, appendContentData, appendContentDOMDocumentFragment, appendContentHTMLAttributeValue, appendContentHTMLString, appendContentString, appendHeader, appendHeaders, canAccessFieldsDirectly, content, contentAsDOMDocument, contentEncoding, contentString, cookies, defaultEncoding, equals, handleQueryWithUnboundKey, handleTakeValueForUnboundKey, headerForKey, headerKeys, headers, headersForKey, httpVersion, removeCookie, removeHeadersForKey, requiresHTMLEscaping, setContent, setContent, setContent, setContentDOMDocument, setContentEncoding, setDefaultEncoding, setHeader, setHeaders, setHeaders, setHTTPVersion, setUserInfo, stringByEscapingHTMLAttributeValue, stringByEscapingHTMLString, takeValueForKey, takeValueForKeyPath, unableToSetNullForKey, userInfo, valueForKey, valueForKeyPath
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WOResponse

public WOResponse()
Creates a WOResponse with HTTP status set to 200 (OK), client caching enabled, and the default string encoding set to ISO Latin 1.
Method Detail

clone

public Object clone()
Overrides:
clone in class WOMessage

disableClientCaching

public void disableClientCaching()
Attempts to disable caching in the client browser by appending a no-cache Cache-Control response directive to the HTTP response and by appending Expires and Date values that are equal and set to the current date and time.

This method should not be invoked more than once for a given response.


generateResponse

public WOResponse generateResponse()
WOResponse's implementation simply returns itself.
Specified by:
generateResponse in interface WOActionResults
Returns:
a WOResponse object
See Also:
WOComponent.generateResponse()

setStatus

public void setStatus(int aStatus)
Sets the HTTP status to aStatus. The most commonly useful status codes are defined in static fields on WOMessage.

Consult RFC 2616 for the significance of status integers.

Parameters:
aStatus - the integer stating the status of the HTTP
See Also:
status(), WOMessage

status

public int status()
Returns the HTTP return status of the WOResponse. The most commonly useful status codes are defined in static fields on WOMessage.

By default, the status is 200 ("OK" status).

Consult RFC 2616 for the significance of status integers.

Returns:
an integer code representing the HTTP status
See Also:
setStatus(int aStatus), WOMessage

toString

public String toString()
Returns a String representation of the receiver. This string representation is suitable for debugging. It details many of the WOResponse object's attributes and should not be confused with the contentString method.
Overrides:
toString in class WOMessage
Returns:
String representation of the receiver

Last updated Thu Jan 10 18:10:21 PST 2002.

Copyright © 2002 Apple Computer, Inc.