• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Struts2 Image Display Replaces Response

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was able to display an image feed from a byte stream in my JSP using these instructions: Struts FAQ Dynamic Image Example.

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?

Wildman
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Dave Whaley
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

[Ankit: disabled HTML in the message]
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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".

If interested will give more details of the code.

Thanks,
Aruna
 
I'm thinking about a new battle cry. Maybe "Not in the face! Not in the face!" Any thoughts tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic