File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

comparision between loading images from servlet vs. from files

 
Joe Nguyen
Ranch Hand
Posts: 161
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have noticed that loading memory image from serlvet are much slower than loading image from files. Theoretically, I think loading memory image must be faster because a) I call the servlet directly. b) I load images that have been cached in memory as byte arrays. On the other hand, loading images from a file as http://localhost:8080/myImage.gif requires to a) redirect my url to servlet. b) search and load myImage.gif file into memory. c) write byte array to response object.
Would you provide some suggestions, comment?
Thanks
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is your server configuration? Is this Tomcat standalone, or what?
 
Joe Nguyen
Ranch Hand
Posts: 161
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William
I am using IBM web sphere.
For memory images:
All images are kept in oracle db and load to servlet context when servlet engine is started. Servlet will set the content type and write the image byte array to the output stream. I have 15 images to display on a single page, so the above servlet will be invoked 15 times simutaneously.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would certainly expect that to be about as fast as reading a static file. There is some overhead with constructing the request and response objects that is not present when serving files directly. How much time difference are we talking about?
You are writing the byte[] with as single write I assume.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic