001    /*
002    * Copyright 2004 The Apache Software Foundation
003    *
004    * Licensed under the Apache License, Version 2.0 (the "License");
005    * you may not use this file except in compliance with the License.
006    * You may obtain a copy of the License at
007    *
008    *     http://www.apache.org/licenses/LICENSE-2.0
009    *
010    * Unless required by applicable law or agreed to in writing, software
011    * distributed under the License is distributed on an "AS IS" BASIS,
012    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013    * See the License for the specific language governing permissions and
014    * limitations under the License.
015    */
016    /* $Id: HelloWorldExample.java 434248 2006-08-23 23:27:37Z jdillon $
017     *
018     */
019    
020    import java.io.*;
021    import java.text.*;
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