Java - JSP - Checkout

Creating a checkout jsp webpage in java.

Page

<%-- 
    Document   : checkout
    Created on : 5-Nov-2014, 9:32:37 PM
    Author     : Steven Bartsch
--%>

<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Arrays"%>
<%@page import="model.entities.Orders"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.List"%>
<%@page import="javax.persistence.Persistence"%>
<%@page import="javax.persistence.Query"%>
<%@page import="javax.persistence.EntityManager"%>
<%@page import="javax.persistence.EntityManagerFactory"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="style.css"/>
        <title>Checkout</title>
    </head>
    <body>
        <div id="wrapper">
            <header>
                <div class="logo"><img src="images/bone_logo.png"/></div>
                <navigation>
                    <ul>
                        <li><a href="store.jsp">Store</a></li>
                        <li><a href="#">${userInfo.firstname} ${userInfo.lastname}</a></li>
                        <li><a href="cart.jsp">Shopping Cart</a></li>
                        <li><a href="login.jsp">Logout</a></li>
                    </ul>
                </navigation>
            </header>
            <div id="content">

                <%
                    EntityManagerFactory emf = Persistence.createEntityManagerFactory("SecondAssignmentPU");
                    EntityManager em = emf.createEntityManager();

                    Integer userID = (Integer)session.getAttribute("userID");

                    Query query = em.createNamedQuery("Orders.findByUserid");
                    query.setParameter("userid",userID);
                    List resultList = query.getResultList();
                    Iterator it = resultList.iterator();
                    boolean currentOrder = true;

                    while(it.hasNext())
                    {
                        Orders order = (Orders) it.next();
                        List<String> itemList = Arrays.asList((order.getItems()).split(","));
                        List<String> qtyList = Arrays.asList((order.getQuantities()).split(","));

                        if(currentOrder)
                        {
                            out.print("<div class='item_cart'><h1>Current Order</h1><h2>"+ order.getOrderdate() + "</h2>");
                            currentOrder = false;
                        }
                        else
                        {
                            out.print("<div class='item_cart'><h1>Past Order</h1><h2>"+ order.getOrderdate() + "</h2>");
                        }

                        out.print("<table width='100%' border='1'><tr><th>Item Name</th><th>Quantity</th><th>Price</th></tr>");

                        for(int ctr=0;ctr<itemList.size();ctr++)
                        {
                            out.print("<tr>");
                            out.print("<td>" + session.getAttribute("itemname"+itemList.get(ctr)) + "</td>");
                            out.print("<td>" + qtyList.get(ctr) + "</td>");
                            out.print("<td>" + session.getAttribute("itemprice"+itemList.get(ctr)) + "</td>");
                            out.print("</tr>");
                        }
                        out.print("</table></div>");                 
                    }
                    out.print("<div class=\"item_cart\"><form><input class='right' type='submit' name='submit' value='Cart' formaction='Controller'/></form></div>");
                %>

            </div>
        </div>
    </body>
</html>