<% @ Page Language = "Java" pageencoding = "UTF-8" %> <br/> <% @ page import = "org. jfree. data. general. defaultpiedataset, <br/> Org. jfree. chart. jfreechart, <br/> Org. jfree. chart. chartfactory, <br/> Org. jfree. chart. servlet. servletutilities "%> <br/> <% <br/> defaultpiedataset DPD = new defaultpiedataset (); <br/> DPD. setvalue ("Administrator", 25); <br/> DPD. setvalue ("market personnel", 25); <br/> DPD. setvalue ("Developer", 45); <br/> DPD. setva Lue ("other personnel", 10); <br/> jfreechart chart = chartfactory. createpiechart ("A company's organizational structure 2D pie chart", DPD, true, false, false); <br/> string filename = servletutilities. savechartaspng (chart, 1024,768, session); <br/> string url = request. getcontextpath () + "/servlet/displaychart? Filename = "+ filename; <br/> %> <br/> <br/> <% -- <br/> ======================================== ========================================================== ====================================< br/> Org. jfree. chart. servlet. the displaychart class inherits javax. servlet. HTTP. httpservlet. It is described as follows <br/> Servlet used for streaming charts to the client browser from the temporary directory <br/> you need to add this servlet and mapping to your deployment descriptorin order to get it To Work <br/> Translation: this is a Servlet used to send images to the client browser in the form of a stream from the temporary directory <br/> to make it work, you need to deploy the descriptor (web. XML) add this servlet and Its ing <br/> because we need to display images on the JSP page, we need to go to the Web. display the displaychart in XML as follows: <br/> <servlet> <br/> <servlet-Name> displaychar T </servlet-Name> <br/> <servlet-class> Org. jfree. chart. servlet. displaychart </servlet-class> <br/> </servlet> <br/> <servlet-mapping> <br/> <servlet-Name> displaychart </servlet-Name> <br/> <URL-pattern>/servlet/displaychart </url-pattern> <br/> </servlet-mapping> <br/>===== ========================================================== ========================================================== ============< br/> chartutilities. writechartasjpeg () is for JA Va application <br/> servletutilities. savechartaspng () is web-oriented <br/> ============================================ ========================================================== ======================================< br/> savechartaspng () the returned value is the name of the generated image. The generated image is saved in the temporary directory of the server. <br/> the temporary directory of Tomcat 6 is D: /program files/tomcat6/TEMP directory <br/> here, our Java code is written in the JSP page <br/> so every time you access or refresh the page, an image is generated in the temporary directory of the server. <br/> the name of the image is jfreechart-62412.png.] <br/>============== = ========================================================== ==============================================================< Br/> when used in Web. when the servlet named displaychart is configured in XML <br/> it searches for images in the temporary directory of the server based on its filename, <br/> therefore, the filename parameter should be specified for displaychart, that is, [displaychart? The filename =] part is fixed <br/> ============================== ========================================================== ======================================< br/> -- %>