introduction | use cases
about
taakServlet
taakScript
raves
 
 
 

Introduction

The taakServlet controls execution of the taak framework. The taakServlet is configured through an XML configuration file. An example of a configuration file looks like this:

<taak-config>
   <class-prefix>com.nevik.client.view</class-prefix>
   <preload>true</preload>
   <reparse>true</reparse>
   <mapping path="/login_action.htm" script="login_action.taak" />
   <mapping path="/sign_out.htm" doc="logout.htm" script="logout.taak" />
   <mapping path="/hello.htm" class="HelloView" />
</taak-config>

The class-prefix element specifies the Java package of custom view classes specified elsewhere as the class attribute of the mapping element.

The preload element specifies whether the documents specified in the doc attribute of the mapping elements will be loaded on startup. Valid values for this element are true and false. The default for this element is true.

The reparse element specifies whether the XHTML documents specified in the doc attribute of the mapping elements will be reloaded and parsed automatically when a new version is replace an older one. Valid values for this element are true and false. The default for this element is true.

The mapping element has the attributes:

Attribute Description Required
path The virtual path of the URL. yes
class The Java class to handle this path. If unspecified the default handler internal to the taakServlet is used. no
doc The relative path of the actual xhtml document to be served for the virtual path. If unspecified, a document with the same name as the virtual path is assumed. no
script The name of the taakScript to transform the document before it is sent to the browser. If unspecified, the script can also be included as the content of the mapping element. no

When the taakServlet receives an HTTP request, it looks up the taak-config.xml file to find a match between the URL Request and the path attribute by examining each mapping element. The document specified in the doc attribute is optional. If the document exists, the document is retrieved and parsed into a JDOM object. Next, the taakServlet examines the remaining attribute in the mapping element to determine the executable element (also called a handler) for the request. The handler can be either a Taak script, or a Java class, or neither. A taakScript can be specified in an external file by using the script attribute. A Java class is specified using the class attribute. A use of Taak and Java classes as handlers is mutually exclusive. Only one or the other should be specified. If neither a Java handler nor a Taak script is specified, the document is sent to the user after any optional URL rewriting in done.

If a handler is specified, an execution context is set up and the handler is executed. The context provides to the handler input from the user through the ServletRequest, and the optional XHTML document as a JDOM object. The handler is responsible for retrieving additional data to complete its processing.

The handler may complete processing in one of the following ways:

  • Throwing an exception.
  • Redirecting to another page.
  • Forwarding to another page.
  • Writing XHTML to the servlet output stream.
  • Modifying a JDOM object. In this case, the servlet will complete processing by doing URL rewriting and outputting the JDOM object as XHTML to the user.