File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes streaming images from custom tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "streaming images from custom tags" Watch "streaming images from custom tags" New topic
Author

streaming images from custom tags

John Eric Hamacher
Ranch Hand

Joined: Apr 25, 2007
Posts: 230
Hello:

Is it possible to stream an image from a custom tag to the browser? If so, how is this done?

Thanks
eric
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If it's possible, it probably wouldn't make much sense to do so.

Tags are meant to be embedded into HTML.
If your response is returning text (HTML) then you can't also mix binary data (images) with it.

Maybe if you explain what you're trying to accomplish, someone can offer a better alternative.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
John Eric Hamacher
Ranch Hand

Joined: Apr 25, 2007
Posts: 230
I currently have a custom tag which writes an img tag to the browser, The img tag calls a servlet and passes a very long parameter, more than the 2000 or so characters allowed by IE. So to avoid the long parameter (which describes chart data) I want the tag itself to produce the image and stream it.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12809
    
    5
The img tag calls a servlet and passes a very long parameter, more than the 2000 or so characters allowed by IE. So to avoid the long parameter (which describes chart data) I want the tag itself to produce the image and stream it.


1. img tags can only address a resource with a URL, browsers make a separate request based on this URL so there is no way the tag can produce anything.
2. why dont you make use of automatic session mechanism and put the 2000 or so characters into the user session, then have the image creating servlet access the session?
[ May 21, 2008: Message edited by: William Brogden ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: streaming images from custom tags