Imaging_ToWeb.jsp
<%@ page autoFlush="false" import="java.awt.*,java.awt.image.*,com.sun.image.codec.jpeg.*,java.util.*"%>
<%
String ImageStr = request.getParameter("ID_Text");
if(ImageStr==null || ImageStr.equals(""))
{
response.setContentType("text/html; charset=gb2312");
%>
<HTML>
<头>
<title>http://www.lionsky.net</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</头>
<正文>
<form id="Form1" method="post">
<输入类型=“文本”id=“ID_Text”名称=ID_Text>
<输入类型=提交值=“GO”>
</形式>
</正文>
</HTML>
<%
}
别的
{
输出.clear();
响应.setContentType(“图像/jpeg”);
response.addHeader("pragma","NO-cache");
response.addHeader("缓存控制","无缓存");
response.addDateHeader("Expries",0);
int 宽度=300,高度=100;
BufferedImage 图像 = new BufferedImage(宽度, 高度, BufferedImage.TYPE_INT_RGB);
图形 g = image.getGraphics();
//以下填充背景颜色
g.setColor(Color.lightGray);
g.fillRect(0, 0, 宽度, 高度);
字符串随机=“随机”;
//以下设置前方景色
g.setColor(Color.BLACK);
g.drawString(" http://www.downcodes.com",10,20 );
g.drawString("作者:Lion[[email protected]]",10,40);
g.drawLine(10,50,290,50);
g.drawString(ImageStr,10,70);
g.dispose();
ServletOutputStream outStream = response.getOutputStream();
JPEGImageEncoder编码器=JPEGCodec.createJPEGEncoder(outStream);
编码器.编码(图像);
outStream.close();
}
%>