How to display a jpeg msql Blob field

Bob Prah <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <[email protected]>
Hi to All,

I am having difficulties trying to display a jpeg Blob field from a mysql
table in a servlet. All other fields from this table render their text fields
apart from this particular jpeg Blob field - it'll simply not display
anything at all.

Has anyone dealt with with a similar situation using mysql and how?

Will be appreciate any help.


Thank you,

Bob.

Here is snippet from my code:
<<<<
.....

Connection con;
ResultSet res=null;

 public void service(ServletRequest request, ServletResponse response)
    throws ServletException, java.io.IOException {

      response.setContentType("image/jpeg");
      PrintWriter out = response.getWriter();

try {

            stmt = con.createStatement();
            res=stmt .executeQuery(
            "SELECT textField1,textField2,imageField1 FROM tech_bks ORDER BY
id ;");
            out.println("<table border=0 cellpadding=5 cellspacing=2
align=center width=970>");
            InputStream ipsrt =null;
            while (res.next()){
                blob = res.getBlob("imageField1");
                out.println("<tr><td width=40% >" +
res.getString("textField1"));

                out.print("</td><td width=20% align=left>" +
res.getString("textField2")+ "</td><td width=40% align=left>");


                 ipsrt =  blob.getBinaryStream();
                 try{
                    while(IsIpsrt(ipsrt)){
                        out.print(ipsrt.read());
                    }
                    out.print("</td></tr>"  );
                }

                 catch (IOException et){}
            }
            out.println("</table>");
            con.close();
            out.close();
        }
        catch (SQLException e4) {}
}
 private boolean IsIpsrt(InputStream input){
        String dist="";
        dist = input.toString();
        if( dist.equalsIgnoreCase(""))
            return true ;
        else return false;
    }
......

<<<<
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.