Your configuration is okay but you have misused the action tag. You
can't embed an inline image within an HTML page.
ie. you've started sending a result, which is from JSP, and then
part-way though you've attempted to output some binary data in the same
output stream.
You do not need special tags. As Gabriel suggested, you simple need an
image tag.
default.jsp:
<p>The image follows</p>
<img src="pgetpicture.action" alt="generated image"/>
That means there's first an HTML stream (from the JSP), then separately
browser opens the image stream from your action.
Hope that makes sense.
Jeromy Evans
Alessio Bandini wrote:
I'm sorry again.
The mailing list manager does not allow attached files.
But the problem is still the same.
I get the image from DB, but I see binary characters and not the image.
Probably I have to use some special tags but I cannot understand what.
Thanks.
Alessio Bandini wrote:
Thanks,
I'm sorry, I intend "mistake", writing the modules, not "error".
The image is stored in an Oracle DB, not in a file system.
I get the BLOB from DB, but when I try to view the image what I see
is in the file attached to this mail.
I see binary characters and not the image.
Thanks.
Gabriel Belingueres wrote:
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]
__________ Informazione NOD32 3375 (20080821) __________
Questo messaggio รจ stato controllato dal Sistema Antivirus NOD32
http://www.nod32.it
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]