import javax.servlet.*; import javax.servlet.http.*; import com.sun.image.codec.jpeg.*; //kuulub SUNi JDK-sse import java.awt.image.*; import java.awt.*; import java.io.*; public class piltservlet2 extends HttpServlet{ public void doGet(HttpServletRequest kysimus, HttpServletResponse vastus) throws IOException, ServletException{ int suurus=(int)(20+Math.random()*60); BufferedImage pilt =new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB); Graphics2D piltg=pilt.createGraphics(); piltg.setColor(Color.red); piltg.fillOval(50-suurus/2, 50-suurus/2, suurus, suurus); vastus.setContentType("image/jpeg"); JPEGCodec.createJPEGEncoder(vastus.getOutputStream()).encode(pilt); } }