Embedthis Appweb 3.4.0
Home > Users Guide > Configuration Directives > Ejscript Directives

Quick Nav

See Also

Ejscript Directives

The Ejscript directives control the Ejscript Web Framework and configure Ejscript web applications.

EjsApp

Description Enable the Ejscript Web Framework
Synopsis EjsApp [on | off]
Context Default server, Virtual host, Location
Example <Location /myapp/>
    EjsApp on
    SetHandler ejs
</Location>
Alias /myApp /var/www/myAppDir
Notes

The EjsApp directive enables the Ejscript Web Framework to service requests in the enclosing block. This directive is used inside a Location or VirtualHost block which defines the ejs handler to process requests.

However, It is insufficient to only use the EjsApp directive to create an EjsApplication. You typically need to also use SetHandler and Alias directives to fully define an Ejscript application. It is usually best to use the EjsAppAlias directive or the EjsAppDirAlias directives to define applications.

EjsAppAlias

Description Define an Ejscript web application
Synopsis EjsAppAlias UrlPrefix Directory
Context Default server, Virtual host, Location
Example EjsAppAlias /myapp/  /var/www/myapp/
Notes

The EjsAppAlias directive defines an Ejscript application at the given directory which will receive all requests with specified URL prefix. This one-line directive is typically all you need to do to define an Ejscript application.

It is convenient to define applications using this directive in a separate configuration file for each application. If the application config file is stored under the Appweb "conf/apps" directory, then Appweb will read it automatically when it starts. This makes it very easy to install or remove applications by simply adding or removing an application configuration file to or from this directory.

The EjsAppAlias directive does the following actions:

  • Creates a new Location block for the URL prefix
  • Creates a new directory block if required for the directory
  • Creates an alias for the URL prefix to the directory
  • Defines the ejs handler as the handler for the URL prefix

If you have many Ejscript applications you can also use the EjsAppDirAlias directives to define a directory of applications.

EjsAppDir

Description Enable a block for Ejscript applications
Synopsis EjsAppDir [on | off]
Context Default server, Virtual host, Location
Example <Location /myapp/>
    EjsAppDir on
    SetHandler ejs
</Location>
Alias /apps /var/www/applications
Notes

The EjsAppDir directive enables the Ejscript Web Framework to service requests for Ejscript applications in the enclosing block. This directive is used inside a Location block which defines the ejs handler to process requests.

When requests are serviced, the first URL segement after the Location block prefix is used as the application name. Applications reside in named directories under the aliased directory for the Location block.

See the EjsAppAlias directive to define a single application.

EjsAppDirAlias

Description Define a directory of Ejscript applications
Synopsis EjsAppDirAlias UrlPrefix Directory
Context Default server, Virtual host, Location
Example EjsAppDirAlias /apps /var/www/applications
Notes

The EjsAppDirAlias defines a directory of Ejscript applications at the given directory which will receive requests with the specified URL prefix.

When requests are serviced, the first URL segement after the URL prefix is used as the application name.

The directive does the following actions:

  • Creates a new Location block for the URL prefix
  • Creates a new directory block if required for the directory
  • Creates an alias for the URL prefix to the directory
  • Defines the ejs handler as the handler for the URL prefix

Applications reside in named directories under the given directory name.

See the EjsAppAlias directive to define a single application.

EjsErrors

Description Control Ejscript error handling
Synopsis EjsErrors [browser | log]
Context Default server, Virtual host, Location
Example EjsErrors browser
Notes

The EjsError directive controls how errors are processed by the Ejscript Web Framework. Errors can be logged into the web server log or they can be sent back to the client for display in a browser.

Production installations typically send errors to the log, whereas development sites often send errors for display in a developer's browser.

EjsSession

Description Control if Ejscript automatically creates session objects
Synopsis EjsSession [on | off]
Context Default server, Virtual host, Location
Example EjsSession on
Notes

This directive enables session state to be automatically created for requests. When enabled, Ejscript will create a session state object and a cookie to send to the client. The cookie contains the session ID. When requests quote this session ID, the appropraite session state storage object will be made available to the request.

If this directive is disabled, the application can still use session state storage, but it will need to explicitly create the session state object via the Controller.createSession API.

EjsSessionTimeout

Description Define the default session timeout value
Synopsis EjsSessionTimeout seconds
Context Default server, Virtual host, Location
Example EjsSessionTimeout 1800
Notes

This directive defines the inactivity timeout in seconds for session state objects. If no requests are received during this timeout period, the session state storage will be discarded.

© Embedthis Software LLC, 2003-2012. All rights reserved. Embedthis, Ejscript and Appweb are trademarks of Embedthis Software LLC.