// Copyright (C)1995-2002 ASH multimedia lab. http://ash.jp/
package jp.ash.example;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
/** 初期パラメータ表示サーブレット **/
public class ParamServlet extends HttpServlet {
public void service (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
PrintWriter out;
Enumeration enum;
String key, val;
res.setContentType("text/html; charset=Shift_JIS");
out = res.getWriter();
out.println("<html><body>");
out.println("<h1>サーブレットの初期パラメータ</h1>");
out.println("<h2>web.xmlのInitParameterの表示</h2>");
enum = getInitParameterNames();
if (enum != null) {
out.println("<table border=\"2\">");
out.println("<tr><th>key</th><th>val</th></tr>");
while (enum.hasMoreElements()) {
key = (String) enum.nextElement();
val = getInitParameter(key);
out.println("<tr><td>"+key+"</td><td>"+val+"</td></tr>");
}
out.println("</table>");
}
out.println("</body></html>");
}
}
|