Imaging_ToWeb.jsp
<%@ 페이지 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>
<헤드>
<제목>http://www.lionsky.net</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</HEAD>
<본문>
<form id="Form1" 메서드="게시물">
<input type="text" id="ID_Text" 이름=ID_Text>
<입력 유형=값 제출="GO">
</form>
</body>
</HTML>
<%
}
또 다른
{
out.clear();
response.setContentType("image/jpeg");
response.addHeader("pragma","NO-캐시");
response.addHeader("Cache-Control","no-cache");
response.addDateHeader("Expries",0);
정수 너비=300, 높이=100;
BufferedImage 이미지 = new BufferedImage(너비, 높이, BufferedImage.TYPE_INT_RGB);
그래픽 g = image.getGraphics();
//以下填充背景颜color
g.setColor(Color.lightGray);
g.fillRect(0, 0, 너비, 높이);
문자열 무작위="무작위";
//以下设置前景color
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();
}
%>