Hi All, I've one servlet which constructs the get request url and then it hit's chart api server [http://chart.apis.google.com/chart?] to get image line chart.
I am getting following response from chart api server. <img src="http://localhost:8080/velocity/googlechart/" alt="The image “http://localhost:8080/velocity/googlechart/” cannot be displayed, because it contains errors."> can anyone tell me what am I doing wrong here please. the code is protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { byte [] data = getData(); resp.setContentType("image/PNG"); resp.getOutputStream().write(data); } public static byte [] getData(){ HttpURLConnection.setFollowRedirects(false); HttpURLConnection conn; ByteArrayOutputStream boi =new ByteArrayOutputStream(); try { String urlStr = "http://chart.apis.google.com/chart? cht=lc&chs=300x250&chxt=x%2Cy&chxs=$&chxl=0%3A|1%20amn|2%20am|3%20am| 4%20am| 5%20am&chdlp=bv&chco=ff7f00%2C339999%2Ccc9966&chxr=1%2C59%2C1170&chd=t: 40,20,50,20,100|75,74,66,30,10"; URL url = new URL(urlStr); conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); int ii = -1; try { BufferedReader inp = new BufferedReader(new InputStreamReader( conn.getInputStream())); while (( ii = inp.read()) != -1) { boi.write(ii); } inp.close(); } catch (Exception e) { } } catch (IOException e) { e.printStackTrace(); } return boi.toByteArray(); } Thanks, Arya -- You received this message because you are subscribed to the Google Groups "Google Chart API" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-chart-api?hl=en.
