Meaningless Drivel is fun!*
The moose likes JSP and the fly likes refreshing the BLOB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "refreshing the BLOB" Watch "refreshing the BLOB" New topic
Author

refreshing the BLOB

Gert Cuppens
Ranch Hand

Joined: Jul 13, 2003
Posts: 87
I've made a small web application about movies. For those interested
to see it work : go to http://www.gertcuppens.org/servlet/cluif.
The web app works with servlets and JSP's.

Now the problem is this : in the local version, I can select on the first
page the letter "B" to get all movies starting with a B. When I select
, say, "Bad Santa" in thsi list, I can see the detail screen containing
the poster of the movie (a BLOB).
If I go back to the list and select "the Blob" from 1958, I see the poster
with the photo of Steve Mc QUeen. If I go back to the list once more,
I can select "the Blob" from 1988, and I see the poster from this movie.

So locally, everything is OK. Then I published the web application on my
web site, and this still keeps on working.
But when I go to the office, and try to go to my web application at work,
whichever poster I see first, this is the poster that will be shown on all
the other detail screens.
So, for instance, with the above scenarion, I see the data from "bad santa"
and its poster. If I go to the blob, I see the data of the blob (title, year)
but still the poster of "bad santa".

So, at work, I can only view the first poster, even though I select other
movies. Can anyone tell me where the error is ?
Kristian Breifossmo
Greenhorn

Joined: Mar 01, 2005
Posts: 9
I might be trying to shoot in the dark here, but anyway...


Have you checked it's not a caching issue? Try turning caching off and on
on the browser, restarting the browser each time and maybe emptying the
cache. I don't know much about your system so I can't make any better guess right now.

It could also be a session issue (shoot me if I'm wrong anyone), do you have cookies enabled at work/home?
[ March 12, 2005: Message edited by: Kristian Breifossmo ]

<ul type="square"><br /><li><a href="http://kb.zapto.org/Kristian/sd_index.jsp" target="_blank" rel="nofollow">Kristian Breifossmos hjemmeside</a><br /> <br /><li><a href="http://kb.zapto.org/Marthe/sd_index.jsp" target="_blank" rel="nofollow">Marthe Buseths hjemmeside</a><br /></ul>
Gert Cuppens
Ranch Hand

Joined: Jul 13, 2003
Posts: 87
Frankly, after reading your answer, I think it must be a cache problem. I already had this before at work with another web application. Then, the JSP's never changed. To solve this, I had to add the following lines to each JSP :

<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Expires", "0");
response.setHeader("Pragma", "No-cache");
response.addHeader("Cache-control", "no-store"); // tell proxy not to cache
response.addHeader("Cache-control", "max-age=0"); // stale right away
%>

But now it's different. The JSP's are all right, but the image shown is made by a servlet which is called inside a JSP with the following code

<td width="200" rowspan="6"><div align="center"><img src="/gco/cluifimg" width="150" height="200"></div></td>


the /gco/cluifimg is referred to a servlet which takes care of the translation from the blob into an array of bytes. This works fine at home, but at work, I suppose the proxyserver is only calling this servlet once, putting it into the cache, and never bother again to see if it has changed. So, I have to look for a way to prevent the caching of the output of this servlet.
Kristian Breifossmo
Greenhorn

Joined: Mar 01, 2005
Posts: 9
I would also check if there is a possibility that only the generated image is cached. When viewing the image, what filename (url) does the image have when appearing in the browser?


Let's say I have a servlet generating an image which always will have the name "img.jpg".

The browser sees



every time! Since there is a possibility it has cached an image with that name/size already it doesn't bother to check if it in fact is the same image.

Try making a random filename for the generated image and you should see the problem disappearing.
Gert Cuppens
Ranch Hand

Joined: Jul 13, 2003
Posts: 87
Kristian, you were right. It is the caching that showed me the first poster
all over again. I changed the line of code into this :


and with adding a superfluous parameter, I forced the proxyserver to show
me every poster I asked for. I tested it today at work and this did the trick. Thanks again.
kira yamato
Greenhorn

Joined: Mar 24, 2005
Posts: 7
i also have this problem..but instead of using servlet..mine is just printing out the filename
Something like <img src="<%=request.getContexxtPath()%>/images/<%=imageFileName%>" /> where imageFileName is the fileName i took from database..but cos i can edit my picture...so the filename when edited..is the same...just that..the picture image changes...

cos when i tried toggle between .jpg and .gif file...the image changes..but when i save .jpg..the image won't change when reload..then i have to press F5 to refresh then it reload..

when i edit and save the image file name will be like 1000001.jpg so when i save to .gif it will be 1000001.gif but when i save a .jpg file..it becomes somename.jpg to 100001.jpg

how to solve it ?
Gert Cuppens
Ranch Hand

Joined: Jul 13, 2003
Posts: 87
Kira, I advise you to start a new topic if you won't get an answer to your question soon. It is my experience that people think that the topic is solved as soon as it gets a number of replies.

So, don't wait too long. If you haven't got a good answer to your problem, start a new topic.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: refreshing the BLOB