|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
refreshing the BLOB
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 ? |
|
#2
|
||||
|
||||
|
The error has been found : it was due to the caching of
the proxyserver at work. The fact that I wrote Code:
<img src="/gco/cluifimg" width="150" height="200"> made the proxyserver think he already had done that when I asked him for a second poster. So, he always kept on showing the first poster . What is the solution ? Well, a very simple one : add a parameter so the proxyserver thinks he has to do something different. The most simple thing is to add a parameter equal to date + time. So, writing the following lines did the trick : Code:
<img src="/gco/cluifimg?nocache=<%=new java.util.Date()%>" width="150" height="200"> With this line I fooled the proxyserver and got every poster I asked for. I thought this might interest some other members of this forum. |
|
#3
|
||||
|
||||
|
This isn't directly related to your question [in fact, I haven't finished reading your posts], but I clicked the link in your first post, and it displayed the HTML tags as plain text.
|
|
#4
|
||||
|
||||
|
how does /gco/cluifimg know which image to return?
what happens if i were to just access http://domain/gco/cluifimg ? Myself, I would have added a parameter to the image... perhaps movie id or something. This way, the proxy CAN cache if it knows it's already returned that certain image. Example: <img src="/gco/cluifimg?id=100"> <picky-observation>Where's your ALT text? </picky-observation> |
|
#5
|
||||
|
||||
|
I have a javabean to know which image should be displayed.
Inside the cluifFilmDetail.jsp I have added Code:
<jsp:useBean id="film" class="org.gertcuppens.cluif.Film" scope="session"/> this javabean contains the filmposter found in the database. With/gco/cluifimg I refer to the web.xml inside the gco folder of the webapps folder of Tomcat. This web.xml contains the following lines Code:
<servlet> <servlet-name>org.gertcuppens.controller.ImageServlet</servlet-name> <servlet-class>org.gertcuppens.controller.ImageServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>org.gertcuppens.controller.ImageServlet</servlet-name> <url-pattern>/cluifimg</url-pattern> </servlet-mapping> And so I refer to a servlet who does nothing else than accepting a blob and writing it down as an array of bytes. How does this servlet get the film javabean ? Well, this javabean is inside the session. So, all the servlet has to do is grab the session, unpack the film javabean and look for the blob of the film. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > refreshing the BLOB |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|