Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 771 | blopes | 1 | |
| 2 | /* |
||
| 3 | * Licensed to the Apache Software Foundation (ASF) under one or more |
||
| 4 | * contributor license agreements. See the NOTICE file distributed with |
||
| 5 | * this work for additional information regarding copyright ownership. |
||
| 6 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
||
| 7 | * (the "License"); you may not use this file except in compliance with |
||
| 8 | * the License. You may obtain a copy of the License at |
||
| 9 | * |
||
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
| 11 | * |
||
| 12 | * Unless required by applicable law or agreed to in writing, software |
||
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
| 15 | * See the License for the specific language governing permissions and |
||
| 16 | * limitations under the License. |
||
| 17 | */ |
||
| 18 | import java.io.IOException; |
||
| 19 | import java.io.PrintWriter; |
||
| 20 | import java.util.ResourceBundle; |
||
| 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 | * The simplest possible servlet. |
||
| 29 | */ |
||
| 30 | public class HelloWorldExample extends HttpServlet { |
||
| 31 | |||
| 32 | private static final long serialVersionUID = 1L; |
||
| 33 | |||
| 34 | @Override |
||
| 35 | public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { |
||
| 36 | ResourceBundle rb = ResourceBundle.getBundle("LocalStrings", request.getLocale()); |
||
| 37 | response.setContentType("text/html"); |
||
| 38 | response.setCharacterEncoding("UTF-8"); |
||
| 39 | PrintWriter out = response.getWriter(); |
||
| 40 | |||
| 41 | out.println("<!DOCTYPE html><html>"); |
||
| 42 | out.println("<head>"); |
||
| 43 | out.println("<meta charset=\"UTF-8\" />"); |
||
| 44 | |||
| 45 | String title = rb.getString("helloworld.title"); |
||
| 46 | |||
| 47 | out.println("<title>" + title + "</title>"); |
||
| 48 | out.println("</head>"); |
||
| 49 | out.println("<body bgcolor=\"white\">"); |
||
| 50 | |||
| 51 | // note that all links are created to be relative. this |
||
| 52 | // ensures that we can move the web application that this |
||
| 53 | // servlet belongs to a different place in the url |
||
| 54 | // tree and not have any harmful side effects. |
||
| 55 | |||
| 56 | // XXX |
||
| 57 | // making these absolute till we work out the |
||
| 58 | // addition of a PathInfo issue |
||
| 59 | |||
| 60 | out.println("<a href=\"../helloworld.html\">"); |
||
| 61 | out.println( |
||
| 62 | "<img src=\"../images/code.gif\" height=24 " + "width=24 align=right border=0 alt=\"view code\"></a>"); |
||
| 63 | out.println("<a href=\"../index.html\">"); |
||
| 64 | out.println( |
||
| 65 | "<img src=\"../images/return.gif\" height=24 " + "width=24 align=right border=0 alt=\"return\"></a>"); |
||
| 66 | out.println("<h1>" + title + "</h1>"); |
||
| 67 | out.println("</body>"); |
||
| 68 | out.println("</html>"); |
||
| 69 | } |
||
| 70 | } |
||
| 71 |