Forums Register Login

Images are not being displayed properly over JSP

+Pie Number of slices to send: Send
Hi,

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 :

java.net.ProtocolException: Didn't meet stated Content-Length, wrote: '0' bytes instead of stated

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 :

MultiimageServlet.java



MultiImages.jsp



Looking like buffer size problem in each of the cases.Could somebody please suggest.Almost stuck for 4-5 days over same thing.








+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
Hi Paul,

I have removed wrapper around ServletOutputStream but this doesn't changes the situation either.Thanks for your reply.


+Pie Number of slices to send: Send
Hi Paul,

I have removed wrapper around ServletOutputStream but this doesn't changes the situation either.Thanks for your reply.




Well code posted partially there,don't know how

particular section is given below



Apologies for inconvenience. the text block under img src tag is not being printed. Could be a bug with coderanch...:P
It is given below :

src="Multiimageservlet/${imageName}"
+Pie Number of slices to send: Send
 

Ankit Tripathi wrote:
Apologies for inconvenience. the text block under img src tag is not being printed. Could be a bug with coderanch...:P


No bug. You need to check the "Disable HTML" button when posting.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Thanks for reply,Paul.You were correct.From logs I can see there is inconsistency in data between ImageDAO and Multiimageservlet and data is not being flushed :

2013-07-31 22:51:02,613 [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' INFO multiImages.jsp - inside multiImages.jsp
2013-07-31 22:51:02,614 [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' INFO multiImages.jsp - multi servlet executed
2013-07-31 22:51:02,648 [ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)' INFO controller.MultiImageservlet - imageName image_mumbai
2013-07-31 22:51:02,676 [ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)' INFO util.DBConnection - inside DBConnection.createConnection
2013-07-31 22:51:02,694 [ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)' INFO util.DBConnection - inside DBConnection:value of connection objectcom.mysql.jdbc.JDBC4Connection@93a15b
2013-07-31 22:51:02,695 [ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)' INFO dao.ImageDAO - under ImageDAO-pic com.mysql.jdbc.Blob@1ae22eb
2013-07-31 22:51:02,695 [ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)' INFO dao.ImageDAO - under ImageDAO-in java.io.ByteArrayInputStream@17685a0
2013-07-31 22:51:02,696 [ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)' INFO controller.MultiImageservlet - input java.io.ByteArrayInputStream@17685a0
2013-07-31 22:51:02,696 [ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)' INFO controller.MultiImageservlet - under MultiImageservlet-pic com.mysql.jdbc.Blob@1ae22eb
2013-07-31 22:51:02,696 [ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)' INFO controller.MultiImageservlet - under MultiImageservlet-in java.io.ByteArrayInputStream@17685a0

2013-07-31 22:52:34,228 [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' INFO util.DBConnection - inside DBConnection.createConnection
2013-07-31 22:52:34,255 [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' INFO util.DBConnection - inside DBConnection:value of connection objectcom.mysql.jdbc.JDBC4Connection@1846542
2013-07-31 22:52:35,752 [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' INFO util.DBConnection - inside DBConnection.createConnection
2013-07-31 22:52:35,777 [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' INFO util.DBConnection - inside DBConnection:value of connection objectcom.mysql.jdbc.JDBC4Connection@1e550b8
2013-07-31 22:52:35,799 [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' INFO multiImages.jsp - inside multiImages.jsp
2013-07-31 22:52:35,799 [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' INFO multiImages.jsp - multi servlet executed
2013-07-31 22:52:35,841 [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' INFO controller.MultiImageservlet - imageName image_Man
2013-07-31 22:52:35,883 [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' INFO util.DBConnection - inside DBConnection.createConnection
2013-07-31 22:52:35,909 [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' INFO util.DBConnection - inside DBConnection:value of connection objectcom.mysql.jdbc.JDBC4Connection@179651e
2013-07-31 22:52:35,910 [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' INFO dao.ImageDAO - under ImageDAO-pic com.mysql.jdbc.Blob@1b92d6f
2013-07-31 22:52:35,911 [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' INFO dao.ImageDAO - under ImageDAO-in java.io.ByteArrayInputStream@15169f4
2013-07-31 22:52:35,911 [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' INFO controller.MultiImageservlet - input java.io.ByteArrayInputStream@17685a0
2013-07-31 22:52:35,912 [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' INFO controller.MultiImageservlet - under MultiImageservlet-pic com.mysql.jdbc.Blob@1ae22eb
2013-07-31 22:52:35,912 [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' INFO controller.MultiImageservlet - under MultiImageservlet-in java.io.ByteArrayInputStream@17685a0

+Pie Number of slices to send: Send
Hi Paul,

It worked like charm..Thanks!..

I am resetting mixList after every call of method.
Getting married means "We're in love, so let's tell the police!" - and invite this tiny ad to the wedding:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 3753 times.
Similar Threads
Display of images in JSP
IllegalStateException:
Response of a io/Image stream
jsp to display image
Download file HELP?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 06:38:33.