Reputation: 2456
I am using applet and creating a chart by jcchart. Now when the chart is ploited, if the user wants to export this chart as GIF then this chart should be save as on the server directory. Can anybody help me how can I do it?
Upvotes: 0
Views: 931
Reputation: 3505
It's actually quite easy with HTTP using the HttpURLConnection class to POST the data to a servlet or a PHP script running on the web server. There's an example here that shows how to use HttpURLConnection. You'll need to set a different content type header (image/png) and use a binary stream to output the data, but the basics are all there.
Upvotes: 2
Reputation: 156444
I'm assuming that the chart is generated by the server and sent to the client via some request handler (instead of, say, in an applet on the client side). If this is the case, then you can simply modify that request handler to look for an additional request parameter (say "saveImage
") which, if found and affirmative, will trigger the handler to save it to a file on the local filesystem instead of (or in addition to) returning the contents directly.
So once you've exported your chart object as a PNG, say, you can simply write that byte stream to a local file using a FileOutputStream, for example.
Upvotes: 2