BufferedImage image = new BufferedImage(80,30,BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
g.setColor(new Color(255,255,255));
g.fillRect(0,0,80,30);
Random r = new Random();
g.getColor(new Color(r.nextInt(255),r.nextInt(255),r.nextInt(255));
g.setFont(new Font(null,Font.ITALIC,24));
String number = r.nextInt(10000)+"";
g.drawString(number,5,26);
for(int i=0;i<6;i++) {
g.drawLine(r.nextInt(80),r.nextInt(30),r.nextInt(80),r.nextInt(30));
}
response.setContextType("image/jpeg");
OutputString ops = response.getOutputStream();
javax.imageio.imageIO.write(image,"jpeg",ops);
ops.close();