Rendering images from a database?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Rendering images from a database?

Geoff Hopson
Some quick help required...

I know I can get an image from a database and render it to a web page
using a separate servlet. I don't particularly want to do this. I was
thinking that it might be possible to write a Click control to stuff
the byte[] into an Image and set the response content type to
"image/gif" or whatever in the toString() method.

Would this work?

Regards,
Geoff




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Click-development mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/click-development
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rendering images from a database?

pbarnes
Hi Geoff,

I'm not sure this would work, as the response stream would likely already be set by whatever Page is being rendered.

Likely what one would have to do is subclass ClickServlet and override handleRequest (or processPage()) and interrogate the URL to determine whether the request was for an actual page or an image, then delegate rendering of the response for images to the Control, while skipping "normal" Page processing -- all in all a pretty messy solution.

I don't want to unnecessarily belabor this point, but is this in an effort to potentially migrate a legacy application?  The reason I ask is, in general, unless it's a low volume site, serving images up dynamically from the database isn't really a good thing -- having large byte arrays floating around in memory can increase consumption, and dynamic images reduce the opportunity for server and browser caching.  There are probably other approaches that could also be researched, however (temporary directories to write out images statically, then serve them up normally for instance).

Phil..

On 9/5/05, Geoff Hopson <[hidden email]> wrote:
Some quick help required...

I know I can get an image from a database and render it to a web page
using a separate servlet. I don't particularly want to do this. I was
thinking that it might be possible to write a Click control to stuff
the byte[] into an Image and set the response content type to
"image/gif" or whatever in the toString() method.

Would this work?

Regards,
Geoff




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Click-development mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/click-development

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rendering images from a database?

Geoff Hopson
Hi Phil,

The application has billions of small images in a database - each image if
little more than 2k in size. It is impractical to have all these images on the
file system. There are a lot of them. Billions. Although the user is only
looking at one at a time...

Anyway, I have found a solution, albeit a bit clunky for now, so it needs
tidying up. The solution entailed creating a ImageView.htm and associated
ImageView.java, subclassed off Page. I override getContentType, and in onGet I
stream the byte[] from the database into the response ServletOutputStream.
Standard stuff. Then, in my ImageView.htm, I have <img src='ImageView.htm'>, and
in the component that wants to display the image, I #parse('ImageView.htm').

Very clunky for now, and there is some domain-specific code in there and I am
passing stuff around in the session. I want to tidy this up and make it a bit
more resusable/parameter driven, at which point it's coming your way :-)

Geoff





-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Click-development mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/click-development
Loading...