As was said before, if your images are small (or you don't care about IE) you can return the image as a data URI (google is your friend here) and when you get the response simply do: new Image(myImageDataURI);
Another option would be to save your image (either to the filesystem, or datastore) using some sort of identifier (hash maybe)
Then use a separate HTTPServlet to return this image something like: /GetImage?ID=someid
But your original idea should have worked as well ... GWT.getModuleBaseURL()+imageName
module base url is the location of the Module.js file used in the host page.
There is also GWT.getHostPageBaseURL() which is the location of the Host HTML page (which may be different than the module's location)
-jason
On Oct 26, 2010, at 3:18 PM, Greg Dougherty wrote:
Thank you Thomas.
Given what I'm trying to do, I need to have the Image created via a
GWT RPC call. However, nothing keeps me from implementing doGet ()
within my servlet, so I did that, and now I can serve up the images
cleanly, and I can even cache them! :-)
Greg
On Oct 26, 11:26 am, Thomas Broyer <t.bro...@gmail.com> wrote:On 26 oct, 16:18, Greg Dougherty <dougherty.greg...@mayo.edu> wrote:- Generate the image with a servlet on the fly (return the appropriate mimetype and the image) or (if the images are small)Great idea. HOW DO I DO THAT?Sorry for the shouting, but I'm already generating the things on thefly. If I knew how to return them other than as a file, I'd alreadybe doing that.I've got a GWT client and a GWT Servlet. The GWT Servlet has an imagesitting in its memory. I want to get that image to the client. Ifyou can give me sample code, point me to sample code, or point me to awell documented Java function, that would be great, and you would havemy full appreciation.Telling me to "do X' is pointless, if you don't give me some way offiguring out how to DO that X. Because if I knew how to do it, Iwould have already done it, and not wasted everyone's time with thesequestions.The thing is: instead of calling your servlet through GWT-RPC orwhatever (anything implemented above XMLHttpRequest) to generate theimage; "generate" the call through a new Image(), passing the"arguments" in the URL.Your servlet will then be a bare HttpServlet (no GWT involved, justimplement de doGet method) and you'd send the image back using theHttpServletResponse's OutputStream (after setting theHttpServletResponse's content-type to the appropriate value, forinstance "image/png").To get the arguments on the server-side, if you passed them in thequery string, then HttpServletRequest#getParameter will workseamlessly.
--
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-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment