rwsf::ServletOutputStream std::basic_ostream<char>
#include <rwsf/servlet/ServletOutputStream.h>
rwsf::ServletOutputStream provides a simple mechanism for writing a response. The class has a set of print() and println() functions which duplicate the corresponding methods in the Java ServletOutputStream class. A print() method writes the argument to the output stream. A println() method writes the argument and a newline to the output stream. Note that the print(bool) and println(bool) functions follow Java conventions and produce "true" and "false" rather than 1 and 0.
To construct an instance of this class, call either function getOutputStream() or function getWriter() of rwsf::ServletResponse.
#include <rwsf/servlet/http/HttpServlet.h> #include <rwsf/servlet/http/HttpServletRequest.h> #include <rwsf/servlet/http/HttpServletResponse.h> #include <rwsf/cstring.h> #include <iomanip> #include <stdlib.h> #include <math.h> class DivideNumbers : public rwsf::HttpServlet { protected: virtual void doGet(rwsf::HttpServletRequest& request, rwsf::HttpServletResponse& response) { doPost(request,response); }; virtual void doPost(rwsf::HttpServletRequest& request, rwsf::HttpServletResponse& response); }; rwsf_DEFINE_SERVLET(DivideNumbers) void DivideNumbers::doPost (rwsf::HttpServletRequest& request, rwsf::HttpServletResponse& response) { std::string num = request.getParameter("numerator"); std::string denom = request.getParameter("denominator"); std::string prec = request.getParameter("precision"); double n = strtod(num.data(), (char**)NULL); double d = strtod(denom.data(), (char**)NULL); if (d == 0 || n == 0 || fabs(d) == HUGE_VAL || fabs(n) == HUGE_VAL) { response.sendError(500); return; } double result = n/d; int p = atoi(prec.data()); if (p == 0) p = 3; response.setContentType("text/xml"); rwsf::ServletOutputStream& out = response.getOutputStream(); }
virtual ~ServletOutputStream();
Destructor.
std::string getBuffer() const;
Returns the contents of the output buffer as a string.
rwsf::ServletOutputStream& print(bool b);
Appends a bool value to the payload. This function appends the string "true" or the string "false" rather than 1 or 0.
rwsf::ServletOutputStream& print(char c);
Appends a char value to the payload.
rwsf::ServletOutputStream& print(unsigned char uc);
Appends an unsigned char to the payload.
rwsf::ServletOutputStream& print(short s);
Appends a short value to the payload.
rwsf::ServletOutputStream& print(unsigned short us);
Appends an unsigned short value to the payload.
rwsf::ServletOutputStream& print(int i);
Appends an int value to the payload.
rwsf::ServletOutputStream& print(unsigned int ui);
Appends an unsigned int to the payload.
rwsf::ServletOutputStream& print(long l);
Appends a long value to the payload.
rwsf::ServletOutputStream& print(unsigned long ul);
Appends an unsigned long value to the payload.
rwsf::ServletOutputStream& print(float f);
Appends a float value to the payload.
rwsf::ServletOutputStream& print(double d);
Appends a double value to the payload.
rwsf::ServletOutputStream& print(const char *cs);
Appends a NULL terminated string value to the payload.
rwsf::ServletOutputStream& print(const unsigned char *ucs);
Appends a NULL terminated string value to the payload.
rwsf::ServletOutputStream& print(const std::string& str);
Appends an std::string value to the payload.
rwsf::ServletOutputStream& println();
Appends a newline value to the payload.
rwsf::ServletOutputStream& println(bool b);
Appends a bool value followed by a newline to the payload. This function appends the string "true" or the string "false" rather than 1 or 0.
rwsf::ServletOutputStream& println(char c);
Appends a char value followed by a newline to the payload.
rwsf::ServletOutputStream& println(unsigned char uc);
Appends an unsigned char value followed by a newline to the payload.
rwsf::ServletOutputStream& println(short s);
Appends a short value followed by a newline to the payload.
rwsf::ServletOutputStream& println(unsigned short us);
Appends an unsigned short value followed by a newline to the payload.
rwsf::ServletOutputStream& println(int i);
Appends an int value followed by a newline to the payload.
rwsf::ServletOutputStream& println(unsigned int ui);
Appends an unsigned int value followed by a newline to the payload.
rwsf::ServletOutputStream& println(long l);
Appends a long value followed by a newline to the payload.
rwsf::ServletOutputStream& println(unsigned long ul);
Appends an unsigned long value followed by a newline to the payload.
rwsf::ServletOutputStream& println(float f);
Appends a float value followed by a newline to the payload.
rwsf::ServletOutputStream& println(double d);
Appends a double value followed by a newline to the payload.
rwsf::ServletOutputStream& println(const char *cs);
Appends a NULL terminated string value followed by a newline to the payload.
rwsf::ServletOutputStream& println(const unsigned char *ucs);
Appends a NULL terminated string value followed by a newline to the payload.
rwsf::ServletOutputStream& println(const std::string& str);
Appends a std::string value followed by a newline to the payload.
void reset();
Clears any internal buffer.
void reset(const std::string& newContents);
Clears any internal buffer, then sets the contents of the internal buffer to newContents.
©2004-2007 Copyright Quovadx, Inc. All Rights Reserved.
Quovadx and Rogue Wave are registered trademarks of Quovadx, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.