Java - JSP - Shopping Cart

Creating a shopping cart jsp webpage in java.

Page

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

<%@page import="java.math.BigDecimal"%>
<%@page import="model.entities.UserCartPK"%>
<%@page import="model.entities.UserAccount"%>
<%@page import="model.entities.UserCart"%>
<%@page import="model.entities.ItemCategory"%>
<%@page import="model.entities.ItemCatalog"%>
<%@page import="javax.persistence.Persistence"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.List"%>
<%@page import="javax.persistence.Query"%>
<%@page import="javax.persistence.EntityManager"%>
<%@page import="javax.persistence.EntityManagerFactory"%>
<%@page import="model.entities.UserInfo"%>
<%@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>Cart</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");
                    BigDecimal grandTotal = new BigDecimal(0);
                    BigDecimal qty = new BigDecimal(0);
                    BigDecimal price = new BigDecimal(0);
                    BigDecimal subTotal = new BigDecimal(0);

                    Query query = em.createNamedQuery("UserCart.findByUserid");
                    query.setParameter("userid",userID);
                    List resultList = query.getResultList();
                    if(!resultList.isEmpty()){

                        out.print("<div class='item_cart'><b>ITEM NAME</b>");
                        out.print("<remove><b>-</b></remove>");
                        out.print("<subtotal><b>SUBTOTAL</b></subtotal>");
                        out.print("<price><b>PRICE</b></price>");
                        out.print("<qty><b>QUANTITY</b></qty>");
                        out.print("</div>"); 
                        Iterator it = resultList.iterator();

                        while(it.hasNext()){
                            UserCart item = (UserCart) it.next();
                            int quantity = item.getQty();
                            qty = new java.math.BigDecimal(String.valueOf(quantity));
                            price = (BigDecimal) session.getAttribute("itemprice"+item.getUserCartPK().getItemid());
                            subTotal = price.multiply(qty);
                            grandTotal = grandTotal.add(subTotal);

                            out.print("<div class='item_cart'>");
                            out.print(session.getAttribute("itemname"+item.getUserCartPK().getItemid()));
                            out.print("<remove><form>");
                            out.print("<input type='text' hidden name='itemid' value='"+item.getUserCartPK().getItemid()+"'/>");
                            out.print("<input type='submit' name='submit' formaction='Controller' value='-'/>");
                            out.print("</form></remove>");
                            out.print("<subtotal>$" + subTotal + "</subtotal>");
                            out.print("<price>$" + price + "</price>");
                            out.print("<qty>" + qty + "</qty>");
                            out.print("</div>");                 
                        }

                        out.print("<div class='item_cart'><b>TOTAL</b>");
                        out.print("<grandtotals><b>$" + grandTotal + "</b></grandtotals>");
                        out.print("</div>"); 
                        out.print("<div class=\"item_cart\"><form><input class='right' type='submit' name='submit' value='Checkout' formaction='Controller'/></form></div>");
                    }
                    else{
                        out.print("<div class=\"item_cart\">You have no items in your cart.</table></div>");
                    }
                %>

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