入れています
OutputStream outStream = response.getOutputStream();
私のjspファイルで、ブラウザでExcelファイルを開きます。
私は例外を取得しています、
java.lang.IllegalStateException: OutputStream already obtained
ソース
<%@page import="java.io.File"%>
<%@page import="java.awt.Image"%>
<%@page import="org.jfree.chart.ChartRenderingInfo"%>
<%@page import="org.jfree.chart.entity.StandardEntityCollection"%>
<%@page import="org.jfree.chart.ChartUtilities"%>
<%@page import="javax.imageio.ImageIO"%>
<%@page import="java.io.OutputStream"%>
<%@page import="org.jfree.chart.JFreeChart"%>
<%@page import="org.jfree.chart.ChartFactory"%>
<%@page import="org.jfree.data.general.DefaultPieDataset"%>
<%@page import="java.awt.image.RenderedImage"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Poor", new Double(43.2));
dataset.setValue("Average", new Double(55.2));
dataset.setValue("Good", new Double(4.2));
dataset.setValue("Excellent", new Double(43.2));
JFreeChart chart = ChartFactory.createPieChart("MY CHARTR", dataset, true, true, true);
OutputStream os=response.getOutputStream();
RenderedImage image = chart.createBufferedImage(800, 800);
ImageIO.write(image,"png", os);
%>
</body>
</html>
例外:
java.lang.IllegalStateException: getOutputStream() has already been called for this response