1 25 26 package net.killingar.servlet; 27 28 import javax.servlet.ServletOutputStream ; 29 30 public final class Pixel extends javax.servlet.http.HttpServlet 31 { 32 public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException , javax.servlet.ServletException 33 { 34 response.setContentType("image/gif"); 35 36 ServletOutputStream out = response.getOutputStream(); 37 out.write("GIF89a".getBytes()); 38 39 byte 40 data1[] = new byte[]{0x01, 0x00, 0x01, 0x00, (byte)0x80, 0x00, 0x00}, 41 data2[] = new byte[]{(byte)0xFF, (byte)0xFF, (byte)0xFF, 0x21, (byte)0xF9, 0x04, 0x01, 0x00, 0x00, 0x01, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x44, 0x01, 0x00, 0x3B}, 42 color[] = new byte[3]; 43 44 out.write(data1); 45 46 String s = request.getQueryString(); 48 color[0] = (byte)Integer.parseInt(s.substring(0, 2), 16); 49 color[1] = (byte)Integer.parseInt(s.substring(2, 4), 16); 50 color[2] = (byte)Integer.parseInt(s.substring(4, 6), 16); 51 out.write(color); 52 53 out.write(data2); 54 } 55 } | Popular Tags |