protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
String keyString = request.getParameter("key");
PersistenceManager pm = PMF.get().getPersistenceManager();
Image image = (Image) pm.getObjectById(Image.class, keyString);
Blob imageData = image.getData();
pm.close();
response.setContentType(image.getContentType());
response.getOutputStream().write(imageData.getBytes());
response.getOutputStream().flush();
}
On Mon, Nov 23, 2009 at 2:45 PM, mably <[email protected]> wrote:
> Found this doc on Google, it might help you :
>
>
> http://balusc.blogspot.com/2007/04/imageservlet.html#ImageServletServingFromDatabase
>
> On 20 nov, 05:09, java-dev <[email protected]> wrote:
> > hi all,
> >
> > I need some help with images in appengine using java. Now I have
> > sucessfully uploaded an image file and stored it to the datastore. I
> > am also able to read back the stored image (as a byte[] array). Now
> > the issue is, how do I display this image in my jsp page?
> >
> > ***************************************************************
> >
> > //gets the image file Object from the read data d
> > ImageFile f = d.getImg();
> >
> > //gets the byte array of this image
> > byte[] imb = f.getImg();
> >
> > //futile attempt to display this image
> > for(int i=0; i<imb.length; i++)
> > out.println(imb[i]);
> >
> > ***************************************************************
> > The above code displays the raw bytes on the jsp page....How can I get
> > this to display the image itself?
> >
> > Any help would be greatly appreciated..
> >
> > Thanks.
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine-java%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=.
>
>
>
--
Ikai Lan
Developer Programs Engineer, Google App Engine
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" 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-appengine-java?hl=.