This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes preparing a jsp that has both image and text Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "preparing a jsp that has both image and text" Watch "preparing a jsp that has both image and text" New topic
Author

preparing a jsp that has both image and text

jonathan Greens
Ranch Hand

Joined: Apr 07, 2004
Posts: 139
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

Joined: Dec 11, 2004
Posts: 13410

Why not just write image tags to the page and let the browser make separate requests for the images?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
jonathan Greens
Ranch Hand

Joined: Apr 07, 2004
Posts: 139
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

Joined: Dec 11, 2004
Posts: 13410

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

Joined: Apr 07, 2004
Posts: 139
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

Joined: Oct 12, 2000
Posts: 5093
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.


42
Pavel Cherkashin
Ranch Hand

Joined: Mar 04, 2005
Posts: 47
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.


Pavel Cherkashin - <br />SCJP, SCWCD, SCDJWS, SCBCD, SCEA, ...<br />www.linkedin.com/in/pcherkas
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: preparing a jsp that has both image and text