| Author |
display image on sturts from data base
|
vikassheel gupta
Ranch Hand
Joined: Aug 02, 2005
Posts: 53
|
|
hi i have a problem reated to image retrieval what i did till now i have a column in data base with blob data type I can easily upload the image with the help of FormFile and BinaryStream but when i try to retrieve that image i face some sort of problem My problem is:-- I got the image in the resultset with the help of connection but its return type is InputStream which doesnt have the write method so that i can not write that image in the jsp page if i didnt use InputStream and i use byte array and then try to print it again it will not print with no error so i cant not understand why this problem occurs thanks alot
|
Warm Regards<br />vikassheelgupta<br />9911005168
|
 |
James Ellis
Ranch Hand
Joined: Oct 14, 2004
Posts: 205
|
|
You're going to have to "write" the image to a file, and include the path to that file from your page. Try writing to a file first, once you get that you'll see that all you need to do then is include the path to this within an image tag. Additionally, you might want to check this forum form more on I/O issues.
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
Another way of approaching this would be to write a servlet or struts action class that does the following: get the OutputStream from the HttpServletResponse object using the getOutputStream() methodread the input stream and write it to the OutputStreamclose the OutputStream and if this is a Struts Action, return a null forwardin your jsp, use src="myAction.do" in your <img> tag In the Struts 1.2.x download, the struts-examples.war file that comes with the download contains an example of how to do this. Look for org.apache.struts.webapp.exercise.ImageAction [ October 19, 2005: Message edited by: Merrill Higginson ]
|
Merrill
Consultant, Sima Solutions
|
 |
 |
|
|
subject: display image on sturts from data base
|
|
|