import javax.servlet.*; import javax.servlet.http.*; import com.sun.image.codec.jpeg.*; import java.awt.image.*; import java.awt.*; import java.io.*; public class piltservlet3 extends HttpServlet{ public void doGet(HttpServletRequest kysimus, HttpServletResponse vastus) throws IOException, ServletException{ String pildikataloog="c:\\jdk1.3\\tomcat\\pildid\\"; BufferedImage pilt =new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB); Graphics2D piltg=pilt.createGraphics(); Image numbripilt=Toolkit.getDefaultToolkit().getImage(pildikataloog+"nr1.gif"); MediaTracker md=new MediaTracker(new Canvas()); md.addImage(numbripilt, 0); try{ md.waitForAll(); }catch(InterruptedException e){ piltg.drawString("Viga pildi laadimisel", 10, 40); } piltg.drawImage(numbripilt, 30, 30, 40, 40, null); vastus.setContentType("image/jpeg"); JPEGCodec.createJPEGEncoder(vastus.getOutputStream()).encode(pilt); } }