Because you need to use GWT.getHostPageBaseURL() not
GWT.getModuleBaseURL() (or use modulebase, but prepend "../" to your
filename). I assume the actual url to get the image is
http://127.0.0.1:8888/card_designer/exampleImage.jpg . That should get
the image.
BUT, going back to the "working directory" thing, it IS problematic to
write files there. At least, it is if you expect those files to be
there long term. Every time you redeploy a war in production, your app
server (tomcat, glassfish, whatever) will overwrite everything in the
directory which will erase working directories like card_designer. If
you just need some temporary space to store an image while the user
does things like cropping the image and then they download the
finished product, then that might be fine. But if they expect that url
to work long term, I wouldn't use that space.
(Also, don't know if you've considered the problem of lots of people
uploading images named the same thing or not.)
I recently had to do something similar to what you did. We have a
directory mounted on our production servers that holds uploaded images
(and isn't accessible via the web). When someone uploads a file, I
check the MD5 hash of the file to see if it's a match of another image
(in my use case, it's very probable that a user will upload the same
image or images every time they use the app). If it's not, then I
write the file to the shared directory in the MD5hash.ext format.
Either way, I then return the calculated filename to the GWT code.
The GWT code then immediately executes a request to a servlet hosted
at "/mymodule/images/*" and uses the path info to get the filename and
goes to look it up in the shared directory and relays the data through
the servlet.
Hope that's all clear enough.
Derek