|
1 package stx.libjava.tomcat; |
|
2 |
|
3 /* |
|
4 * Licensed to the Apache Software Foundation (ASF) under one or more |
|
5 * contributor license agreements. See the NOTICE file distributed with |
|
6 * this work for additional information regarding copyright ownership. |
|
7 * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
8 * (the "License"); you may not use this file except in compliance with |
|
9 * the License. You may obtain a copy of the License at |
|
10 * |
|
11 * http://www.apache.org/licenses/LICENSE-2.0 |
|
12 * |
|
13 * Unless required by applicable law or agreed to in writing, software |
|
14 * distributed under the License is distributed on an "AS IS" BASIS, |
|
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16 * See the License for the specific language governing permissions and |
|
17 * limitations under the License. |
|
18 */ |
|
19 /* $Id: HelloWorldExample.java 500674 2007-01-27 23:15:00Z markt $ |
|
20 * |
|
21 */ |
|
22 |
|
23 import java.io.*; |
|
24 import java.util.*; |
|
25 |
|
26 import javax.servlet.*; |
|
27 import javax.servlet.http.*; |
|
28 |
|
29 |
|
30 /** |
|
31 * The simplest possible servlet. |
|
32 * |
|
33 * @author James Duncan Davidson |
|
34 */ |
|
35 |
|
36 public class HelloWorldExampleJ extends HttpServlet { |
|
37 |
|
38 |
|
39 public void doGet(HttpServletRequest request, |
|
40 HttpServletResponse response) |
|
41 throws IOException, ServletException |
|
42 { |
|
43 ResourceBundle rb = |
|
44 ResourceBundle.getBundle("LocalStrings",request.getLocale()); |
|
45 response.setContentType("text/html"); |
|
46 PrintWriter out = response.getWriter(); |
|
47 |
|
48 out.println("<html>"); |
|
49 out.println("<head>"); |
|
50 |
|
51 String title = rb.getString("helloworld.title"); |
|
52 |
|
53 out.println("<title>" + title + "</title>"); |
|
54 out.println("</head>"); |
|
55 out.println("<body bgcolor=\"white\">"); |
|
56 |
|
57 // note that all links are created to be relative. this |
|
58 // ensures that we can move the web application that this |
|
59 // servlet belongs to to a different place in the url |
|
60 // tree and not have any harmful side effects. |
|
61 |
|
62 // XXX |
|
63 // making these absolute till we work out the |
|
64 // addition of a PathInfo issue |
|
65 |
|
66 out.println("<a href=\"../helloworld.html\">"); |
|
67 out.println("<img src=\"../images/code.gif\" height=24 " + |
|
68 "width=24 align=right border=0 alt=\"view code\"></a>"); |
|
69 out.println("<a href=\"../index.html\">"); |
|
70 out.println("<img src=\"../images/return.gif\" height=24 " + |
|
71 "width=24 align=right border=0 alt=\"return\"></a>"); |
|
72 out.println("<h1>" + title + "</h1>"); |
|
73 |
|
74 out.println("<table>"); |
|
75 Enumeration<Object> e = System.getProperties().keys(); |
|
76 while (e.hasMoreElements()) { |
|
77 String name = (String)e.nextElement(); |
|
78 out.println("<tr>"); |
|
79 if (name.equals("java.vm.version") || |
|
80 name.equals("java.vm.vendor") || |
|
81 name.equals("java.vm.name") || |
|
82 name.equals("java.vendor.url")) { |
|
83 out.println("<td><b>" + name + "</b<td>"); |
|
84 out.println(" : "); |
|
85 out.println("<td><b>" + System.getProperty(name) + "</b><td>"); |
|
86 } else { |
|
87 out.println("<td>" + name + "<tt>"); |
|
88 out.println(" : "); |
|
89 out.println("<td>" + System.getProperty(name) + "<td>"); |
|
90 } |
|
91 out.println("</tr>"); |
|
92 } |
|
93 out.println("</table>"); |
|
94 |
|
95 |
|
96 |
|
97 out.println("</body>"); |
|
98 out.println("</html>"); |
|
99 } |
|
100 } |
|
101 |
|
102 |
|
103 |