cppHelloServlet.cpp
/*
* Copyright (c) 1998-2005 Servertec. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* THIS NOTICE MUST NOT BE ALTERED NOR REMOVED.
*
* CopyrightVersion 1.0
*/
#include "stdafx.h"
#include "cppHelloServlet.h"
using namespace iws::net::cpp::examples;
void cppHelloServlet::service(stec::iws::Request *_request, stec::iws::Response *_response)
{
PrintWriter *writer = _response->getWriter();
writer->println(S"");
writer->print(S"C++ .NET Example Servlet");
writer->println(S"");
writer->print(S"Hello from C++ .NET Servlet.
");
writer->println(S"");
writer->println(S"");
}
==================================================
BaseServlet.cpp
/*
* Copyright (c) 1998-2005 Servertec. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* THIS NOTICE MUST NOT BE ALTERED NOR REMOVED.
*
* CopyrightVersion 1.0
*/
#include "stdafx.h"
#include "BaseServlet.h"
using namespace java::util;
using namespace java::io;
using namespace iws::net::cpp::examples;
void BaseServlet::service(stec::iws::Request *_request, stec::iws::Response *_response)
{
}
void BaseServlet::service(HttpServletRequest *_request, HttpServletResponse *_response)
{
stec::iws::Request *request = dynamic_cast(_request);
stec::iws::Response *response = dynamic_cast(_response);
String *charset = request->getCharset();
if(charset == NULL)
{
charset = stec::iws::iws::getDefaultCharset();
}
String *content_type = S"text/html";
if(charset != NULL)
{
content_type = String::Concat(content_type, S"; charset=");
content_type = String::Concat(content_type, charset);
}
_response->setContentType(content_type);
String *language;
Locale *locale = request->getLocale();
if(locale == NULL)
{
language = stec::iws::iws::getDefaultLanguage();
}
else
{
language = locale->ToString();
}
if(language != NULL)
{
_response->setHeader(S"Content-Language", language->Replace('_', '-'));
}
service(request, response);
}