weblogic 中的分块传输编码问题。我不知道如何配置 weblogic 以获得未分块的 jsp 图像

Chunked transfer encoding problems in weblogic. I do not know how to configure weblogic in order to get an jsp image not chunked

我有一个简单的 jsp 文件,它使用以下行调用 jsp 图像: <img src='captcha.jsp' id='captcha'>

问题是这张图片加载不正确。我在使用分块编码的 weblogic 方面遇到问题。

我在 Tomcat 和 Glasfish 中对此进行了测试,我没有遇到任何问题。 我已经通过网络搜索,但我不知道如何配置 weblogic。我试图在 weblogic 控制台中更改参数,但我无法成功。

我在 jsp 文件中也尝试过不同的方法。使用东西作为 response.setContentLength 但不工作。

最后,我更改了 属性 ChunkedTransferDisabled = "true" 但它不起作用。我不知道为什么它现在不起作用

能否请您帮助我或阐明我的想法。

非常感谢。

Captcha.jsp

我们创建图像

    BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

    Graphics2D g = (Graphics2D) bufferedImage.getGraphics();

//Some stuff

然后写

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();

我终于解决了这个问题。图片没有正确发送,因为缓冲区已满或我不知道为什么。分块编码没有问题。我认为问题是 content-length header 已满,可能是 weblogic 错误。

只需在 captcha.jsp 的开头添加 response.resetBuffer() 即可解决问题。