Hi, I'm trying my first program using servlets and JSP and would appreciate any help or advice about a problem I'm having.

In my servlet I'm connecting to the database and displaying all the records in there. I'm then trying to add data to a JavaBean so that I can click a button and get the attributes from the JavaBean in the JSP. This is the servlet code (just the relevant bits - the query to get data executes fine):

out.println("<form action=\"viewAllViewJSP_kv003302.jsp\" method=\"post\">");
out.print("<table>");
out.print("<tr>");
Vector<customerBean_kv003302> custs = new Vector<customerBean_kv003302>();
            
            while (rs.next())
            {
                out.println("<tr" + (ctr++ % 2 == 0 ? " class=\"shaded\"" : "") + ">");
                out.println("<td>" + rs.getInt(1) + "</td>");
                out.println("<td>" + rs.getString(2) + " " + rs.getString(4) + " " + rs.getString(3) + "</td>");
                out.println("<td>" + rs.getString(5) + ", " + rs.getString(6) + "</td>");
                out.println("<td><input type=\"submit\" name=\"viewDetails\" value=\"View Details\">");
                out.println("</tr>");
                customerBean_kv003302 cust = new customerBean_kv003302();
                cust.setName(rs.getString(3));
                custs.add(cust);
            }
            request.setAttribute("CustomerCollection", custs);
            out.println("</table>");
            out.println("</form");

In my .jsp file, this is the code I was using (I know how to display it I just need help getting the attributes in the first place)

<% java.util.Vector collection =
               (java.util.Vector)request.getAttribute("CustomerCollection");

    if (collection != null)
    {
  // Iterate through data & put it in a table
 // Then display all in HTML
%>
<%
    }
    else
    {
        throw new javax.servlet.jsp.JspException(
                   "Collection View could not be found");
    }
%>

Any help would be greatly appreciated as I am very stuck!

I do not want to be rude, but you better stop there before you get bad habits, like JSP-database connectivity. Start reading Head First - Servlet and JSP

I'm sorry but I tried reading the book and couldn't find anything that would help me with this particular problem. I don't understand exactly what I am doing wrong?

1. Generating website through servlet (code 1)
2. Messing page view (JSP) with unnecessary Java coding (code 2)

I didn't give you link as solution to your problem, but as resource to learn from as you obviously don't know what you doing in your code