简体   繁体   English

JSP将“渲染的”图像另存为

[英]JSP save “rendered” image as

I have a servlet that generate charts, based on given parameters. 我有一个根据给定参数生成图表的servlet。

I need to be able to save those charts in the server as a regular image: myImage.png for example. 我需要能够将那些图表保存为服务器中的常规图像:例如myImage.png。

These charts are created with a code like this: 这些图表是使用以下代码创建的:

http://127.0.0.1:8080/servlet/graficadorPS?type=area&val1=32.0|32.0|38.0|92.0&cat1=y|y|y|y&eje1=D|I|S|C&titulo=HF&ancho=130&alto=260

so, the image "per se" doesn't exist anywhere. 因此,“本身”的图像在任何地方都不存在。

Is there a way to do this?? 有没有办法做到这一点??

Sample code 样例代码

public static void main(String[] args) throws NumberFormatException, IOException, ParseException {
    URL url  = new URL("http://cdn.portableapps.com/GoogleChromePortable_128.png");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();

    InputStream is = conn.getInputStream();


      BufferedImage image = ImageIO.read(is);
      OutputStream os = new FileOutputStream(new File("output.png"));
      ImageIO.write(image, "png", os);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM