Change html with servlet to jsp

I’m having a bit of trouble with changing html pages to jsp with corresponding changes to the servlet. Usually I have not had an issue with this, but I am now trying to access the database and display tables.

Firstly, the html, corresponding servlet and dao which all works fine.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
        <head>
            <title>Bids</title>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        </head>
        <body>
            <img src="Images/AllBids_Logo.gif" width="295" height="42">
            <form action="controller" method="POST">
                <table width="494" height="63" border="1">
                    <tr>
                        <td width="70" height="28" bgcolor="#CCCCCC">
                            <select name="Bidders"  >
                                <option value="NULL">--Select a Bidder--</option>
                                <option value="M100">Anne Deems</option>
                                <option value="M200">Joe Black</option>
                                <option value="M300">Henry Brown</option>
                                <option value="M400">Sam Pink</option>
                                <option value="M500">Eva Blue</option>
                                <option value="M600">George Grey</option>
                                <option value="M700">James Green</option>
                                <option value="M800">Sally Orange</option>
                            </select> 
                        </td>
                        <td width="150" bgcolor="#CCCCCC">
                            <select name="Items" >
                                <option value="NULL">--Select An Item to Bid--</option>
                                <option value="P100">Acer Pentium 5 Laptop</option>
                                <option value="P200">Canon Inkjet Printer</option>
                                <option value="P300">Pioneer Blue Ray Recorder</option>
                                <option value="P400">20 cm ViewSonic LCD Color Monitor</option>
                            </select> 
                        </td>
                    </tr>
                    <tr bgcolor="#999999">
                        <td height="27" >
                            <input type="submit" name="Submit" value="Submit Bid">
                        </td>
                        <td bgcolor="#CCCCCC">
                            <input type="hidden" name="action" value="bid">
                            Enter Your Bid <input type="text" name="bidValue" size="10">
                        </td>
                    </tr>
                </table>

            <p>&nbsp;</p>
            </form>
        </body>
    </html>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title>View Bids</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
        <body>
            <img src="Images/AllBids_Logo.gif" width="295" height="42" alt="Logo">

            <form action="controller" method="POST">
                <table width="494" height="63" border="1">
                    <tr>
                        <td height="28" bgcolor="#CCCCCC"> 
                            <select name="Items" size="1">
                                <option value="NULL">--Select An Item to View Bids--</option>
                                <option value="P100">Acer Pentium 5 Laptop</option>
                                <option value="P200">Canon Inkjet Printer</option>
                                <option value="P300">Pioneer Blue Ray Recorder</option>
                                <option value="P400">20 cm ViewSonic LCD Color Monitor</option>
                            </select>
                            <input type="submit" name="Submit" value="Display Bids">
                        </td>
                    </tr>
                    <tr bgcolor="#999999">
                    <td height="27">
                        <input name="action" type="hidden" id="action" value="viewBids">
                    </td>
                </tr>
            </table>
        </form>
    </body>
</html>

This is the part of the servlet used, TableFormatter is a class located within a jar file in the Libraries package.

else if(action.equals("bid")){
    AuctionDAO dao = new AuctionDAO(ds);
    String itemID = request.getParameter("Items");
    String bidderID = request.getParameter("Bidders");
    double bidAmount = Double.parseDouble(request.getParameter("bidValue"));
    try{
        boolean bidRecorded = dao.regBid(itemID,bidderID,bidAmount);

        if(bidRecorded){
            out.println(formatPage("Your Bid for " + bidAmount + " was recorded"));
        }
        else {
            out.println(formatPage("Your Bid could not be registered"));
        }

    }catch(Exception ex){
        out.println(ex.getMessage());
    }// end catch
}// end if

else if(action.equals("viewBids")){
    // AuctionDAO dao = new AuctionDAO(ds);
    String itemID = request.getParameter("Items");
        try{
            ResultSet rs = dao.viewBids(itemID);
            out.print(TableFormatter.getData(rs));
        }catch(Exception ex){
            out.print(ex.getMessage());
        }// end catch
    }// end if

