He doesn't care about overhead, Frank.  He just wants to do it.  If it
is slow, ugly, etc. that does not matter to him.

On 9/27/05, Frank W. Zammetti <[EMAIL PROTECTED]> wrote:
> The Wiki is your friend:
>
> http://wiki.apache.org/struts/StrutsFileDownload
>
> Specifically, you will be interested in the downloadapp.zip sample I
> posted there... it has an example of serving a BLOB from a database.  All
> you need to do is have a mapping to this Action, and use it as the src
> attribute of an <img> tag.
>
> As another poster said though, there is definitely a fair amount of
> overhead to doing this.  That being said, I've done it to good effect on
> at least two occassions.  But, you do have to think about whether it is
> appropriate... in my case, it was a client's logo in a frame that only
> changed when the user changed clients, very infrequent.  I can't imagine
> I'd serve images from a database if it was going to be needed a lot... I'd
> have to have an exceptionally good reason for doing it.  Maybe you do :)
> In any case, that sample app should show you how.
>
> Note too that even if you aren't using a version of Struts with the
> DownloadAction, what's there is still somewhat applicable, and there's
> nothing to stop you from bringing DownloadAction over to your app anyway
> AFAIK.
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
>
> On Tue, September 27, 2005 12:23 pm, Braun, James F said:
> > Goal: Read a blob image from an Oracle database and render it on an html
> > page using the struts framework.
> >
> > I've never found a good way to do this and I was hoping someone had a
> > "best practice" suggestion.
> >
> > I have no trouble getting the image from the database. However, I wonder
> > if there isn't a better way to display it rather than writing it to a
> > physical file and then rendering it. I'm using the <html:img tag to
> > display the image now.
> >
> > All help appreciated.
> >
> > J.
> >
> > ImputStream pictureStream;
> > ResultSet rs;
> >
> > // create the query and execute it ...
> >
> > // get the result
> > pictureStream = rs.getBinaryStream("picture");
> >
> > // I can write it to a physical file
> > File pictureFile = new File("/temp/picture.jpg");
> >
> >         try
> >         {
> >           FileOutputStream out = new FileOutputStream(pictureFile);
> >           int chunk = 0;
> >           while( (chunk = pictureStream.read()) != -1)
> >           {
> >             out.write(chunk);
> >           }
> >           out.close();
> >           out.flush();
> >         }
> >         catch(FileNotFoundException ex)
> >         {
> >           System.err.println("selectionForm.populate.picturefile: " +
> > ex.getMessage());
> >           logger.error("selectionForm.populate.picturefile: " +
> > ex.getMessage());
> >         }
> >         catch(IOException ex)
> >         {
> >           System.err.println("selectionForm.populate.picturefile: " +
> > ex.getMessage());
> >           logger.error("selectionForm.populate.picturefile: " +
> > ex.getMessage());
> >         }
> >
> > --
> > This transmission is intended only for use by the addressee(s) named
> > herein and may contain information that is proprietary, confidential
> > and/or legally privileged. If you are not the intended recipient, you are
> > hereby notified that any disclosure, copying, distribution, or use of the
> > information contained herein (including any reliance thereon) is STRICTLY
> > PROHIBITED. If you received this transmission in error, please immediately
> > contact the sender and destroy the material in its entirety, whether in
> > electronic or hard copy format. Thank you.
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


--
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to