Re: Storing images in SQL BLOBs
On Wed, 2005-09-07 at 14:16 +1000, Murray Collingwood wrote: > Thanks Jason > > I'm having a strange issue with serving up these images. I'm getting a > "socket write > error" from the following code. There are 3 images, the details follow the > code. The > first two images appear, the third fails to appear. >From the error it looks like the browser has decided to close the connection in the middle for some reason. It could be for various reasons - like timeout or a bug or it decides that it can't handle the file type. You should accommodate for this error anyway because even when everything is dandy the network or the client may go down at any stage. What do you see on the browser's side? Can you try using wget/curl instead of a web browser? Cheers, --Amos - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Storing images in SQL BLOBs
Thanks Jason I'm having a strange issue with serving up these images. I'm getting a "socket write error" from the following code. There are 3 images, the details follow the code. The first two images appear, the third fails to appear. response.setContentLength((int) f.length()); response.setContentType("application/x-file-download"); response.setHeader("Content-disposition", "attachment; filename=" + name ); System.err.println(">> " + response.toString()); FileInputStream fis = new FileInputStream(f); ServletOutputStream sos = response.getOutputStream(); byte[] buffer = new byte[32768]; int n = 0; int x = 0; while ((n = fis.read(buffer)) != -1) { System.err.println(">> x = " + x++ + " n = " + n); sos.write(buffer, 0, n); } fis.close(); sos.flush(); } catch (Exception e) { System.err.println(">> Error serving image: " + request.getParameter("local")); e.printStackTrace(); } Image 1 bytes: 7734 Image 2 bytes: 79279 Image 3 bytes: 2871052 (image called "2_another quite night on tour.tif") The generated log file: >> [EMAIL PROTECTED] >> x = 0 n = 7734 >> [EMAIL PROTECTED] >> x = 0 n = 32768 >> x = 1 n = 32768 >> [EMAIL PROTECTED] >> x = 0 n = 32768 >> x = 1 n = 32768 >> x = 2 n = 32768 >> x = 3 n = 32768 >> x = 4 n = 32768 >> x = 5 n = 32768 >> x = 6 n = 32768 >> x = 7 n = 32768 >> x = 8 n = 32768 >> x = 9 n = 32768 >> x = 2 n = 13743 >> x = 10 n = 32768 >> Error serving image: 2_another quite night on tour.tif ClientAbortException: java.net.SocketException: Connection reset by peer: socket write error at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:366) at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:403) at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:323) at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:392) at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:381) at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:76 ) at com.bpx.website.controller.action.Image.execute(Image.java:54) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.ja va:419) Appreciate any help. Kind regards mc On 7 Sep 2005 at 15:33, Jason Lea wrote: > Oh right, you need to discover the location automatically. > > Something like this might work: > > request.getSession().getServletContext().getRealPath("/images"); > > That should give you the full path to /images. > > > > Murray Collingwood wrote: > > >How do I find the path actual path to "/images" assuming of course that > >"/images" is a > >url reference? > > > >Is there something like $STRUTS_ROOT? > > > >Kind regards > >mc > > > > > >On 7 Sep 2005 at 14:50, Jason Lea wrote: > > > > > > > >>I guess it depends if you are trying to restrict access to these images. > >> > >>To make all images available for anyone, put them into /images, for example. > >> > >>If you want to not allow any direct access to them, you could create a > >>directory under /WEB-INF and put them there. You would then have to > >>create something to serve the images up to browser. > >> > >>Or set up container managed security, put them into /auth/images, then > >>put a security constraint on /auth/images so that only users with the > >>required role is allowed to view the images. > >> > >> > >>Murray Collingwood wrote: > >> > >> > >> > >>>Hi all (Gosh, I'm starting to feel like a regular on this list...) > >>> > >>>After my experiences below I have rewritten my application to store the > >>>images in a > >>>local sub-directory, however when I ran this new version the sub-directory > >>>was > >>> > >>> > >created > > > > > >>>under the Tomcat/bin directory - not really appropriate. > >>> > >>>Should I be trying to reference my application directory and store the > >>>images under > >>> > >>> > >my > > > > > >>>"/WEB-INF" directory? > >>> > >>>Do I have to setup a special directory on the server that can be > >>>referenced by > >>> > >>> > >Tomcat > > > > > >>>to serve the images directly? > >>> > >>>What are others doing? > >>> > >>>Also, if you are referencing this directory in your application, is it > >>>hard-coded or do > >>> > >>> > >you > > > > > >>>have an entry in your 'context.xml'? What sort of entry do you use? > >>> > >>>Kind regards > >>>mc > >>> > >>> > >>> > >>> > >>-- > >>Jason Lea > >> > >> > >> > >>- > >>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>For additional commands, e-mail: [EM
Re: Storing images in SQL BLOBs
Oh right, you need to discover the location automatically. Something like this might work: request.getSession().getServletContext().getRealPath("/images"); That should give you the full path to /images. Murray Collingwood wrote: How do I find the path actual path to "/images" assuming of course that "/images" is a url reference? Is there something like $STRUTS_ROOT? Kind regards mc On 7 Sep 2005 at 14:50, Jason Lea wrote: I guess it depends if you are trying to restrict access to these images. To make all images available for anyone, put them into /images, for example. If you want to not allow any direct access to them, you could create a directory under /WEB-INF and put them there. You would then have to create something to serve the images up to browser. Or set up container managed security, put them into /auth/images, then put a security constraint on /auth/images so that only users with the required role is allowed to view the images. Murray Collingwood wrote: Hi all (Gosh, I'm starting to feel like a regular on this list...) After my experiences below I have rewritten my application to store the images in a local sub-directory, however when I ran this new version the sub-directory was created under the Tomcat/bin directory - not really appropriate. Should I be trying to reference my application directory and store the images under my "/WEB-INF" directory? Do I have to setup a special directory on the server that can be referenced by Tomcat to serve the images directly? What are others doing? Also, if you are referencing this directory in your application, is it hard-coded or do you have an entry in your 'context.xml'? What sort of entry do you use? Kind regards mc -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 6/09/2005 FOCUS Computing Mob: 0415 24 26 24 [EMAIL PROTECTED] http://www.focus-computing.com.au -- Jason Lea
Re: Storing images in SQL BLOBs
How do I find the path actual path to "/images" assuming of course that "/images" is a url reference? Is there something like $STRUTS_ROOT? Kind regards mc On 7 Sep 2005 at 14:50, Jason Lea wrote: > I guess it depends if you are trying to restrict access to these images. > > To make all images available for anyone, put them into /images, for example. > > If you want to not allow any direct access to them, you could create a > directory under /WEB-INF and put them there. You would then have to > create something to serve the images up to browser. > > Or set up container managed security, put them into /auth/images, then > put a security constraint on /auth/images so that only users with the > required role is allowed to view the images. > > > Murray Collingwood wrote: > > >Hi all (Gosh, I'm starting to feel like a regular on this list...) > > > >After my experiences below I have rewritten my application to store the > >images in a > >local sub-directory, however when I ran this new version the sub-directory > >was created > >under the Tomcat/bin directory - not really appropriate. > > > >Should I be trying to reference my application directory and store the > >images under my > >"/WEB-INF" directory? > > > >Do I have to setup a special directory on the server that can be referenced > >by Tomcat > >to serve the images directly? > > > >What are others doing? > > > >Also, if you are referencing this directory in your application, is it > >hard-coded or do you > >have an entry in your 'context.xml'? What sort of entry do you use? > > > >Kind regards > >mc > > > > > > -- > Jason Lea > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -- > No virus found in this incoming message. > Checked by AVG Anti-Virus. > Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 6/09/2005 > FOCUS Computing Mob: 0415 24 26 24 [EMAIL PROTECTED] http://www.focus-computing.com.au -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 6/09/2005 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Storing images in SQL BLOBs
I guess it depends if you are trying to restrict access to these images. To make all images available for anyone, put them into /images, for example. If you want to not allow any direct access to them, you could create a directory under /WEB-INF and put them there. You would then have to create something to serve the images up to browser. Or set up container managed security, put them into /auth/images, then put a security constraint on /auth/images so that only users with the required role is allowed to view the images. Murray Collingwood wrote: Hi all (Gosh, I'm starting to feel like a regular on this list...) After my experiences below I have rewritten my application to store the images in a local sub-directory, however when I ran this new version the sub-directory was created under the Tomcat/bin directory - not really appropriate. Should I be trying to reference my application directory and store the images under my "/WEB-INF" directory? Do I have to setup a special directory on the server that can be referenced by Tomcat to serve the images directly? What are others doing? Also, if you are referencing this directory in your application, is it hard-coded or do you have an entry in your 'context.xml'? What sort of entry do you use? Kind regards mc -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Storing images in SQL BLOBs
Hi all (Gosh, I'm starting to feel like a regular on this list...) After my experiences below I have rewritten my application to store the images in a local sub-directory, however when I ran this new version the sub-directory was created under the Tomcat/bin directory - not really appropriate. Should I be trying to reference my application directory and store the images under my "/WEB-INF" directory? Do I have to setup a special directory on the server that can be referenced by Tomcat to serve the images directly? What are others doing? Also, if you are referencing this directory in your application, is it hard-coded or do you have an entry in your 'context.xml'? What sort of entry do you use? Kind regards mc On 7 Sep 2005 at 10:55, Murray Collingwood wrote: > Hi all > > I got my app storing and retrieving images from MySQL database - what a > mistake! > > A simple image of 130k took 8 seconds to appear on the page. This is a huge > time to > sit and stare at a large blank space on the screen. > > I can't help thinking that this is a bug (performance problem) somewhere. > What could > the servlet / database / whatever be doing for such a long time? No need to > respond. > > Kind regards > mc > > > > FOCUS Computing > Mob: 0415 24 26 24 > [EMAIL PROTECTED] > http://www.focus-computing.com.au > > > > -- > No virus found in this outgoing message. > Checked by AVG Anti-Virus. > Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 6/09/2005 > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -- > No virus found in this incoming message. > Checked by AVG Anti-Virus. > Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 6/09/2005 > FOCUS Computing Mob: 0415 24 26 24 [EMAIL PROTECTED] http://www.focus-computing.com.au -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 6/09/2005 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Storing images in SQL BLOBs
Hi all I got my app storing and retrieving images from MySQL database - what a mistake! A simple image of 130k took 8 seconds to appear on the page. This is a huge time to sit and stare at a large blank space on the screen. I can't help thinking that this is a bug (performance problem) somewhere. What could the servlet / database / whatever be doing for such a long time? No need to respond. Kind regards mc FOCUS Computing Mob: 0415 24 26 24 [EMAIL PROTECTED] http://www.focus-computing.com.au -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 6/09/2005 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]