private String formatPage(String message){
    StringBuffer output = new StringBuffer();
    output.append("<html><head><title>Auction Admin</title></head><body>");
    output.append("<h1>" + message + "</h1>");
    output.append("</body>");
    output.append("</body></html>");
    return output.toString();
}

and then, the dao

public boolean regBid(String itemId, String bidderId, double amount)throws SQLException{
   int recsInserted = 0;
   regBidQuery();
   regBidPS.setString(1, bidderId);
   regBidPS.setString(2,itemId );
   regBidPS.setDouble(3, amount);
   recsInserted = regBidPS.executeUpdate();

   if(recsInserted == 1){
       return true;
   }
   else {
       return false;
   }
}

private void regBidQuery()throws SQLException{
    regBidPS = con.prepareStatement("INSERT INTO USER1.TBids " +
                                     "VALUES(?,?,?)");
}

Now, All of this works perfectly fine. My jsp pages even work with the new servlet code, but I can’t seem to get how to access the TableFormatter class or the regBids() method.

Jsp’s:

<%@page import="beans.Member"%>
<%@page import="java.util.List"%>
<%@page import="beans.Item"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Bids</title>
    </head>
    <body>
        <img src="Images/AllBids_Logo.gif" width="295" height="42">
        <form action="Controller" method="POST">
            <table border="1">
                <tbody>
                    <tr>
                        <td>
                            <select name="members">
                                <option value="NULL" selected="true">-- Select A Member --</option>
                                <% List<Member> members = (List<Member>) session.getAttribute("members");
                                    for (Member member : members){ %>
                                    <option value=<%= member.getMemberId()%> > <%= member.getMemberName()%></option>
                                <% } //end for %>
                            </select>
                        </td>
                        <td>
                            <select name="items">
                                <option value="NULL" selected="true">-- Select An Item To View Bids --</option>
                                <% List<Item> items = (List<Item>) session.getAttribute("items");
                                    for (Item item : items){ %>
                                    <option value=<%= item.getItemId()%> > <%= item.getItemName()%></option>
                                <% } //end for %>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <input type="submit" value="Submit Bid"/>
                        </td>
                        <td>
                            Enter Your Bid <input type="text" name="bidValue" size="10">
                        </td>
                    </tr>
                </tbody>
            </table>
            <input type="hidden" name="action" value="bid_view"/>
        </form>
    </body>
</html>


<%@page import="java.util.List"%>
<%@page import="beans.Item"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>View Bids</title>
    </head>
    <body>
        <img src="Images/AllBids_Logo.gif" width="295" height="42" alt="Logo">
        <form action="Controller" method="POST">
            <table border="1">
                <tbody>
                    <tr>
                        <td>
                            <select name="items">
                                <option value="NULL" selected="true">-- Select An Item To View Bids --</option>
                                <% List<Item> items = (List<Item>) session.getAttribute("items");
                                    for (Item item : items){ %>
                                    <option value=<%= item.getItemId()%> > <%= item.getItemName()%></option>
                                <% } //end for %>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                    </tr>
                    <tr>
                        <td>
                            <input type="submit" value="Display Bids"/>
                        </td>
                    </tr>
                </tbody>
            </table>
            <input type="hidden" name="action" value="viewbids_view"/>
        </form>
    </body>
</html>

And this is how I am now running the servlet code – as you can see, the code I have generates the same content as the original html pages, it’s just accessing the db and displaying the table and messages that I can’t figure out.

if(action.equals("viewbids_view")) {
    HttpSession session = request.getSession();
    session.setAttribute("items", dao.getItems());
    response.sendRedirect("ItemBids.jsp");
}

else if(action.equals("bid_view")) {
    HttpSession session = request.getSession();
    session.setAttribute("items", dao.getItems());
    session.setAttribute("members", dao.getMembers());
    response.sendRedirect("Bids.jsp");
 }

I’m pretty sure this is the problem, but where do I look to resolve the issue?