i am trying to display table data from database to jsp page, all data are fetched but image is not loaded into image tab. i have store image as a BLOB in table.
my jsp page is follow :
<body>
    <table border="1">  
    <%@ page import="com.*;"%>
    <%
        MySql myobj = new MySql();
        myobj.connect();
        String query="select contact_id,first_name,last_name,photo from contacts";
        ResultSet rs = myobj.getdata(query);
        while(rs.next())
        {               
        %>
            <tr>
                <td>
                    <%= rs.getInt(1) %>             
                </td>
                <td>
                    <%= rs.getString(2).toString() %>
                </td>
                <td>
                    <%= rs.getString(3).toString() %>
                </td>
                <td>
                    <img src="<%= rs.getString(4) %>"  width="500" height="300" alt="data"></img>                   
                </td>
            </tr>
        <% 
        }
    %>
    </table>
</body>
i have to also implement download when item name or data of second div is clicked then that related data should be downloaded.
can anyone solve my this problem soon ?
how to implement download in servlets as back end ?
i have write this code for imageservlet :
protected void doGet( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
    {   
        String id = request.getParameter("contact_id");     
        MySql myobj = new MySql();
        myobj.connect();
        PrintWriter out=response.getWriter();       
        try
        {
            String query="select photo from contacts where contact_id='"+id+"'";
            ResultSet rs = myobj.getdata(query);
            out.println(id);
            Blob image=null;
            byte[] imgData = null;
            image= rs.getBlob(1);
            imgData = image.getBytes(1, (int) image.length());
            response.setContentType("image/gif");
            OutputStream o = response.getOutputStream();
            o.write(imgData);
            o.flush();
            o.close(); 
            response.sendRedirect("Message.jsp");
        }
        catch (Exception e)
        {
            e.getMessage();
        }       
    }
