Hello everyone, I am having trouble in displaying the multiple images on jsp. I am using servlet to pull the image from the database. Following code, will always display single image multiple times on my jsp page. Can anyone please help me in rectifying the error in the code. I am new to jsp and servlet programming! Thanks for your anticipation. Fyi,
Inline Code Example Here

Table A:
    fieldname: personid(datatype: int, primary key)
    fieldname: person_name(datatype: varchar(20)
    Table B:
    fieldname: person_pic(datatype: BLOB)
    fieldname: personid(foreign key references Table A(id))
    fieldname: picid(datatype: int, primary key)
    Below is the jsp code:

     <%
        //uid will have the session value
        rs = st.executeQuery("select picid from Table B where personid = '" + uid + "' ");   
        int pid = 0;
        while(rs.next())
        {
        // Fetching person id from Table B a
        pid = rs.getInt(picid);
        %> <tr> <td><%= rs.getInt(picid);</td> <td><img src="http://localhost:8080/Displayimg?id=pid " height="" width="" /></td> </tr> <% 
        }
        %>
        Servlet code:
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        {
        int p_id= request.getParameter("pid");
         PreparedStatement ps = con.prepareStatement("Select Pro_pic from Table B where  picid =  '" + p_id + "' ");            
         ResultSet rs = ps.executeQuery();
         if(rs.next)
        {
                Blob  b = rs.getBlob("Pro_pic");            
                response.setContentType("image/jpg");
                response.setContentLength( (int) b.length());       
                InputStream is = b.getBinaryStream();
                OutputStream os = response.getOutputStream();
                byte buf[] = new byte[(int) b.length()];
                is.read(buf);
                os.write(buf);
                os.close();        
                }     
                }