• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

flushing image bytes to client browser

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am facing some problem with my servlet code, I am trying to display the image returned by 3rd party server in the browser.
But it gives me error : The image “http://localhost:8080/velocity/googlechart/” cannot be displayed, because it contains errors.

code is as follows, can someone tell me what I'm doing wrong here ?

in the code,

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";

is the .png image url.



Thanks,
Bharat
 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note that this is a guess because I've never done this exact thing before. Could it be that you are reading a single character (16 bits), putting it in an int (32 bits) and then writing an int (but the documentation says that this writes a byte (8 bits)? Why don't you try isolating the read/write logic and put it into a simple test program (main). Read a file, write to a new file and see if they are the same.
 
Bharat Makwana
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tom,

Thank you very much for your time and reply, problem solved. There was a silly mistake in my previous code.
updated code for getData() method would be


Thanks again,
Bharat
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic