Yes, that is exactly what I did and it works now, thank you.

On Sun, Apr 18, 2010 at 10:51 PM, Trevis <[email protected]> wrote:

> Is your goal to show the image in an img tag in the web browser?  I
> have user uploadable images on my gwt website and to present the
> images to users i use an http servlet.  I have an img tag rendered in
> the client that references the image from the servlet.  Since my
> images are saved in the DB, the image servlet processes the users
> request, finds the image that they are requesting and renders the file
> to the output stream.  Pretty much all you need to do is configure the
> content type on the response.
>
>
> On Apr 15, 9:48 am, Ahmet <[email protected]> wrote:
> > Hi everyone,
> >
> > My application has an upload file feature and allow users to upload
> > image files to the server using an httpServlet. That part works fine,
> > the file gets uploaded and placed in the WEB-INF folder (I don't want
> > public access), required url and other info is filled into the
> > database using Hibernate.
> >
> > The problem is when I want to retrieve the image on the client side.
> > My user pojo knows the url of its image, but I can't instantiate an
> > Image object and send it over an RPC call since it is not
> > serializable. I decided to transform the image file, a jpg, into a
> > byte[] on the server side and then transfer the byte[] over the RPC
> > call, however, I it doesn't work.
> >
> > I get no errors on the server side, the RPC call returns, but my
> > client reports a failure:
> >
> > SEVERE: Exception while dispatching incoming RPC call
> > java.lang.RuntimeException: java.lang.ClassCastException: [B cannot be
> > cast to [Ljava.lang.Object;
> >
> > My service code:
> > public byte[] getImageByUrl(String url) {
> >
> >                 ByteArrayOutputStream baos = new ByteArrayOutputStream();
> >                 try{
> >                         File file = new File(url);
> >                         ObjectOutputStream oos = new
> ObjectOutputStream(baos);
> >                         oos.writeObject(file);
> >                 }catch(Exception ioe){
> >                         ioe.getMessage();
> >                 }
> >                 return baos.toByteArray();
> >
> > }
> >
> > My client code:
> > service.getImageByUrl(url, new AsyncCallback<byte[]>() {
> >                                         @Override
> >                                         public void onFailure(Throwable
> arg0) {
> >                                                 log("getImageByUrl
> failed");
> >                                                 log(arg0.getMessage());
> >                                         }
> >                                         @Override
> >                                         public void onSuccess(byte[]
> arg0) {
> >                                                 //reconstruct file
> >                                         }
> >
> > }
> >
> > I send a byte[] and recieve a byte[], I checked the contents of the
> > array from the server side, it is not null and gets returned, however
> > the client side can not accept it... Why can this be ?
> >
> > I have done some research and it seems like using an httpServlet is
> > better than using an RPC call when making a binary data transfer,
> > therefore I am inclined to using the httpServlet for downloading the
> > image, however what I ultimately achive is not having to save the file
> > on my client side to access its content. Is it possible to transfer
> > the Image object over the httpServlet to dynamically use it as it is
> > recieved on the client side ?
> >
> > I am not sure about using data://url s as they are not supported by
> > all browsers, but seems as the simplest solution.
> >
> > Thank you for your opinions..
> >
> > Regards,
> > Ahmet
> >
> > --
> > 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]<google-web-toolkit%[email protected]>
> .
> > For more options, visit this group athttp://
> groups.google.com/group/google-web-toolkit?hl=en.
>
> --
> 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]<google-web-toolkit%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

-- 
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