import java
import java
import com
import javax
import javax
import java
import java
public class JPEGServlet extends HttpServlet {
private String strFile="c:count
private Font mFont=new Font("Courier"
public void doGet(HttpServletRequest request
throws ServletException
String s;
int intCount;
s=getCount();
intCount=new Integer(s)
intCount=intCount+
writeCount(intCount+"");
response
ServletOutputStream out=response
BufferedImage image=new BufferedImage(
Graphics g=image
g
g
g
g
char c;
for(int i=
c=s
g
g
}
JPEGImageEncoder encoder=JPEGCodec
encoder
out
}
public void doPost(HttpServletRequest request
throws ServletException
doGet(request
}
public synchronized void writeCount(String content) {
try {
PrintWriter pw = new PrintWriter(new FileOutputStream(strFile));
pw
pw
} catch(IOException e) {
System
}
}
public synchronized String getCount() {
String strCount;
int len;
int leftLen;
try {
BufferedReader inf = new BufferedReader(new FileReader(strFile));
strCount=inf
inf
} catch(Exception e) {
System
return reChar(
}
len=strCount
if (len<=
return reChar(
}
if (len>
return reChar(
}
leftLen=
return reChar(
}
private String reChar(char c
int i;
if (num<=
String s="";
for(i=
s=s+c;
}
return s;
}
}
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20276.html