可以动态画图输出的JSP例子
来源:未知 责任编辑:智问网络 发表时间:2013-09-03 12:19 点击:次
<%@ page autoFlush="false"
import="java.awt.*,java.awt.image.*,com.sun.image.codec.jpeg.*,java.util.*"
%>
<%
out.clear();
response.setContentType("image/jpeg");
response.addHeader("pragma","NO-cache");
response.addHeader("Cache-Control","no-cache");
response.addDateHeader("Expries",0);
int width=640,height=480;
BufferedImage image= new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
g.setColor(Color.white);
g.fillRect(0,0,width,height);
g.setColor(Color.red);
g.drawString("OK",270,220);
g.drawOval(10,10,100,100);
g.dispose();
ServletOutputStream sos = response.getOutputStream();
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(sos);
encoder.encode(image);
sos.close();
%>
相关新闻>>
- 发表评论
-
- 最新评论 更多>>