bonjour
impossible d'afficher une image dans ma jsp.ci joint mon code
servlet:Graphe.java
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException{
        //response.setContentType("text/html");
        //PrintWriter out=response.getWriter();
        //out.println("<p>hello</p>");
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.addValue(120000.0, "Produit 1", "2000");
        dataset.addValue(550000.0, "Produit 1", "2001");
        dataset.addValue(180000.0, "Produit 1", "2002");
        dataset.addValue(270000.0, "Produit 2", "2000");
        dataset.addValue(600000.0, "Produit 2", "2001");
        dataset.addValue(230000.0, "Produit 2", "2002");
        dataset.addValue(90000.0, "Produit 3", "2000");
        dataset.addValue(450000.0, "Produit 3", "2001");
        dataset.addValue(170000.0, "Produit 3", "2002");
        JFreeChart barChart = ChartFactory.createBarChart("Evolution des ventes", "","Unité vendue", dataset, PlotOrientation.VERTICAL, true, true, false);
        ServletOutputStream out = response.getOutputStream();
        response.setContentType("image/png");
        ChartUtilities.writeChartAsPNG(out, barChart, 400, 300);
        }
jsp:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Graphisme</title>
</head>
<body>
    <H1>Exemple de graphique avec JFreeChart Essai1</h1>
 
    <img src="\Test3\Graphe"></img>
 
</body>
</html>
NB:Test3:nom de mon projet
merci pour votre aide