However, the rest of my JSP output does not show. In other words, the HTML my browser displays is replaced by only an image. I would like to know a) how to fix it, and b) what is going on in general. Is it that the MyBytesResult class causes some sort of redirect when it does "response.getOutputStream().write(action.getImageInBytes());" ? Why is not the image inserted into my rendered page instead of replacing it? Any ideas?
Consider how an HTML page normally displays an image: the image data isn't embedded in the HTML.
Instead, an HTML image tag is used to request the image from the server--that's how your JSP page should work as well. Don't combine the two.
Joined: Aug 07, 2003
David Newton wrote:Consider how an HTML page normally displays an image: the image data isn't embedded in the HTML.Instead, an HTML image tag is used to request the image from the server--that's how your JSP page should work as well. Don't combine the two.
That helped. I am a little too tired to figure out how to explain what I was doing wrong, but basically the example shown is correct. I was thinking that the <img src> tag would do its call after the JSP was displayed. Instead, I changed the mapping to directly invoke the result-type mechanism.
am building an application using struts 2 and tiles. The image rendering example is not working for me. The application is not throwing an error but not displaying the image. Instead of <img src="/myWebAppContext/myAction.do" /> if I use <img src="<s:url action="myAction"/>" />, it throws an error saying
No result defined for action com.action.MyAction and result success.
Did you write any myImageResult.jsp. My result must go to books.jsp but it is tiles page, if I change <result name="myImageResult" type="myBytesResult" /> to
<result type="myBytesResult" > books </result>, it does not work as my books page is defined in type="tiles".