<%
String encode="jpeg";
String uri=request.getRequestURI();
String myurl="http://"+request.getHeader("Host")+uri.substring(0,uri.length()-15); //15 ist the length of my page name
String dataFile="combined2Positions.txt";
if (request.getParameter("chart")!=null) dataFile=request.getParameter("chart");

response.setContentType("text/html");
response.setDateHeader ("Expires",0);

// get output stream
java.io.PrintWriter outb=response.getWriter();

	
// size of the chart image		   
int w=500;
int h=500;


// create Chart from data file
com.java4less.rchart.ChartLoader loader=new com.java4less.rchart.ChartLoader();
loader.loadFromFile(myurl+dataFile,false);
com.java4less.rchart.Chart chart=loader.build(false,false);

// set size of the chart
chart.setSize(w,h);

// we must paint the chart once before we can retrieve the image map
com.java4less.rchart.gc.ChartImage chartImage= com.java4less.rchart.gc.GraphicsProvider.createImage(w,h);
com.java4less.rchart.gc.ChartGraphics chartGraphics=chartImage.getGraphics();
chart.paint(chartGraphics);
chartGraphics.dispose();
chartImage.dispose();


// encode image and send output to the browser
String htmlMap=chart.getHTMLImageMap("Chart");

outb.print("<html>");
//outb.print("<META HTTP-EQUIV='Refresh' CONTENT='3'>");
outb.print("<body>");

outb.print("<img src='getChart.jsp?chart="+dataFile+"' BORDER=0 NAME='ICHART' USEMAP='#Chart'>");
outb.print(htmlMap);			
outb.print("</body>");
outb.print("</html>");


outb.close();


%>