public class SampleServlet extends HttpServlet {
private HashMap map;
public void init( ServletConfig config ) throws ServletException {
super.init(config);
map = new HashMap();
Enumeration e = config.getInitParameterNames();
while(e.hasMoreElements()) {
String name= (String)e.nextElement();
map.put(name, config.getInitParameter(name));
}
}
public void doGet( HttpServletRequest request, HttpServletResponse response )
throws ServletException,IOException {
response.setContentType("text/html;charset=Windows-31J");
PrintWriter out = response.getWriter();
out.println("<html><body>");
Iterator it = map.keySet().iterator();
while (it.hasNext()) {
String name = (String)it.next();
out.println(name + "=" + map.get(name) + "<br>");
}
out.println("</body></html>");
}
}
|