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