Imaging_ToWeb.jsp
<%@ halaman autoFlush="false" import="java.awt.*,java.awt.image.*,com.sun.image.codec.jpeg.*,java.util.*"%>
<%
String ImageStr = permintaan.getParameter("ID_Teks");
if(ImageStr==null || ImageStr.sama dengan(""))
{
respon.setContentType("teks/html; charset=gb2312");
%>
<HTML>
<KEPALA>
<title>Http://www.lionsky.net</title>
<meta http-equiv="Jenis Konten" content="teks/html; charset=gb2312">
</KEPALA>
<tubuh>
<form id="Form1" metode="posting">
<masukan tipe="teks" id="ID_Teks" nama=ID_Teks>
<tipe masukan=kirim nilai="GO">
</bentuk>
</tubuh>
</HTML>
<%
}
kalau tidak
{
keluar.hapus();
respon.setContentType("gambar/jpeg");
respon.addHeader("pragma","TANPA cache");
respon.addHeader("Kontrol-Cache","tanpa-cache");
respon.addDateHeader("Kedaluwarsa",0);
int lebar=300, tinggi=100;
Gambar BufferedImage = BufferedImage baru (lebar, tinggi, BufferedImage.TYPE_INT_RGB);
Grafik g = image.getGraphics();
//以下填充背景颜色
g.setColor(Warna.Abu-abu Muda);
g.fillRect(0, 0, lebar, tinggi);
String acak = "acak";
//以下设置前景色
g.setColor(Warna.HITAM);
g.drawString(" Http://www.downcodes.com",10,20 );
g.drawString("Penulis:Lion[[email protected]]",10,40);
g.drawLine(10,50,290,50);
g.drawString(ImageStr,10,70);
g.buang();
ServletOutputStream outStream = respon.getOutputStream();
Encoder JPEGImageEncoder =JPEGCodec.createJPEGEncoder(outStream);
encoder.encode(gambar);
outStream.close();
}
%>