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"<html>"); writer->print(S"<head><title>C++ .NET Example Servlet</title></head>"); writer->println(S"<body>"); writer->print(S"<h1>Hello from C++ .NET Servlet.</h1>"); writer->println(S"</body>"); writer->println(S"</html>"); } ================================================== 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<stec::iws::Request *>(_request); stec::iws::Response *response = dynamic_cast<stec::iws::Response *>(_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); }