dfischer.femtowebserver.test
Class BinaryTestWeblet

java.lang.Object
  |
  +--dfischer.femtowebserver.test.BinaryTestWeblet
All Implemented Interfaces:
HttpdWebletInterface

public class BinaryTestWeblet
extends java.lang.Object
implements HttpdWebletInterface

This Weblet example displays a small red gif image with the blue text "TEST".

 Sourcecode

 package dfischer.femtowebserver.test;
 import dfischer.femtowebserver.httpd.*;

 public class BinaryTestWeblet implements HttpdWebletInterface 
 {
    // gif image data
    private int[] gifData = { 0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x26, 0x00, 0x11, 0x00, 0x91, 0x00, 0x00, 0xFF, 0xFF, 0xFF,	
                              0xF5, 0x09, 0x09, 0x32, 0x11, 0xDA, 0x00, 0x00, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x26, 0x00,
                              0x11, 0x00, 0x00, 0x02, 0x32, 0x8C, 0x8F, 0xA9, 0xCB, 0xED, 0x0F, 0xA3, 0x9C, 0xB4, 0xDA, 0xAB,
                              0x84, 0xD6, 0x66, 0x8B, 0xBE, 0x81, 0xE1, 0xF4, 0x1D, 0xA5, 0xD9, 0x21, 0x27, 0xA9, 0x66, 0x6E,
                              0xB5, 0x8E, 0x68, 0x0B, 0xD3, 0x6F, 0x5A, 0xCF, 0x73, 0x6C, 0xC5, 0xA3, 0x67, 0xC3, 0x08, 0x87,
                              0xC4, 0xA2, 0xF1, 0x88, 0x6C, 0x14, 0x00, 0x00, 0x3B };
						   
    public void execute(HttpRequest req, HttpResponse res, HttpdProperties httpdProperties) throws Exception
    {
        // convert gif image: int[] to byte[]
        byte[] content = new byte[gifData.length];		
        for (int x = 0; x < gifData.length; x++)
            content[x] = (byte) (gifData[x]);

        // display image
        res.setContent(content);
        res.setContentType("IMAGE/GIF");
    }
 }
 


Constructor Summary
BinaryTestWeblet()
           
 
Method Summary
 void execute(HttpRequest req, HttpResponse res, HttpdProperties httpdProperties)
          Executes the Weblet.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryTestWeblet

public BinaryTestWeblet()
Method Detail

execute

public void execute(HttpRequest req,
                    HttpResponse res,
                    HttpdProperties httpdProperties)
             throws java.lang.Exception
Executes the Weblet.
Specified by:
execute in interface HttpdWebletInterface
Parameters:
req - HTTP request data
res - HTTP response data of the Weblet
httpdProperties - properties of the Femto Web Server