Image reload

117 views
Skip to first unread message

D L H

unread,
Jul 30, 2008, 4:15:56 PM7/30/08
to Google Web Toolkit
I have an image that is updated dynamically with a servlet. i tried
using a setUrl to reload the image after the servlet finished
rendering it, but it seems to be pulling the image from the cache.

i checked the directory that the generated image is written to and saw
that the image was being updated correctly by the servlet. so i just
need some way of reloading the image on the client side bypassing the
cache.

-DLH

rudolf michael

unread,
Jul 30, 2008, 4:26:38 PM7/30/08
to Google-We...@googlegroups.com
hello,
you need to reset the image size. i had this problem once and i used to send the new width and height in the servlet response every time i re-size the image.

regards,
ruds

D L H

unread,
Jul 30, 2008, 4:49:31 PM7/30/08
to Google Web Toolkit
hmm i'm not getting that to work. not in the hosted mode browser
anyway. could you give me a slighly more detailed idea of how you got
it to work?

thanks

On Jul 30, 4:26 pm, "rudolf michael" <roud...@gmail.com> wrote:
> hello,
> you need to reset the image size. i had this problem once and i used to send
> the new width and height in the servlet response every time i re-size the
> image.
>
> regards,
> ruds
>

rudolf michael

unread,
Jul 30, 2008, 5:28:28 PM7/30/08
to Google-We...@googlegroups.com
the servlet response is a text/plain, so i just appended to the response the width and height with some special characters to seperate them.
for example my servlet response is images/resized.jpg@width@height and on the client side, i am parsing the string to an array to get the values so i can set them.

D L H

unread,
Jul 31, 2008, 8:40:36 AM7/31/08
to Google Web Toolkit
hmm still not getting it to work. the size is updating just fine, but
the image is not.

this is my onSuccess method in my callback. renderedText is my Image
widget.

public void onSuccess(String result) {
String[] parsedString = result.split("&");
String urlString = parsedString[0];
String widthString = parsedString[1];
String heightString = parsedString[2];
renderedText.setUrl(urlString);
renderedText.setSize(widthString+"px", heightString+"px");
}

On Jul 30, 5:28 pm, "rudolf michael" <roud...@gmail.com> wrote:
> the servlet response is a text/plain, so i just appended to the response the
> width and height with some special characters to seperate them.
> for example my servlet response is images/resized.jpg@width@height and on
> the client side, i am parsing the string to an array to get the values so i
> can set them.
>

rudolf michael

unread,
Jul 31, 2008, 8:46:07 AM7/31/08
to Google-We...@googlegroups.com
did you tried to print out or alert your servlet response to check if this parsing is correct?
try to use something other then &, this might be a special character for regex.

D L H

unread,
Jul 31, 2008, 8:58:59 AM7/31/08
to Google Web Toolkit
i displayed the strings with labels and they seemed to be just fine.

On Jul 31, 8:46 am, "rudolf michael" <roud...@gmail.com> wrote:
> did you tried to print out or alert your servlet response to check if this
> parsing is correct?
> try to use something other then &, this might be a special character for
> regex.
>

jhulford

unread,
Jul 31, 2008, 10:24:21 AM7/31/08
to Google Web Toolkit
Try appending a timestamp as a query parameter to the image's URL.
That'll fool the browser into thinking the image is new each time and
won't grab it from the cache. Or you can add nocache directives to
your server to tell the browser not to cache that image (or others
like it).

D L H

unread,
Jul 31, 2008, 10:26:51 AM7/31/08
to Google Web Toolkit
i thought about doing something like that, but i decided that it would
be too hard to keep track of all those images and delete them when
they're no longer useful.

this nocache idea sounds intriguing. can you explain it?

MN

unread,
Jul 31, 2008, 10:48:43 AM7/31/08
to Google Web Toolkit
url = "myimagepath/myimage.jpg?" + [...youtimestampgenerator..]

for example:

url = "myimagepath/myimage.jpg?" + new Date().getTime()
you get a "myimagepath/myimage.jpg?122342343" link

D L H

unread,
Jul 31, 2008, 10:54:20 AM7/31/08
to Google Web Toolkit
it works!! thanks a lot!! :)
Reply all
Reply to author
Forward
0 new messages