JFC on the JSP page, do not put the picture on the server side, only into session sessions (available)

Source: Internet
Author: User
Tags sessions

JFC on the JSP page, do not place the image on the server side, only into session sessions. One of the main uses of JFC is a servlet class.

<%@ page contenttype= "text/html;charset=gb2312" errorpage= ". /common/error.jsp "%><%@ page import=" dqz.jsp.* "%><%@ page import=" java.sql.* "%><%@ page import=" javax.sql.* "%><%@ page import=" javax.naming.* "%><%@ include file=". /common/config.jsp "%><%@ include file=" reporter_session.jsp "%><%@ page import=" Org.jfree.chart.servlet . Servletutilities, Java.awt.Font, Java.awt.Color, Org.jfree.chart.ChartFactory, Org.jfree.chart.ChartFra  Me, Org.jfree.chart.JFreeChart, Org.jfree.chart.StandardChartTheme, Org.jfree.chart.plot.CategoryPlot,  Org.jfree.chart.plot.PlotOrientation, Org.jfree.data.category.CategoryDataset, Org.jfree.data.category.defaultcategorydataset,org.jfree.chart.chartutilities, Org.jfree.chart.axis.categoryaxis,org.jfree.chart.axis.numberaxis,org.jfree.chart.axis.valueaxis, Org.jfree.chart.labels.standardcategoryitemlabelgenerator,org.jfree.chart.renderer.category.barrenderer, org.jfree.chart.title.tExttitle, Java.io.fileoutputstream,java.io.ioexception, Java.io.printwriter,java.util.arraylist, Java.util.HashMap, Java.util.list,java.util.map,java.text.decimalformat, Java.text.numberformat,java.io.fil Eoutputstream,java.io.ioexception,java.io.printwriter,java.sql.connection,java.sql.drivermanager, Java.sql.preparedstatement,java.sql.resultset,java.sql.sqlexception,java.util.arraylist,java.util.list, Org.jfree.chart.servlet.ServletUtilities, Java.util.map,org.jfree.chart.labels.standardpiesectionlabelgenerator , Org.jfree.chart.labels.standardpietooltipgenerator,org.jfree.chart.plot.pieplot3d, Org.jfree.data.general.defaultpiedataset,org.jfree.data.general.piedataset, Org.jfree.chart.title.LegendTitle " %>//=========================== Histogram test begins =================================================== Defaultcategorydataset DataSet = new Defaultcategorydataset ();d ataset.addvalue (610, "Guangzhou", "Pork");d Ataset.addvalue (220 , "Guangzhou", "Beef");d ataset.addvalue (530, "Guangzhou", "Chicken");d ataset.AddValue (340, "Guangzhou", "Fish"); Jfreechart Mbarchart = Chartfactory.createbarchart3d ("Meat Sales Chart", "Meat", "Sales", Dataset,plotorientation.vertical,false,        False,false);          Chart Title set Texttitle Mtexttitle = Mbarchart.gettitle ();          Mtexttitle.setfont (New Font ("Blackbody", Font.Bold, 20));          Mbarchart.settitle (New Texttitle ("School Personnel Map", New Font ("Blackbody", Font.Bold, 20)));          Chart legend Settings Legendtitle mlegend = Mbarchart.getlegend ();          if (mlegend! = null) Mlegend.setitemfont (new Font ("Arial", Font.center_baseline, 15));          Mbarchart.getlegend (). Setitemfont (New Font ("Arial", Font.center_baseline, 15));                    Set the column chart axis categoryplot Mplot = (categoryplot) mbarchart.getplot ();          X-axis Categoryaxis Mdomainaxis = Mplot.getdomainaxis ();          Sets the font mdomainaxis.setlabelfont for the x-axis title (new font ("Arial", Font.plain, 15));          Set x-axis coordinate font mdomainaxis.setticklabelfont (new font ("Arial", Font.plain, 15));        Y-Axis  Valueaxis Mvalueaxis = Mplot.getrangeaxis ();          Sets the y-axis title font mvalueaxis.setlabelfont (new font ("Arial", Font.plain, 15));          Sets the y-axis coordinate font mvalueaxis.setticklabelfont (new font ("Arial", Font.plain, 15));          Column display value Barrenderer mrenderer= new Barrenderer ();          Mrenderer.setitemlabelgenerator (New Standardcategoryitemlabelgenerator ());          Mrenderer.setitemlabelfont (New Font ("Arial", Font.plain, 10));          Mrenderer.setitemlabelsvisible (TRUE);  Mplot.setrenderer (Mrenderer); String filename = servletutilities.savechartaspng (Mbarchart, +, n, null, session); String Graphurl = Request.getcontextpath () + "/displaychart?filename=" + filename;//=========================== Histogram test ends ===================================================//=========================== pie chart test begins =================                 ==================================//Set data source Defaultpiedataset Mpiedataset = new Defaultpiedataset (); Mpiedataset.setvalue ("Pre-market", new doUble (10));           Mpiedataset.setvalue ("Project", New Double (15));           Mpiedataset.setvalue ("plan", New Double (20));           Mpiedataset.setvalue ("Requirements and Design", New Double (10));           Mpiedataset.setvalue ("Execution Control", New Double (25));           Mpiedataset.setvalue ("Closure", new Double (10));                 Mpiedataset.setvalue ("Operation Dimension", New Double (10));          Build chart Jfreechart Mpiechart = Chartfactory.createpiechart3d ("Project Progress Distribution", Mpiedataset, True, true, false);          Set the chart title Mpiechart.settitle (New Texttitle ("Project status Distribution", New Font ("Blackbody", Font.center_baseline, 20)));                    Set legend Font mpiechart.getlegend (). Setitemfont (New Font ("Arial", Font.roman_baseline, 15));          Pieplot3d Mpieplot = (Pieplot3d) mpiechart.getplot (); Displays the percentage//mpieplot.setlabelgenerator by default (new Standardpiesectionlabelgenerator (Standardpietooltipgenerator.defau          Lt_tooltip_format)); Percentage displayed in the Picture: Custom mode, {0} for options, {1} for numeric value, {2} for percentage, two bits for mpieplot after decimal point.Setlabelgenerator (New Standardpiesectionlabelgenerator ("{0}={1} ({2})", Numberformat.getnumberinstance (), New          DecimalFormat ("0%")); The bottom legend shows the percentage: custom, {0} represents an option, {1} represents a number, and {2} represents the percentage mpieplot.setlegendlabelgenerator (new Standardpiesectionlabelg          Enerator ("{0}={1} ({2})");                  Set the pie chart label font mpieplot.setlabelfont (new font ("Arial", Font.plain, 15));    String piefilename = servletutilities.savechartaspng (Mpiechart, n, +, NULL, session); String Piegraphurl = Request.getcontextpath () + "/displaychart?filename=" + piefilename;//=========================== Pie chart test End ===================================================//=========================== Line chart test start =================          ================================== standardcharttheme mchartthemezxt = new Standardcharttheme ("CN");          Mchartthemezxt.setlargefont (New Font ("Blackbody", Font.Bold, 20));          Mchartthemezxt.setextralargefont (New Font ("Arial", Font.plain, 15)); Mchartthemezxt.setregularfont (new Font ("Arial", Font.plain, 15));             Chartfactory.setcharttheme (MCHARTTHEMEZXT);        Row keys ...        String series1 = "First";        String Series2 = "Second";        String Series3 = "Third";        Column keys ...        String type1 = "Type 1";        String type2 = "Type 2";        String type3 = "Type 3";        String type4 = "Type 4";        String Type5 = "Type 5";        String Type6 = "Type 6";        String Type7 = "Type 7";        String Type8 = "Type 8";        Create the DataSet ...        Defaultcategorydataset DATASET_ZXT = new Defaultcategorydataset ();        Dataset_zxt.addvalue (1.0, Series1, type1);        Dataset_zxt.addvalue (4.0, series1, type2);        Dataset_zxt.addvalue (3.0, series1, type3);        Dataset_zxt.addvalue (5.0, series1, TYPE4);        Dataset_zxt.addvalue (5.0, series1, Type5);        Dataset_zxt.addvalue (7.0, series1, Type6);        Dataset_zxt.addvalue (7.0, series1, Type7);  Dataset_zxt.addvalue (0.0, series1, type8);      Dataset_zxt.addvalue (5.0, Series2, type1);        Dataset_zxt.addvalue (7.0, Series2, type2);        Dataset_zxt.addvalue (6.0, Series2, type3);        Dataset_zxt.addvalue (8.0, Series2, type4);        Dataset_zxt.addvalue (4.0, Series2, Type5);        Dataset_zxt.addvalue (4.0, Series2, Type6);        Dataset_zxt.addvalue (2.0, Series2, Type7);        Dataset_zxt.addvalue (1.0, Series2, Type8);        Dataset_zxt.addvalue (4.0, Series3, type1);        Dataset_zxt.addvalue (3.0, Series3, type2);        Dataset_zxt.addvalue (2.0, Series3, type3);        Dataset_zxt.addvalue (3.0, Series3, type4);        Dataset_zxt.addvalue (6.0, Series3, Type5);        Dataset_zxt.addvalue (3.0, Series3, Type6);        Dataset_zxt.addvalue (4.0, Series3, Type7);                            Dataset_zxt.addvalue (3.0, Series3, Type8);                   Jfreechart Mzxtchart = Chartfactory.createlinechart ("Line chart", "Time", "Quantity", DATASET_ZXT, PlotOrientation.vertical, True, true, false);          Categoryplot Mzxtplot = (categoryplot) mzxtchart.getplot ();          Mzxtplot.setbackgroundpaint (Color.light_gray); Mzxtplot.setrangegridlinepaint (Color.Blue)///Background horizontal dashed mzxtplot.setoutlinepaint (color.red);//Boundary line Mzxtcha Rt.getlegend (). Setitemfont (New Font ("Arial", Font.plain, 12));//Graph column Categoryaxis Mzxtdomainaxis = mzxtplot.ge Tdomainaxis ();  X-coordinate Mzxtdomainaxis.setticklabelfont (new Font ("Sans-serif", Font.plain, 11));              X Mzxtdomainaxis.setlabelfont (New Font ("Arial", Font.plain, 12));     Valueaxis Mzxtvalueaxis = Mzxtplot.getrangeaxis ();  Mzxtvalueaxis.setticklabelfont (New Font ("Sans-serif", Font.plain, 12));       Y Mzxtvalueaxis.setlabelfont (New Font ("Blackbody", Font.plain, 12));                      Texttitle zxttexttitle = Mzxtchart.gettitle ();//coordinates header set Zxttexttitle.setfont ("bold", Font.plain, 20); STring Zxtfilename = servletutilities.savechartaspng (Mzxtchart, n, +, NULL, session); String Zxtgraphurl = Request.getcontextpath () + "/displaychart?filename=" + zxtfilename;//=========================== Line chart test end ===================================================%><br/><br/>

  

JFC on the JSP page, do not put the picture on the server side, only into session sessions (available)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.