Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
771 blopes 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
package mypackage;
18
 
19
import java.io.IOException;
20
import java.io.PrintWriter;
21
 
22
import javax.servlet.ServletException;
23
import javax.servlet.http.HttpServlet;
24
import javax.servlet.http.HttpServletRequest;
25
import javax.servlet.http.HttpServletResponse;
26
 
27
 
28
/**
29
 * Simple servlet to validate that the Hello, World example can
30
 * execute servlets.  In the web application deployment descriptor,
31
 * this servlet must be mapped to correspond to the link in the
32
 * "index.html" file.
33
 */
34
 
35
public final class Hello extends HttpServlet {
36
 
37
    private static final long serialVersionUID = 1L;
38
 
39
    /**
40
     * Respond to a GET request for the content produced by
41
     * this servlet.
42
     *
43
     * @param request The servlet request we are processing
44
     * @param response The servlet response we are producing
45
     *
46
     * @exception IOException if an input/output error occurs
47
     * @exception ServletException if a servlet error occurs
48
     */
49
    @Override
50
    public void doGet(HttpServletRequest request,
51
                      HttpServletResponse response)
52
      throws IOException, ServletException {
53
 
54
        response.setContentType("text/html");
55
        response.setCharacterEncoding("UTF-8");
56
        try (PrintWriter writer = response.getWriter()) {
57
 
58
            writer.println("<!DOCTYPE html><html>");
59
            writer.println("<head>");
60
            writer.println("<meta charset=\"UTF-8\" />");
61
            writer.println("<title>Sample Application Servlet Page</title>");
62
            writer.println("</head>");
63
            writer.println("<body>");
64
 
65
 
66
            writer.println("<div style=\"float: left; padding: 10px;\">");
67
            writer.println("<img src=\"images/tomcat.gif\" alt=\"\" />");
68
            writer.println("</div>");
69
            writer.println("<h1>Sample Application Servlet</h1>");
70
            writer.println("<p>");
71
            writer.println("This is the output of a servlet that is part of");
72
            writer.println("the Hello, World application.");
73
            writer.println("</p>");
74
 
75
            writer.println("</body>");
76
            writer.println("</html>");
77
        }
78
    }
79
 
80
 
81
}