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>
<HEAD>
<title>Http://www.lionsky.net</title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
</HEAD>
<body>
<form id= "Form1" method= "POST" >
<input type= "text" id= "Id_text" name=id_text>
<input type=submit value= "Go" >
</form>
</body>
</HTML>
<%
}
Else
{
Out.clear ();
Response.setcontenttype ("Image/jpeg");
Response.AddHeader ("Pragma", "no-cache");
Response.AddHeader ("Cache-control", "No-cache");
Response.adddateheader ("Expries", 0);
int width=300, height=100;
BufferedImage image = new BufferedImage (width, height, bufferedimage.type_int_rgb);
Graphics g = image.getgraphics ();
Following fill background color
G.setcolor (Color.lightgray);
G.fillrect (0, 0, width, height);
String random= "random";
The following sets the foreground color
G.setcolor (Color.Black);
g.DrawString ("Http://www.knowsky.com", 10,20);
g.DrawString ("author:lion[lion-a@sohu.com]", 10,40);
G.drawline (10,50,290,50);
g.DrawString (imagestr,10,70);
G.dispose ();
Servletoutputstream OutStream = Response.getoutputstream ();
JPEGImageEncoder encoder =jpegcodec.createjpegencoder (OutStream);
Encoder.encode (image);
Outstream.close ();
}
%>