Does not inherit
appendPayload() flushBuffer() getOutputStream() getPayload() |
getWriter() isCommitted() reset() resetBuffer() |
ServletResponse() setContentLength() setContentType() setPayload() |
~ServletResponse() |
#include rwsf/servlet/ServletResponse.h
rwsf::ServletResponse encapsulates a response to a client. For each request, the Agent creates an instance of this object and passes the instance to the servlet's service() method. Each response object contains an output buffer that holds the response payload. The methods in this class allow a servlet to access and set buffer information.
To write to the output buffer, either set the payload directly using setPayload() or construct an rwsf::ServletOutputStream via getOutputStream() or getWriter(). To get a copy of the contents of the output buffer, use the getPayload() function.
The following table lists methods that are either non-standard or not supported at this release.
appendPayload() |
added method |
getCharacterEncoding() |
not supported in this release. |
getLocale() |
not supported in this release. |
getPayload() |
added method. |
setLocale() |
not supported in this release. |
setPayload() |
added method |
ServletResponse();
Constructs a new rwsf::ServletResponse object. This object is always created by the Agent. Servlets have access to an instance of this object with the service methods.
virtual ~ServletResponse();
Destructor.
void appendPayload(const std::string & payload);
Appends data to the current payload.
void flushBuffer();
Flushes the current response buffer. Any content that has been written to this response will be sent to the client, including any headers.
rwsf::ServletOutputStream & getOutputStream();
Returns an object that can be used to write the response to the client. A servlet can use the rwsf::ServletOutputStream object to write the response or a servlet can set the payload directly using the setPayload method.
std::string getPayload() const;
Returns the current payload that was set with the setPayload() method.
rwsf::ServletOutputStream & getWriter();
Returns an rwsf::ServletOutputStream for this request. This method is identical to the getOutputStream() method.
bool isCommitted() const;
Returns true if this response has been committed to the client, false otherwise.
void reset();
Clears the current payload. Note that this does not clear any rwsf::ServletOutputStream objects associated with this response. To clear an output stream, call the reset() function of the output stream.
void resetBuffer();
Clears the current payload. Does not clear any rwsf::ServletOutputStream objects associated with this response. Use the reset() function of the output stream to clear an output stream.
void setContentLength(int len);
Sets the content length for the response.
void setContentType(const std::string & type);
Sets the Content-Type for the response.
void setPayload(const std::string & payload);
Sets the payload to the given string, clearing any previous information not yet sent to the client. Setting the payload directly is generally more efficient than using the rwsf::ServletOutputStream class to write the response.
© Copyright Rogue Wave Software, Inc. All Rights Reserved. All Rights Reserved. Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. HydraExpress is a trademark of Rogue Wave Software, Inc. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.