csHelloServlet.cs /* * 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 */ using System; using PrintWriter = java.io.PrintWriter; using DString = stec.lang.DString; using Utils = stec.iws.Utils; using Request = stec.iws.Request; using Response = stec.iws.Response; namespace iws.net.cs.examples { public class csHelloServlet : BaseServlet { public csHelloServlet() { } override public void service(Request _request, Response _response) { PrintWriter writer = _response.getWriter(); writer.println("<html>"); writer.println("<head><title>C# .NET Example Servlet</title></head>"); writer.println("<body>"); writer.println("<h1>Hello from C# .NET Servlet.</h1>"); writer.println("</body>"); writer.println("</html>"); } } } ================================================== BaseServlet.cs /* * 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 */ using System; using Locale = java.util.Locale; using HttpServlet = javax.servlet.http.HttpServlet; using HttpServletRequest = javax.servlet.http.HttpServletRequest; using HttpServletResponse = javax.servlet.http.HttpServletResponse; using Request = stec.iws.Request; using Response = stec.iws.Response; namespace iws.net.cs.examples { public abstract class BaseServlet : HttpServlet { public BaseServlet() { } override public void service(HttpServletRequest _request, HttpServletResponse _response) { Request request = (Request)_request; Response response = (Response)_response; String charset = request.getCharset(); if(charset == null) { charset = stec.iws.iws.getDefaultCharset(); } String content_type = "text/html"; if(charset != null) { content_type = content_type + "; charset=" + 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("Content-Language", language.Replace('_', '-')); } service(request, response); } public abstract void service(Request _request, Response _response); } }