I don't think it is possible to create an image using base64 encoded data.
Even if it were possible, you don't want to do it for a lot of reasons,
namely
a) RPC uses POST, which is not easily cacheable
b) Its a waste of bandwidh. RPC and base64 both have their overheads
c) You have to deal with the asynchronous nature of RPC
d) Its non-intuitive, and a lot more work

i cannot fetch it directly from the client since this image needs to be
> registered in the session of the GWT-server - image servlet, if i fetch it
> from the client it will be registered in the client session with the image
> servlet.

Could you explain this statement? It looks to me you are confused with the
concept of sessions. Serving images via a servlet is a pretty standard
technique, you need to better explain your problems with that approach.

--Sri


On 18 May 2010 23:57, Professor Vagner <professorvag...@javaneses.com>wrote:

> Try this.
>
>
> import com.google.gwt.user.client.rpc.RemoteService;
> import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
>
> /**
>  * The client side stub for the RPC service.
>  */
> @RemoteServiceRelativePath("greet")
> public interface GreetingService extends RemoteService {
>     String getImage(String name) throws IllegalArgumentException;
> }// end GreetingService
>
>
> ##############################################################################
>
> /**
>  * The async counterpart of <code>GreetingService</code>.
>  */
> public interface GreetingServiceAsync {
>     void getImage(String input, AsyncCallback<String> callback)
>             throws IllegalArgumentException;
> }// end GreetingServiceAsync
>
>
> ##############################################################################
>
> package testes.gwt.server;
>
> import java.io.FileInputStream;
>
> import sun.misc.BASE64Encoder;
> import testes.gwt.client.GreetingService;
>
> import com.google.gwt.user.server.rpc.RemoteServiceServlet;
>
> /**
>  * The server side implementation of the RPC service.
>  */
> public class GreetingServiceImpl extends RemoteServiceServlet implements
>         GreetingService {
>
>     private static final long serialVersionUID = -7242788956943039085L;
>
>     public String getImage(String input) throws IllegalArgumentException {
>
>         try {
>             BASE64Encoder base64Encoder = new BASE64Encoder();
>             FileInputStream fileInputStream = new
> FileInputStream("myImage");
>
>             byte[] buffer = new byte[fileInputStream.available()];
>
>             StringBuilder stringBuilder = new StringBuilder();
>             stringBuilder.append("data:image/png;base64,");
>             fileInputStream.read(buffer);
>             stringBuilder.append(base64Encoder.encode(buffer));
>             return stringBuilder.toString();
>         } catch (Exception e) {
>             e.printStackTrace();
>         }// end catch
>         return null;
>     }// end getImage
> }// end GreetingServiceImpl
>
>
>
> ##############################################################################
>
>
> public void onFailure(Throwable caught) {}
>
> public void onSuccess(String result) {
>     if (!img.isVisible())
>            img.setVisible(true);
>     img.getElement().setPropertyObject("src", result);
>  } // end onSuccess
>
>
> --
> Professor Vagner
>
> O PLANETA É O MEU PAÍS, E A CIÊNCIA É A MINHA RELIGIÃO ! INDO AO INFINITO E
> ALÉM... !!!!!!
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to google-web-tool...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com>
> .
> 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 google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to