introduction | use cases
about
taakServlet
taakScript
raves
 
 
 

Introduction

Case 1: No Document and taakScript

When the taakServlet receives an HTTP request, it looks up the XHTML document; in this case it does not exist. Next the servlet examines the source for business logic and in this case a taakScript is defined. The Java class will perform business logic and return a view back to the user. This requirement can be fulfilled in a variety of ways ranging from:

An example of a taak-config.xml file is shown below:

<taak-config>
   <class-prefix>com.nevik.client.view</class-prefix>
   <mapping path="/hello.htm" class="HelloView.taak" />
</taak-config>

Case 2: Document and taakScript

When the taakServlet receives an HTTP request, it looks up the XHTML document and the document is parsed into a JDOM object. The Taak script is instantiated and provided the TaakContext made up with the JDOM object, servlet request, and servlet response. The script is parsed and executed in the context. When executed, the script populates the document with data from the middle tier. Once populated, the document is outputted as XHTML and any URL rewriting is performed.

An example of a taak-config.xml file is shown below:

<taak-config>
   <class-prefix>com.nevik.client.view</class-prefix>
   <mapping path="/hello.htm" script="HelloView.taak" />
</taak-config>

Case 3: Document and Java Class

When the taakServlet receives an HTTP request, it looks up the XHTML document and the document is parsed into a JDOM object. The Java Class is instantiated and provided the taakContext made up with the JDOM object, servlet request, and servlet response. The script is parsed and executed in the context. When executed, the class populates the document with data from the middle tier. Once populated the document is outputted as XHTML and any URL rewriting is performed.

An example of a taak-config.xml file is shown below:

<taak-config>
   <class-prefix>com.nevik.client.view</class-prefix>
   <mapping path="/hello.htm" class="HelloView.taak" />
</taak-config>

Case 4: Document and No business logic

When the taakServlet receives an HTTP request, it looks up the XHTML document and the document is parsed into a JDOM object. Since no taakScript or Java class exist, nothing further is happens except JDOM object is returned to XHTML and any URL rewriting is performed.

An example of a taak-config.xml file is shown below:

<taak-config>
   <class-prefix>com.nevik.client.view</class-prefix>
   <mapping path="/FAQ.htm" />
</taak-config>

If a taakScript is specified, the taakServlet sets up the taakContext for the script. The taakContext includes the ServletRequest defined as the variable SERVLET_REQUEST, the ServletResponse defined as the variable SERVLET_RESPONSE, the JDOM object defined as the variable DOCUMENT. The script is then executed in the defined context. When the script is finished executing, its exit condition is examined. The exit condition tells the Servlet whether the script has an error, or the script is forwarding the request to another URL, or the script is redirecting the request to another URL, or the script completes successfully. In the last case, the JDOM object that has been modified by the script is returned to the browser after any needed URL rewriting is done.

Case 5: No Document and Java

When the taakServlet receives an HTTP request, it looks up the XHTML document; in this case it does not exist. Next the servlet examines the source for a handler and in this case a Java class is defined. The Java class will perform business logic and returns a view back to the user. This requirement can be fulfilled in a variety of ways ranging from:

  1. Redirecting to another web site
  2. Redirecting to the taakServlet with a new Request URL
  3. Forwarding to another web site
  4. Forwarding to the taakServlet with a new Request URL
  5. Building a view and returning to back to the user

An example of a taak-config.xml file is shown below:

<taak-config>
   <class-prefix>com.nevik.client.view</class-prefix>
   <mapping path="/hello.htm" class="HelloView" />
</taak-config>