This week's giveaway is in the Java/Jakarta EE forum.We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line!See

Any ideas on what could be causing this?

EDIT- I removed the width/height specifications in HTML and it doesn't do it anymore. Any idea why? Any idea how I can get it to work? I want the image to be displayed smaller, but want to get the actual resolution with a right click save as.

What I understood is that if the servlet handles only one request at a time, then there's no problem. It seems to be a concurrency issue then. How is myBufferedImage declared i.e. is it a local variable or an instance field in the servlet class?? I'm assuming its an instance of java.awt.image.BufferedImage and you are using javax.imageio.ImageIO class to write to the output stream. How are you actually generating the image i.e. read the image and warp it?? Is the code to generate the image thread safe??

What I understood is that if the servlet handles only one request at a time, then there's no problem. It seems to be a concurrency issue then. How is myBufferedImage declared i.e. is it a local variable or an instance field in the servlet class?? I'm assuming its an instance of java.awt.image.BufferedImage and you are using javax.imageio.ImageIO class to write to the output stream. How are you actually generating the image i.e. read the image and warp it?? Is the code to generate the image thread safe??

The image is read in from a file, then a warp is performed on it. Your assumptions are correct. I removed all resizing from my html to be generated form my display servlet, and displayed the full size images without error. I'm not sure why resizing in html would cause this though.

I removed the width/height specifications in HTML and it doesn't do it anymore.

I couldn't understand this statement earlier. So the images distorted only when the browser tries to resize it. The only thing (that I can think of) that will generate this behavior is if the image is corrupt by some means. If there's some problem with the encoding of the image or if the image data is not correct, then resizing the image might create this kind of behavior. The image might seem correct in full size, I've seen this kind of behavior on an image processing software (which one and when is a long story). Can you check if the original images are absolutely fine, try to point the html page to the original images directly and apply resizing through HTML...

Ankit Garg wrote: I couldn't understand this statement earlier. So the images distorted only when the browser tries to resize it. The only thing (that I can think of) that will generate this behavior is if the image is corrupt by some means. If there's some problem with the encoding of the image or if the image data is not correct, then resizing the image might create this kind of behavior. The image might seem correct in full size, I've seen this kind of behavior on an image processing software (which one and when is a long story). Can you check if the original images are absolutely fine, try to point the html page to the original images directly and apply resizing through HTML...

I did do this. If I display the pages in my HTML without resizing, it works. I hadn't done this when I first posted my thread, but edited it to post that at the bottom.

For some reason it seems like the resizing in HTML is what causes it but I'm not sure why. It looks like

Removing height and width causes it to display the full images which works without distortion, but I want them resized..

Jake, what I meant was try to put the original (unmodified i.e. not warped) bike and plane images in the HTML and resize them in HTML. If they are rendered okay, then there's something wrong with the code that warps the images. Also check if generating multiple warped images is causing the problem or not. So put only 1 warped image in your HTML and refresh it many times. If there's no problem, then your code to warp the images is having concurrency issues. This is all that I can think of as the cause...

Ankit Garg wrote:Jake, what I meant was try to put the original (unmodified i.e. not warped) bike and plane images in the HTML and resize them in HTML. If they are rendered okay, then there's something wrong with the code that warps the images. Also check if generating multiple warped images is causing the problem or not. So put only 1 warped image in your HTML and refresh it many times. If there's no problem, then your code to warp the images is having concurrency issues. This is all that I can think of as the cause...

One of my coding partners ran it in IE. I didn't think to check. It actually works perfectly in IE and Chrome, but not firefox. Who know's why. Oh well this is just for a demonstration mainly, I'll just run it in IE I suppose.