HydraExpress™ C++ API Reference Guide

Product Documentation:
   HydraExpress C++
Documentation Home
List of all members | Public Member Functions
rwsf::ServletResponse Class Reference

Encapsulates the response a servlet returns to the client. More...

#include <rwsf/servlet/ServletResponse.h>

Inheritance diagram for rwsf::ServletResponse:
rwsf::HttpServletResponse

Public Member Functions

virtual ~ServletResponse ()
 
void appendPayload (const std::string &data)
 
virtual void flushBuffer ()
 
rwsf::ServletOutputStreamgetOutputStream ()
 
std::string getPayload () const
 
rwsf::ServletOutputStreamgetWriter ()
 
bool isCommitted () const
 
void reset ()
 
void resetBuffer ()
 
virtual void setContentLength (int len)
 
virtual void setContentType (const std::string &type)
 
void setPayload (const std::string &payload)
 

Detailed Description

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 behavior of the following functions are inconsistent with or not defined in the Java Servlet Specification v2.3.

appendPayload() Added method
getCharacterEncoding() Not supported in this release
getLocale() Not supported in this release
getBufferSize() Not supported in this release
setBufferSize() Not supported in the release
getPayload() Added method.
setLocale() Not supported in this release
setPayload() Added method

Constructor & Destructor Documentation

virtual rwsf::ServletResponse::~ServletResponse ( )
virtual

Destructor.

Member Function Documentation

void rwsf::ServletResponse::appendPayload ( const std::string &  data)

Appends data to the current payload.

virtual void rwsf::ServletResponse::flushBuffer ( )
virtual

Flushes the current response buffer. Any content that has been written to this response is sent to the client, including any headers.

Reimplemented in rwsf::HttpServletResponse.

rwsf::ServletOutputStream& rwsf::ServletResponse::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 rwsf::ServletResponse::getPayload ( ) const

Returns the current contents of the payload.

rwsf::ServletOutputStream& rwsf::ServletResponse::getWriter ( )

Returns an rwsf::ServletOutputStream for this request. This method is identical to the getOutputStream() method.

bool rwsf::ServletResponse::isCommitted ( ) const

Returns true if this response has been committed to the client, false otherwise.

void rwsf::ServletResponse::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 rwsf::ServletOutputStream::reset().

void rwsf::ServletResponse::resetBuffer ( )

Clears the current payload. Does not clear any rwsf::ServletOutputStream objects associated with this response. To clear an output stream, call rwsf::ServletOutputStream::reset().

virtual void rwsf::ServletResponse::setContentLength ( int  len)
virtual

Sets the HTTP Content-Length header, which indicates the size of the Content-body.

Reimplemented in rwsf::HttpServletResponse.

virtual void rwsf::ServletResponse::setContentType ( const std::string &  type)
virtual

Sets the HTTP Content-Type header of the response. The content type may include the type of character encoding used; for example, text/html;charset=ISO-8859-4.

Reimplemented in rwsf::HttpServletResponse.

void rwsf::ServletResponse::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 © 2020 Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is registered trademark of Rogue Wave Software, Inc. in the United States and other countries, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.