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 ();
// Fill in the background color below
G. setColor (Color. lightGray );
G. fillRect (0, 0, width, height );
String random = "random ";
// Set the foreground color below
G. setColor (Color. BLACK );
G. drawString ("Http: // www.knowsky.com", 10, 20 );
G. drawString ("Author: Lion [lion-a@sohu.com );
G. drawLine );
G. drawString (ImageStr, 10, 70 );
G. dispose ();
ServletOutputStream outStream = response. getOutputStream ();
Required imageencoder encoder = required codec. createJPEGEncoder (outStream );
Encoder. encode (image );
OutStream. close ();
}
%>