Java Reference
In-Depth Information
L ISTING 4.1
Continued
super.init(config);
}
//Process the HTTP Get request
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType(“text/html”);
PrintWriter out = response.getWriter();
out.println(“<html>”);
out.println(“<head><title>FormServlet</title></head>”);
out.println(“<body>”);
// Get all the parameter names
Enumeration parameters = request.getParameterNames();
String param = null;
// Iterate over the names, getting the parameters
while ( parameters.hasMoreElements() ) {
param = (String)parameters.nextElement();
out.println(“<BOLD>” + param +
“ : “ + request.getParameter(param) +
“</BOLD><BR>”);
}
out.println(“</body></html>”);
out.close();
4
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType(“text/html”);
PrintWriter out = response.getWriter();
out.println(“<html>”);
out.println(“<head><title>FormServlet</title></head>”);
out.println(“<body>”);
// Get all the parameter names
Enumeration parameters = request.getParameterNames();
 
Search WWH ::




Custom Search