/*
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
BasicFormProcessor
BasicFormProcessor
BasicFormProcessor
/formProcessor
*/
import java.io.IOException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class BasicFormProcessor extends HttpServlet {
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws IOException {
ServletOutputStream out = res.getOutputStream();
res.setContentType("text/html");
out
.println("Basic Form Processor Output ");
out.println("");
out.println("Here is your Form Data
");
//extract the form data here
String title = req.getParameter("title");
String name = req.getParameter("name");
String city = req.getParameter("city");
String country = req.getParameter("country");
String tel = req.getParameter("tel");
String age = req.getParameter("age");
// extracting data from the checkbox field
String[] interests = req.getParameterValues("interests");
//output the data into a web page
out.println("Your title is " + title);
out.println("
Your name is " + name);
out.println("
Your city is " + city);
out.println("
Your country is " + country);
out.println("
Your tel is " + tel);
out.println("
Your interests include ");
for (int i = 0; i < interests.length; i++) {
out.println("- " + interests[i]);
}
out.println("
");
out.println("
Your age is " + age);
out.println("");
}
}