import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SessionTest extends HttpServlet implements HtmlStrings {
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
HttpSession ses = req.getSession(false);
res.setContentType("text/html");
PrintWriter out = res.getWriter();
String firstName = (String)ses.getAttribute("firstName");
String lastName = (String)ses.getAttribute("lastName");
int numPick = ((Integer)ses.getAttribute("numPick")).intValue();
double amount = ((Double)ses.getAttribute("amount")).doubleValue();
double totalCost = ((Double)ses.getAttribute("totalCost")).doubleValue();
StringBuffer sb = new StringBuffer();
sb.append("Your session values are: <br>");
sb.append("Firstname: "+firstName+"<br>");
sb.append("Lastname: "+lastName+"<br>");
sb.append("Your number picked: "+numPick+"<br>");
sb.append("The amount you picked: "+amount+"<br>");
sb.append("Your total is: "+totalCost+"<br>");
out.println(sb);
out.close();
}
public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
doPost(req, res);
}
};