Please post the error (stack trace?). I suppose that if you want to "show" the image, you need some <img> tag in your html page result. <s:action> tag doesn't generate <img> tags for you AFAIK.
2008/8/21, Alessio Bandini <[EMAIL PROTECTED]>: > > Hello, > > I have a web application that must get image from blob field stored in an > Oracle DB, but I cannot find "how to" examples. > > Here is my sources. Where is the error? > > default.jsp > ----------- > <s:action name="pgetpicture" executeResult="true" > > <s:param name="id" value="2950" /> > </s:action> > > struts.xml > ---------- > <package name="pgetpicture" extends="struts-default"> > <action name="pgetpicture" > class="pgetpicture.PGetPictureAction"> > <result name="success" type="stream"> > <param name="contentType">image/jpeg</param> > <param name="inputName">img</param> > <param name="bufferSize">1024</param> > <param name="contentDisposition">inline</param> > </result> > </action> > </package> > > > > PGetPictureAction.java > ---------------------- > package pgetpicture; > > import com.opensymphony.xwork2.ActionSupport; > import maps.SqlMapConfig; > import java.io.*; > > @SuppressWarnings("serial") > > public class PGetPictureAction extends ActionSupport { > > private Integer id; > private PGetPicture imgobj; > > public String execute() throws Exception { > imgobj = > (PGetPicture)SqlMapConfig.getSqlMapIstance().queryForObject > ("getpromopicture", getId()); > return SUCCESS; > } > > public Integer getId() { > return id; > } > > public void setId(Integer id) { > this.id = id; > } > > public InputStream getImg() { > return imgobj.getImg(); > } > > } > > > PGetPicture.java > ---------------- > package pgetpicture; > > import java.sql.SQLException; > import com.ibatis.sqlmap.client.SqlMapClient; > import java.util.*; > import java.io.*; > > public class PGetPicture { > > private byte[] img; > > > public void PGetPicture(){ > //super(): > } > > public InputStream getImg() { > InputStream is = new ByteArrayInputStream(img); > return is; > } > > public void setImg(byte[] img) { > this.img = img; > } > > } > > > PGetPicture.xml > --------------- > <?xml version="1.0" encoding="UTF-8"?> > > <!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" > "http://www.ibatis.com/dtd/sql-map-2.dtd"> > > <sqlMap namespace="pgetpicture"> > > <typeAlias alias="picture" > type="pgetpicture.PGetPicture"/> > > <resultMap id="picture-map" class="picture"> > <result property="img" column="img" jdbcType="BLOB" /> > </resultMap> > > <select id="getpromopicture" resultMap="picture-map"> > SELECT b_imgbkg as img > FROM <table_name> > WHERE i_id = #id# > </select> > > </sqlMap> > > Please, help me. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]