/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development * and Distribution License("CDDL") (collectively, the "License"). You * may not use this file except in compliance with the License. You can * obtain a copy of the License at * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html * or packager/legal/LICENSE.txt. See the License for the specific * language governing permissions and limitations under the License. * * When distributing the software, include this License Header Notice in each * file and include the License file at packager/legal/LICENSE.txt. * * GPL Classpath Exception: * Oracle designates this particular file as subject to the "Classpath" * exception as provided by Oracle in the GPL Version 2 section of the License * file that accompanied this code. * * Modifications: * If applicable, add the following below the License Header, with the fields * enclosed by brackets [] replaced by your own identifying information: * "Portions Copyright [year] [name of copyright owner]" * * Contributor(s): * If you wish your version of this file to be governed by only the CDDL or * only the GPL Version 2, indicate your decision by adding "[Contributor] * elects to include this software in this distribution under the [CDDL or GPL * Version 2] license." If you don't indicate a single choice of license, a * recipient has the option to distribute your version of this file under * either the CDDL, the GPL Version 2 or to extend the choice of license to * its licensees as provided above. However, if you add GPL Version 2 code * and therefore, elected the GPL Version 2 license, then the option applies * only if the new code is made subject to such option by the copyright * holder. */ package myapp; import java.io.*; import java.io.PrintWriter; import java.util.Enumeration; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.logging.*; import com.sun.logging.*; /** * Simple servlet to validate that the Hello, World example can * execute servlets. In the web application deployment descriptor, * this servlet must be mapped to correspond to the link in the * "index.html" file. * * @author Craig R. McClanahan */ public final class HelloServlet extends HttpServlet { private Logger logger = Logger.getLogger(getClass().getName()); //private Logger logger1 = Logger.getLogger(LogDomains.CORE_LOGGER); //private Logger logger2 = Logger.getLogger(LogDomains.LOADER_LOGGER); public static final Logger logger1 = Logger.getLogger("testlogger.abc"); // Web Container loggers public static final Logger logger2 = Logger.getLogger("javax.enterprise.system.container.web.testlogger"); public static final Logger logger3 = Logger.getLogger("org.apache.catalina.testlogger"); public static final Logger logger4 = Logger.getLogger("org.apache.coyote.testlogger"); public static final Logger logger5 = Logger.getLogger("org.apache.jasper.testlogger"); /** * Respond to a GET request for the content produced by * this servlet. * * @param request The servlet request we are processing * @param response The servlet response we are producing * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet error occurs */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { OutputStreamWriter os = new OutputStreamWriter(System.out); os.write("Hello"); os.flush(); System.out.println("Servlet processing do get1.."); logger.finest("...finest..."); logger.fine("...fine..."); logger.finer("...finer..."); logger.severe("...severe..."); logger.warning("...warning..."); logger.info("...info..."); logger.config("...config..."); System.err.println("Servlet processing do get4.."); logger1.finest(".1..finest..."); logger1.fine(".1..fine..."); logger1.finer(".1..finer..."); logger1.severe(".1..severe..."); logger1.warning(".1..warning..."); logger1.info(".1..info..."); logger1.config(".1..config..."); logger2.finest(".2..finest..."); logger2.fine(".2..fine..."); logger2.finer(".2..finer..."); logger2.severe(".2..severe..."); logger2.warning(".2..warning..."); logger2.info(".2..info..."); logger2.config(".2..config..."); logger3.finest(".3..finest..."); logger3.fine(".3..fine..."); logger3.finer(".3..finer..."); logger3.severe(".3..severe..."); logger3.warning(".3..warning..."); logger3.info(".3..info..."); logger3.config(".3..config..."); logger4.finest(".4..finest..."); logger4.fine(".4..fine..."); logger4.finer(".4..finer..."); logger4.severe(".4..severe..."); logger4.warning(".4..warning..."); logger4.info(".4..info..."); logger4.config(".4..config..."); logger5.finest(".5..finest..."); logger5.fine(".5..fine..."); logger5.finer(".5..finer..."); logger5.severe(".5..severe..."); logger5.warning(".5..warning..."); logger5.info(".5..info..."); logger5.config(".5..config..."); response.setContentType("text/html"); PrintWriter writer = response.getWriter(); writer.println(""); writer.println(""); writer.println("Sample Application Servlet Page"); writer.println(""); writer.println(""); writer.println(""); writer.println(""); writer.println(""); writer.println(""); writer.println(""); writer.println("
"); //writer.println(""); writer.println(""); writer.println("

Sample Application Servlet

"); writer.println("This is the output of a servlet that is part of"); writer.println("the Hello, World application. It displays the"); writer.println("request headers from the request we are currently"); writer.println("processing."); writer.println("
"); writer.println(""); Enumeration names = request.getHeaderNames(); while (names.hasMoreElements()) { String name = (String) names.nextElement(); writer.println(""); writer.println(" "); writer.println(" "); writer.println(""); } writer.println("
" + name + ":" + request.getHeader(name) + "
"); writer.println(""); writer.println(""); } }