Hi

Please help to me

I am not able to display image from Mysql 2005
i written code but the image is not displaying the data is comming to my java but not displaying

(

if(request.getParameter("option").equalsIgnoreCase("FOUR")) // for image & signature
				{
					//qry2="select  PicBuffer from D140101 where CustNo="+cust+" and PicSrNo = (select max(PicSrNo) from D140101 where CustNo="+cust+")";
					System.out.println("prodtCd::"+prodtCd);
					qry2="select  PicBuffer from D140101 where PrdAcctId='"+  prodtCd +"'and LBrCode="+ lbrCode +" and PicSrNo = (select max(PicSrNo) from D140101 where PrdAcctId='"+  prodtCd +"'and LBrCode="+ lbrCode +")";
					
					System.out.println("Photo query="+qry2);
					ResultSet rs2=stmt.executeQuery(qry2);
				
					int test= rs2.getRow();
					if ( test == 0 )
						System.out.println("Photo image not found in the database for prodtCd="+prodtCd);
				
					if(rs2.next()) 
					{
						// image
						byte[] bytearray = new byte[4096]; //4096
						int size=0;
						InputStream sImage;
						
						sImage = rs2.getBinaryStream(1); //GET THE BLOB
						System.out.println("sImage::"+rs2);
						response.reset();
						response.setContentType("image/jpeg");
					
						while((size=sImage.read(bytearray))!= -1 )
						{
							System.out.println("sImage44::");
							request.setAttribute("SIMG",bytearray);
							response.getOutputStream().write(bytearray,0,size);
						}
						response.flushBuffer();
						sImage.close();
						rs2.close();
						conn.close();
						stmt.close();
					}
					else
					{
						System.out.println("Photo image not found in the database for prodtCd="+prodtCd);
						System.out.println("sImage45::");
						request.setAttribute("imgvalue","IMP");
					}
				 } // if  four

)

jsp:

<logic:present name="BRDATA" scope="request">
				<%System.out.println("image2:::"); %>
					<img border="10" align="right"
						src="<%=request.getContextPath()%>/imgs/viewImg?cno=<%=prd %>&sno=1&option=FOUR&prd=<%=prd%>&branchCode=<%=branchCode%>" />				
			</logic:present></td>

please give reply any body

I guess you wrote improper select statement:

Your code

qry2="select  PicBuffer from D140101 where PrdAcctId='"+  prodtCd +"'and LBrCode="+ lbrCode +" and PicSrNo = (select max(PicSrNo) from D140101 where PrdAcctId='"+  prodtCd +"'and LBrCode="+ lbrCode +")";
qry2="select  PicBuffer from D140101 where PrdAcctId='"+  prodtCd +"'  and LBrCode="+ lbrCode +" and PicSrNo = (select max(PicSrNo) from D140101 where PrdAcctId='"+  prodtCd +"'  and LBrCode="+ lbrCode +")";