1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import java.io.IOException;
22 import java.io.PrintWriter;
23 import java.util.ResourceBundle;
24
25 import javax.servlet.ServletException;
26 import javax.servlet.http.HttpServlet;
27 import javax.servlet.http.HttpServletRequest;
28 import javax.servlet.http.HttpServletResponse;
29
30
31
32
33
34
35
36 public class HelloWorldExample extends HttpServlet {
37
38
39 public void doGet(HttpServletRequest request,
40 HttpServletResponse response)
41 throws IOException, ServletException {
42 ResourceBundle rb =
43 ResourceBundle.getBundle("LocalStrings", request.getLocale());
44 response.setContentType("text/html");
45 PrintWriter out = response.getWriter();
46
47 out.println("<html>");
48 out.println("<head>");
49
50 String title = rb.getString("helloworld.title");
51
52 out.println("<title>" + title + "</title>");
53 out.println("</head>");
54 out.println("<body bgcolor=\"white\">");
55
56
57
58
59
60
61
62
63
64
65 out.println("<a href=\"../helloworld.html\">");
66 out.println("<img src=\"../images/code.gif\" height=24 " +
67 "width=24 align=right border=0 alt=\"view code\"></a>");
68 out.println("<a href=\"../index.html\">");
69 out.println("<img src=\"../images/return.gif\" height=24 " +
70 "width=24 align=right border=0 alt=\"return\"></a>");
71 out.println("<h1>" + title + "</h1>");
72 out.println("</body>");
73 out.println("</html>");
74 }
75 }
76
77
78