use a standard servlet - it's just a URL as far as the client is
concerned. Here's an example I found:

 // This method is called by the servlet container to process a GET
request.
    public void doGet(HttpServletRequest req, HttpServletResponse
resp) throws IOException {
        // Get the absolute path of the image
        ServletContext sc = getServletContext();
        String filename = sc.getRealPath("image.gif");

        // Get the MIME type of the image
        String mimeType = sc.getMimeType(filename);
        if (mimeType == null) {
            sc.log("Could not get MIME type of "+filename);
            resp.setStatus
(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            return;
        }

        // Set content type
        resp.setContentType(mimeType);

        // Set content size
        File file = new File(filename);
        resp.setContentLength((int)file.length());

        // Open the file and output streams
        FileInputStream in = new FileInputStream(file);
        OutputStream out = resp.getOutputStream();

        // Copy the contents of the file to the output stream
        byte[] buf = new byte[1024];
        int count = 0;
        while ((count = in.read(buf)) >= 0) {
            out.write(buf, 0, count);
        }
        in.close();
        out.close();
    }


You need to adapt this to:

1) Strip the image name from the HttpRequest URL so you can use it to
build your JDBC query.
2) Check your DB docs to see how to get an InputStream (as opposed a
byte array) out of the ResultSet
3) Then you plug this InputStream into the response OutputStream
instead of the FileInputStream used in the example
4) I'm not sure what the significance of the MimeType bit in the
example is - you might be able to just set this to a constant if it's
needed

The main idea is that you set up streams piping the image bytes
directly from your DB out to the client using a small byte buffer (say
1024 bytes as in example) in the servlet. This avoids creating big byte
[] objects on the web server which hammers memory.

regards
gregor

On Nov 15, 6:52 am, CodeABunch <[EMAIL PROTECTED]> wrote:
> Greetings.
>
> I'm dynamically reading images stored in the DB and I need to render
> them in the screen
>
> The Image Widget reads only static URLs so I need to have the images
> saved in a temp directory (but still accessible from regular URL).
>
> I'm wondering if there is any other "smart" way of doing this. Any
> light out there?
>
> Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to