• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

preparing a jsp that has both image and text

 
jonathan Greens
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi folks,
i am using the typical command-view model for developing my web application. So before I forward the view to the jsp, the command would prepare the view. If the jsp contains text and images, how would I prepare for it in my command. I know how to stream image, but if I just set the responeHeader to image, the resulting jsp would just display the image and no text is allowed. How can this be done?
thanks!
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not just write image tags to the page and let the browser make separate requests for the images?
 
jonathan Greens
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using img tags in jsp to show the image, but on the server side I still need to stream the images to the browser. These images are not accessible by the browser without a streaming servlet. So I am not sure how to do this on the server side.
thanks!
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You realize that the HTML and each image involves a separate request, right?
I might not be sure what you're asking.
I have a small example app that streams images to a webpage.
http://simple.souther.us
Download and run SimpleStream.
It might answer your question.
 
jonathan Greens
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks I understand now, my confusion was related to the image tag, the image tag's can point to a streaming servlet, right? I thought the image tag can only points to static files
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
image tags can point to anything. As long as the browser can display what is returned by the URI they point to as an image things will work out.

The browser doesn't know whether the image is static or not, it gets a stream of data in either case.
 
Pavel Cherkashin
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will be better to add something:
if you point the img tag to dynamic resource you
should take into account browser caching.
It is sometimes bad when browser each time requests
the very same stream of bytes

Another bug can be on the contrary: the browser caches
the dynamic response and dysplayed info is not always up to date.

To avoid it you can use setting response headers
and returning appropriated response status codes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic