Chapter 2. OpenLaszlo Request Types

Table of Contents

1. What are OpenLaszlo Request Types?
1.1. HTML Request Types
1.2. Embedding Request Types
1.3. Debugging Request Types
1.4. Implementation Request Types
2. Other Query Parameters
3. Administrative Requests
4. Preprocessed Requests

This document briefly describes OpenLaszlo request types. It assumes that you are generally familiar with HTTP, URLs, and the OpenLaszlo architecture described in ???.

1. What are OpenLaszlo Request Types?

In general, an URL that is used to request a proxied OpenLaszlo application is of the form:

http://myhost[:myport]/mywebapp/myapp.lzx?lzt=type

Everything before the ? character can typically be configured via settings in your Servlet Container and/or Web Server. The value of the lzt query parameter is interpreted by the OpenLaszlo Server as a request type. Here are the standard request types:

1.1. HTML Request Types

These request types return an HTML page that displays the application. The mime-type of the response is text/html.

lzt=html

This request causes the OpenLaszlo Server to respond with an HTML wrapper page for the Laszlo application. The HTML page presents the application. The title and background color of the application are set to the title and background color of the application (the values of its canvas title and bgcolor attributes, if present).

The page that this SWF returns uses JavaScript to include the OpenLaszlo application.

lzt=html-object

Same as lzt=html, except this page embeds the <object> and <embed> tags directly in the HTML page. This is the traditional technique for including applications that is used on most web sites, but it is incompatible with the announced changes to Internet Explorer.

lzt=window

Show the application in a popup window sized to the canvas.

1.2. Embedding Request Types

These request types are used to embed an application in an HTML page. Different requests are available depending on the request is included on the server (object-tag) or the client (everything else); whether the embedding technique is compatible with the announced changes to Internet Explorer (embed and js) or uses traditional embedding techniques (object-tag), and whether it creates <object> and <embed> tags (embed, js, and object-tag) or simply returns the swf file that contains the application (swf).

lzt=embed

Returns a JavaScript include file that is suitable for the target of an HTML <script> tag. The file embeds the application into the HTML page at the site of the <script> tag. This is appropriate for including an application in a way that is compatible with the announced changes to Internet Explorer.

Usage:

<script type="text/javascript" language="JavaScript"
        src="http://127.0.0.1:8080/lps-5.0.x/examples/hello.lzx?lzt=embed">
</script>
lzt=js

Same as lzt=embed, except the included file depends on the functions defined in the embed.js file.

Usage:

<html>
<head>
…
<script type="text/javascript" language="JavaScript"
        src="http://127.0.0.1:8080/lps-5.0.x/lps/includes/embed.js"/ >
</head>
<body>
…
<script type="text/javascript" language="JavaScript"
        src="http://127.0.0.1:8080/lps-5.0.x/examples/hello.lzx?lzt=js">
</script>
…
</body>
</html>
lzt=object-tag

Returns the HTML <object> and <embed> tags that embed the application into an HTML page. This is useful for server-side includes, when compatability with the announced changes to Internet Explorer is not necessary.

lzt=swf

Returns the SWF file that represents the application, without any HTML. This is used to embed an OpenLaszlo application in an HTML page. (Most of the other request types generate code that includes a URL with this request type.) The mime-type returned by this request is application/x-shockwave-flash.

1.3. Debugging Request Types

lzt=app_console

This request causes the OpenLaszlo Server to respond with an HTML wrapper page for the OpenLaszlo application. The HTML page presents the application. It also displays compilation warnings for the application, and links to development environment commands and developer resources. These commands are described here.

This is the default request. If no lzt query string variable is present, the value is assumed to be html.

The mime-type returned by this request is text/html.

lzt=source

Show the source in a <textarea> HTML element. The mime-type returned by this request is text/html.

lzt=xml

Show the source as plain XML (for XML-aware browsers). The mime-type returned by this request is text/xml.

1.4. Implementation Request Types

These request types are used in the implementation and testing of the OpenLaszlo Server. Their behavior and existence should not be relied on, and they may change in future releases.

  • lzt=canvas-xml

  • lzt=deployment

  • lzt=inline-examples

  • lzt=v1

  • lzt=serverinfo

lzt=serverinfo returns a list of server attributes, some of which can also be fetched by an expression like Debug.write(canvas.version).

2. Other Query Parameters

The debug=true query parameter can be used to include the debugger in an application.

The debuglog=true query parameter can be used to log debug messages to the server log.

The ?lzrecompile=true query parameter can be used to force the OpenLaszlo Server to recompile an application (.lzx only, not .lzo) even when the compilation manager's dependency option is set to never. (See Chapter 3, Deploying OpenLaszlo Applications for details on the compilation manager's dependency option). If the administrator password is set, you must also provide the password in pwd= query parameter for the recompile to take effect.

The ?pwd=passwd query string can be used to pass in the OpenLaszlo Server administrative password.

A running OpenLaszlo application can get access to any of the query strings that was given in the URL used to access it via the LzBrowser service's getInitArg() method. For example if the following URL:

      http://host:port/myapps/wooker.lzx?wookie=Chewie
    

were used to access the following app:

Example 2.1. Accessing query strings

      <canvas debug="true">
        <script>
          var wookieName = LzBrowser.getInitArg('wookie');
          Debug.write("The Wookie's Name: " + wookieName);
        </script>
      </canvas>
    

the debugger would display

      The Wookie's Name: Chewie
    

Note that query strings that conflict with the OpenLaszlo Runime Library's global namespace will be lost (for example, "canvas" or "bgcolor").

3. Administrative Requests

A password may be required for Administrative Requests. See Chapter 3, Deploying OpenLaszlo Applications for more details.

lzt=log

Show the current log file as text/html.

lzt=clearlog

Clears the current log file.

lzt=logconfig

Show OpenLaszlo Server log4j configuration as text/xml.

lzt=clearcache

Clear OpenLaszlo Server media, data, and compilation caches. Return a text/html status message.

lzt=serverinfo

Show OpenLaszlo Server configuration information as text/xml.

lzt=cacheinfo

Show OpenLaszlo Server media and data cache information as text/xml.

lzt=errorcount

Show the number of OpenLaszlo Server errors as text/xml.

lzt=errorcount&clear=1

Clear OpenLaszlo Server error count.

lzt=stat

Monitor server statistics.

lzt=gc

Run the garbage collector.

4. Preprocessed Requests

The OpenLaszlo Server also supports using dynamic, server-side back-end processors (e.g., PHP, JSP) to generate LZX application source code before the OpenLaszlo Server compiles and serves it. For URLs that end in .lzx for which the OpenLaszlo Server can not find a matching source file on disk, the Server removes the .lzx suffix and uses HTTP GET to retrieve the content of the modified URL. The returned content should be a valid LZX file. The OpenLaszlo Server compiles and serves an application based on the dynamically generated source code. For example see the hello.jsp file in the examples directory. This example generates a Laszlo application that contains information about the current time and session. You can see the generated LZX source at:

http://127.0.0.1:8080/lps-5.0.x/examples/hello.jsp.lzx?lzt=source

and the generated application at:

http://127.0.0.1:8080/lps-5.0.x/examples/hello.jsp.lzx

The use of dynamically generated LZX circumvents the OpenLaszlo Server compilation cache, and compiles an application for each request. This is not recommended for use in deployment. Dynamic behavior is best handled by a static application that requests data and resources from the server during its initialization.