Nonsense not to say, directly on the code.
Create a new JSP file, named Img.jsp, with the following code:
1<% @pageImport= "Javax.imageio.ImageIO"%>2<% @pageImport= "Java.awt.*"%>3<% @pageImport= "Java.awt.image.BufferedImage"%>4<%@ page language= "java" contenttype= "Image/png"%>5 6<%7BufferedImage image =NewBufferedImage (300, 400,8 Bufferedimage.type_int_rgb);9Graphics g =image.getgraphics ();TenG.fillrect (0, 0, 400, 400); One AG.setcolor (NewColor (255, 0, 0)); -G.fillarc (20, 20, 100, 100, 30, 120); - theG.setcolor (NewColor (0, 255, 0)); -G.fillarc (20, 20, 100, 100, 150, 120); - -G.setcolor (NewColor (0, 0, 255)); +G.fillarc (20, 20, 100, 100, 270, 120); - +G.setcolor (NewColor (0, 0, 0)); AG.setfont (NewFont ("Arial Black", Font.plain, 16)); atg.DrawString ("Red:climb", 200, 60); -g.DrawString ("Green:swim", 200, 100); -g.DrawString ("Blue:jump", 200, 140); - - g.dispose (); - inImageio.write (Image, "PNG", Response.getoutputstream ()); -%>
Viewing directly in the browser will show a picture, as follows:
However, opening the browser's debugging tool will prompt an error:Failed to load resource:net::err_incomplete_chunked_encoding
In fact, we do this kind of picture, the most time should be the production of verification code, that is, to other pages to call, at this time a new JSP page, the code more only need to increase
Access the JSP file, report the same error, and the page will not show the picture, but the effect flashed through ~ ~
This phenomenon only appears in Chrome (opera also has), IE, Firefox normal display. Reasons for not checking.
Find a similar problem here, said Chrome bug, waiting to be resolved.
JSP as IMG SRC when chrome bug