Writing Your Own Servlets

This document discusses some details regarding how to write your own servlets.

The process of writing your own servlets for the Tynamo™ server does not change: you can retrieve an OutputStream or Writer and output data just as you have done before; cookies and session data can be stored; requests can be forwarded to, or included in, another servlet. In other words, write your servlets as normal. All servlet features are available to you.

Configuration is done via the servlet properties file.

You must be aware of a few features and restrictions, however. The restrictions are found here, and the extras are as follows:

  1. The com.qindesign.http.serverProps context attribute stores a Hashtable object from which you can access all of the webserver properties. They are read-only. For example, you can determine what the request timeout is, which port the server is listening to, and the minimum time between each GC.
  2. The com.qindesign.http.startTime context attribute stores a Long object indicating the time in milliseconds the server was started.
  3. This server supports the "Basic" authentication scheme of RFC 2617. In order to use this facility, extend com.qindesign.servlet.AuthenticatedHttpServlet instead of the usual javax.servlet.http.HttpServlet.

    Successfully authenticated requests are passed to the doGet and doPost methods, and unauthorized requests are sent to similarly-named doUnauthorizedGet and doUnauthorizedPost methods. Note that only the "GET" and "POST" methods are supported. If there is a need for others, please let us know.

    An example demonstrating how to use this feature can be found in the example servlets.