I have a simple jsp file that calls an jsp image with this line:
<img src='captcha.jsp' id='captcha'>
The problem is that this image is not loaded properly. I have problems with weblogic with chunked encoding.
I tested this in Tomcat and Glasfish and i do not have problems. I have searched through the net and i do not know how to configure weblogic. I tried to change parameters in the weblogic console but i couldn't succeed.
I have tried as well differents approaches in the jsp file. Using things as response.setContentLength but is not working.
Finally, I have changed the property ChunkedTransferDisabled = "true"
but it is not working. I do not know why it is not working now
Can you please help me or clarify my ideas.
Thank you very much.
Captcha.jsp
We create the image
BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g = (Graphics2D) bufferedImage.getGraphics();
//Some stuff
then write
Iterator iter = ImageIO.getImageWritersByFormatName(imageFormat);
if( iter.hasNext() ) {
ImageWriter writer = (ImageWriter)iter.next();
ImageWriteParam iwp = writer.getDefaultWriteParam();
if ( imageFormat.equalsIgnoreCase("jpg") || imageFormat.equalsIgnoreCase("jpeg") ) {
iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
iwp.setCompressionQuality(imageQuality);
}
writer.setOutput(ImageIO.createImageOutputStream(response.getOutputStream()));
IIOImage imageIO = new IIOImage(bufferedImage, null, null);
writer.write(null, imageIO, iwp);
}
else {
throw new RuntimeException("no encoder found for jsp");
}
// Colocamos el string en la sesión
request.getSession().setAttribute("captcha", finalString.toString());
g.dispose();
Finally I solved this problem. The image was not sent properly because the buffer was full or i do not know why. There was no problem about chunked encoding. I think that the problem was that content-length header was full, maybe weblogic bug.
Just adding response.resetBuffer()
at the beggining of captcha.jsp solved the problem.