Java Reference
In-Depth Information
L ISTING 5.4
Continued
out.println(“<html>”);
out.println(“<head><title>Session Servlet</title></head>”);
out.println(“<body>”);
out.println(“<H2>Contents of Shopping Cart</H2>”);
// Display the submitted movie array
for ( int x = 0; x < movies.length; x++ ) {
out.println(movies[x] + “<BR>”);
}
// Create a form to submit an order
out.println(“<FORM action=/djs/servlet/HttpSessionServlet “ +
“METHOD=GET>”);
out.println(“<input type=\”Submit\” name=\”add\” value=” +
“\”Proceed to Checkout\”></FORM>”);
out.println(“</body></html>”);
out.close();
}
//Get Servlet information
public String getServletInfo() {
return “HttpSessionServlet Information”;
}
}
To invoke this servlet, you need to create an HTML file that will make a POST request contain-
ing a list of selected movies. The HTML file that contains this form is in Listing 5.5.
L ISTING 5.5
HtmlSessionServlet.html
<HTML>
<HEAD>
<TITLE>
Movie List
</TITLE>
</HEAD>
<BODY>
<H2>Select From Available Movies</h2>
<FORM ACTION=http://localhost/djs/servlet/HttpSessionServlet method=POST>
Search WWH ::




Custom Search