| 1 | /* | 
|---|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more | 
|---|
| 3 | * contributor license agreements.  See the NOTICE file distributed with | 
|---|
| 4 | * this work for additional information regarding copyright ownership. | 
|---|
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 | 
|---|
| 6 | * (the "License"); you may not use this file except in compliance with | 
|---|
| 7 | * the License.  You may obtain a copy of the License at | 
|---|
| 8 | * | 
|---|
| 9 | *      http://www.apache.org/licenses/LICENSE-2.0 | 
|---|
| 10 | * | 
|---|
| 11 | * Unless required by applicable law or agreed to in writing, software | 
|---|
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, | 
|---|
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|---|
| 14 | * See the License for the specific language governing permissions and | 
|---|
| 15 | * limitations under the License. | 
|---|
| 16 | */ | 
|---|
| 17 |  | 
|---|
| 18 | package mypackage; | 
|---|
| 19 |  | 
|---|
| 20 | import java.io.IOException; | 
|---|
| 21 | import java.io.PrintWriter; | 
|---|
| 22 | import java.util.Enumeration; | 
|---|
| 23 | import javax.servlet.ServletException; | 
|---|
| 24 | import javax.servlet.http.HttpServlet; | 
|---|
| 25 | import javax.servlet.http.HttpServletRequest; | 
|---|
| 26 | import javax.servlet.http.HttpServletResponse; | 
|---|
| 27 |  | 
|---|
| 28 |  | 
|---|
| 29 | /** | 
|---|
| 30 | * Simple servlet to validate that the Hello, World example can | 
|---|
| 31 | * execute servlets.  In the web application deployment descriptor, | 
|---|
| 32 | * this servlet must be mapped to correspond to the link in the | 
|---|
| 33 | * "index.html" file. | 
|---|
| 34 | * | 
|---|
| 35 | * @author Craig R. McClanahan <Craig.McClanahan@eng.sun.com> | 
|---|
| 36 | */ | 
|---|
| 37 |  | 
|---|
| 38 | public final class Hello extends HttpServlet { | 
|---|
| 39 |  | 
|---|
| 40 |  | 
|---|
| 41 | /** | 
|---|
| 42 | * Respond to a GET request for the content produced by | 
|---|
| 43 | * this servlet. | 
|---|
| 44 | * | 
|---|
| 45 | * @param request The servlet request we are processing | 
|---|
| 46 | * @param response The servlet response we are producing | 
|---|
| 47 | * | 
|---|
| 48 | * @exception IOException if an input/output error occurs | 
|---|
| 49 | * @exception ServletException if a servlet error occurs | 
|---|
| 50 | */ | 
|---|
| 51 | public void doGet(HttpServletRequest request, | 
|---|
| 52 | HttpServletResponse response) | 
|---|
| 53 | throws IOException, ServletException { | 
|---|
| 54 |  | 
|---|
| 55 | response.setContentType("text/html"); | 
|---|
| 56 | PrintWriter writer = response.getWriter(); | 
|---|
| 57 |  | 
|---|
| 58 | writer.println("<html>"); | 
|---|
| 59 | writer.println("<head>"); | 
|---|
| 60 | writer.println("<title>Sample Application Servlet Page</title>"); | 
|---|
| 61 | writer.println("</head>"); | 
|---|
| 62 | writer.println("<body bgcolor=white>"); | 
|---|
| 63 |  | 
|---|
| 64 | writer.println("<table border=\"0\">"); | 
|---|
| 65 | writer.println("<tr>"); | 
|---|
| 66 | writer.println("<td>"); | 
|---|
| 67 | writer.println("<img src=\"images/tomcat.gif\">"); | 
|---|
| 68 | writer.println("</td>"); | 
|---|
| 69 | writer.println("<td>"); | 
|---|
| 70 | writer.println("<h1>Sample Application Servlet</h1>"); | 
|---|
| 71 | writer.println("This is the output of a servlet that is part of"); | 
|---|
| 72 | writer.println("the Hello, World application."); | 
|---|
| 73 | writer.println("</td>"); | 
|---|
| 74 | writer.println("</tr>"); | 
|---|
| 75 | writer.println("</table>"); | 
|---|
| 76 |  | 
|---|
| 77 | writer.println("</body>"); | 
|---|
| 78 | writer.println("</html>"); | 
|---|
| 79 |  | 
|---|
| 80 | } | 
|---|
| 81 |  | 
|---|
| 82 |  | 
|---|
| 83 | } | 
|---|