Java Reference
In-Depth Information
L ISTING 5.1
Continued
// These values would be uniquely generated
out.println(“<INPUT TYPE=\”hidden\” NAME=” +
“\”user\” VALUE=\”James\”>”);
out.println(“<INPUT TYPE=\”hidden\” NAME=” +
“\”session\” VALUE=\”12892\”>”);
// These are the currently selected movies
out.println(“<INPUT TYPE=\”hidden\” NAME=” +
“\”movie\” VALUE=\”Happy Gilmore\”>”);
out.println(“<INPUT TYPE=\”hidden\” NAME=” +
“\”movie\” VALUE=\”So I Married an Axe Murderer\”>”);
out.println(“<INPUT TYPE=\”hidden\” NAME=” +
“\”movie\” VALUE=\”Jaws\”>”);
out.println(“<INPUT TYPE=\”submit\” VALUE=” +
“\”Submit\”>”);
out.println(“</FORM>”);
out.println(“</body></html>”);
out.close();
}
//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>HiddenFieldServlet” +
“</title></head>”);
out.println(“<body>”);
// Get the hidden inputs and echo them
String user = request.getParameter(“user”);
String session = request.getParameter(“session”);
out.println(“<H3>” + user +
“, the contents of your Shopping Basket are:</H3><BR>”);
Search WWH ::




Custom Search