I am trying to develop a website in which images related to a particular entity are displayed over a JSP when we select that entity from a drop-down over a previous JSP.I am fetching images from MySQL database.
I have tried to deploy my application in both Oracle Weblogic 12c and Apache Tomcat 7.x. and I am facing almost similar type of problems with both.
A. Weblogic - Only one image used to be displayed(in case if there are multiple images related to that drop-down in database) and that also in very first attempt. For rest of attempts I am getting below error :
Condition 1 : Only one image being displayed(on first time accessing app time since started server) even if there are multiple images related to a particular drop-down
Condition 2 : If I go back by browser back button or again hitting URL(irrespective of browser) nothing is being displayed until and unless I am not restarting server
A. Tomcat - Story is slightly different in case of Tomcat.I am not getting exception over console in case of Tomcat
Condition 1 : Only one image being displayed(on first time accessing app time since started server) even if there are multiple images related to a particular drop-down. rest all images used to be shown as broken for couple for seconds until page loads completely.When page loads completely only one image used to be there(First one) and rest all broken images used to be disappeared
Condition 2 : If I go back by browser back button or again hitting URL(irrespective of browser) without restarting server all images used to be shown as broken and used to be disappeared when page loads completely
With Tomcat image displaying page used to be hang for almost 5-10 seconds
relevant code snippets have been given below :
Looking like buffer size problem in each of the cases.Could somebody please suggest.Almost stuck for 4-5 days over same thing.
I would suggest that your MultiImageservlet code around line 52 should write directly to the response's output stream and not to that other output stream which you wrapped it in. What you did is likely to run into problems with buffering of the two streams, and anyway I don't see any need for it at all.
As for the JSP, shouldn't you have something in the <img> tag? At least the "src" attribute?
It's certainly possible that this "ImageDAO" class is returning bad or inconsistent information. As far as I can see it's producing a List of which the first instance is a Blob and the second instance is an InputStream, which I find quite peculiar. Are they supposed to represent the same image? Are you sure that you get a fresh version of those two things when you call the method for the second time? I would strongly recommend you look there for your problem.
And what does "response.resetBuffer" do? Are you sure you need that? And are you sure you need to set the Content-Disposition header? Or even the Content-Length header? I would recommend you leave out unnecessary code.