001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 /* $Id: HelloWorldExample.java 514091 2007-03-03 06:26:39Z jdillon $ 018 * 019 */ 020 021 import java.io.*; 022 import java.util.*; 023 import javax.servlet.*; 024 import javax.servlet.http.*; 025 026 /** 027 * The simplest possible servlet. 028 * 029 * @author James Duncan Davidson 030 */ 031 032 public class HelloWorldExample extends HttpServlet { 033 034 035 public void doGet(HttpServletRequest request, 036 HttpServletResponse response) 037 throws IOException, ServletException 038 { 039 ResourceBundle rb = 040 ResourceBundle.getBundle("LocalStrings",request.getLocale()); 041 response.setContentType("text/html"); 042 PrintWriter out = response.getWriter(); 043 044 out.println("<html>"); 045 out.println("<head>"); 046 047 String title = rb.getString("helloworld.title"); 048 049 out.println("<title>" + title + "</title>"); 050 out.println("</head>"); 051 out.println("<body bgcolor=\"white\">"); 052 053 // note that all links are created to be relative. this 054 // ensures that we can move the web application that this 055 // servlet belongs to to a different place in the url 056 // tree and not have any harmful side effects. 057 058 // XXX 059 // making these absolute till we work out the 060 // addition of a PathInfo issue 061 062 out.println("<a href=\"../helloworld.html\">"); 063 out.println("<img src=\"../images/code.gif\" height=24 " + 064 "width=24 align=right border=0 alt=\"view code\"></a>"); 065 out.println("<a href=\"../index.html\">"); 066 out.println("<img src=\"../images/return.gif\" height=24 " + 067 "width=24 align=right border=0 alt=\"return\"></a>"); 068 out.println("<h1>" + title + "</h1>"); 069 out.println("</body>"); 070 out.println("</html>"); 071 } 072 } 073 074 075