Passing an arraylist of object from servlet to jsp failed : <p>this things is giving me headache for the past 3 days already. I tried to store the resultset that i get from the database and store inside an arraylist of object then pass it to the jsp for display, but after running the program, it gave me this error:
<a href="http://i.stack.imgur.com/c2hI6.png" rel="nofollow">enter image description here</a></p>

<p>anyone have any idea how to solve this problem? Thanks in advance!
below is my code:
menu.java</p>

<pre><code>@Override
protected void doGet(HttpServletRequest request, HttpServletResponse     response)
        throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    try {
        Class.forName("com.mysql.jdbc.Driver");

        //Create connection object
        conn = DriverManager.getConnection(request.getServletContext().getInitParameter("url"), request.getServletContext().getInitParameter("username"), request.getServletContext().getInitParameter("password"));
        String sql = "select name,price,imageurl from food";
        stmt = conn.createStatement();
        rs = stmt.executeQuery(sql);
        class food {

            String name;
            double price;
            String imageurl;

        }
        ArrayList&lt;food&gt; foodDetail = new ArrayList&lt;food&gt;();

        while (rs.next()) {
            food temp = new food();

            temp.name = rs.getString("name");
            temp.price = rs.getDouble("price");
            temp.imageurl = rs.getString("imageurl");

            foodDetail.add(temp);

        }
        request.setAttribute("menu", foodDetail);
        RequestDispatcher req = request.getRequestDispatcher("menu.jsp");
        req.forward(request, response);

    } catch (ClassNotFoundException ex) {
        Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SQLException ex) {
        Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
    } finally {

        try {
            rs.close();
            stmt.close();
            conn.close();
        } catch (SQLException ex) {
        }

    }
</code></pre>

<p>menu.jsp</p>

<pre><code>&lt;%
        class food {

            String name;
            double price;
            String imageurl;
        }


        ArrayList&lt;food&gt; foodDetail = (ArrayList&lt;food&gt;) request.getAttribute("menu");
        food temp = new food();
java.util.Iterator it = foodDetail.iterator();
        while (it.hasNext()) {

            food z = (food) it.next();

            out.println(z.getName());


        }


    %&gt;
</code></pre>
