dfischer.femtowebserver.httpd
Interface HttpdWebletInterface

All Known Implementing Classes:
BasicAuthGenericTestWeblet, BinaryTestWeblet, DivisionByNullTestWeblet, InputFormTestWeblet, RedirectTestWeblet, TestWeblet

public interface HttpdWebletInterface

Weblets - direct from web browser executable java classes - must implement this interface.

Weblets are special java classes, which can be called direct from the browser. In opposite to a static HTML page, you will be able to generate a dynamic HTML result (based on the browser request with CGI parameters). Weblets are similar to Java Servlets, but easier to program ...

Programming Example

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

 public class MyTestWeblet implements HttpdWebletInterface 
 {	
    public void execute(HttpRequest req, HttpResponse res, HttpdProperties httpdProperties) throws Exception
    {
        res.println("<HTML>");
        res.println("<BODY>");
        res.println("The current time in milliseconds is " + System.currentTimeMillis());
        res.println("</BODY>");
        res.println("</HTML>");		
    }
 }
 
Call this example from the web browser, if the Femto Web Server has started on Port 83:
http://127.0.0.1:83/mypackage/MyTestWeblet   (executes the Weblet mypackage.TestWeblet)
 
Take into consideration that the URL mapping of the Femto Web Server corresponds direct with the directory structure of your package: but replace the directory dots "." with "/" on the browser URL.

Built-in Security: before execution of a class, the Femto Web Server will check if the class implements the HttpdWebletInterface. This will be done before an instance of the class has been created (to avoid security problems by executing the constructor). If the HttpdWebletInterface is not implemented, the browser request will be aborted and the web server response is "403 Forbidden".

Hint 1: make sure that the Weblet is part of the CLASSPATH during execution of the Femto Web Server.
Hint 2: an other way to create dynamic content is also the usage of Simple Server Side Includes (SSSI).

See Also:
Httpd, HttpRequest, HttpResponse, HttpdProperties, HttpdSssiInterface

Method Summary
 void execute(HttpRequest httpRequest, HttpResponse httpResponse, HttpdProperties httpdProperties)
          Executes the Weblet.
 

Method Detail

execute

public void execute(HttpRequest httpRequest,
                    HttpResponse httpResponse,
                    HttpdProperties httpdProperties)
             throws java.lang.Exception
Executes the Weblet.
Parameters:
httpRequest - access to the HTTP request data (browser request)
httpResponse - Weblet HTTP response data (server response)
httpdProperties - read/only access to the Femto Web Server configuration