Skip to content

Stewart Speaks SEO

  • About Me
  • Contact Us
August 10, 2021 / Coding

Application: JFast

JFast is a replacement library for the Java portion of the FastCGI DevKit. The DevKit does not support multi-threaded FastCGI Java applications, but JFast does. JFast is also a much cleaner collection of code, and is therefor a great deal easier to develop further.

JFast is not a full-featured library. It supports only the basic Responder role, and it does not support multiplexed connection (does any web server, either?). If there is a feature in the FastCGI specification that JFast does not support, that you need, let me know.

Documentation

Javadoc to come.

JFast is very straightforward. After creating a singleJFast object, you can call the acceptRequestmethod to access data (a JFastRequest object) connected the request. The JFastRequest object can be passed to a separate thread for processing, and your primary thread can continue to accept new connections.

The JFast constructor can be passed a single intparameter, which represents the port number that a Web Server such as lighttpd can use to communicate with the application. If this parameter is left out, the FCGI_PORT variable must be set in the program’s environment.

The following fields/methods of JFastRequest are of interest:

  • JFastRequest.out: a PrintStream that allows you to send character data to the client.
  • JFastRequest.error: a PrintStream that allows you to send character data to the webserver as logging information.
  • JFastRequest.properties: a Propertiesobject, containing standard CGI key/value pairs.
  • JFastRequest.data: any available POST data that’s associated with the current request.

Example

The following example is a complete (if slightly useless) FastCGI program.


import org.bumblescript.jfast.*;

public class JFTest
{
    public static void main(String args[])

        throws Exception
    {
        JFast jfast = new JFast();
        JFastRequest request;

        
        while((request = jfast.acceptRequest()) != null)
        {

            request.out.print("Content-type: text/html\n\n");
            request.out.print(

                "<html>" +
                "<head><title>JFast Example</title></head>" +

                "<body>" +
                    "<h1>Hello, FastCGI!</h1>" +
                    "<h2>Environment</h2>" +

                    "<pre>"
            );                    
            request.properties.list(request.out);

            request.out.print(
                    "</pre>" +
                    "<h2>Post Data</h2>" +

                    "<pre>" + (new String(request.data)) + "</pre>" +

                "</body>" +
            "</html>"
            );            
            request.end();          
        }

    }
}

Post navigation

Previous Post:

Application: Dynamic Text Replacement

Next Post:

Application: Bcomplete

Recent Posts

  • Business: How to Start Your Own Chat Line Operator
  • Application: Bcomplete
  • Application: JFast
  • Application: Dynamic Text Replacement

Categories

  • Business
  • Coding

My Daily Resources

PHP How to SEO Miami Company Handy Javascript Manual

About Me

I’m an experienced web developer living in Boston, MA with my wife, Lauren, and our two cats, Dory and Pekoe. I spend my spare time fiddling with random computer projects, and reading about ethical philosophy and cognitive science.

© 2023 Stewart Speaks SEO - Powered by SimplyNews