Web Script Runtimes

Showing results for 
Search instead for 
Did you mean: 

Web Script Runtimes

0 0 2,614

Obsolete Pages{{Obsolete}}

The official documentation is at: http://docs.alfresco.com

Web Scripts
Back to RESTful API.


This document describes features to be found in Alfresco v2.1.  (Newer versions: v3)


Although web scripts are accessible via HTTP, their URL addressability means they can actually be hosted in a number of different environments (and therefore accessed via a protocol appropriate to the environment).

The web script architecture clearly separates the notion of a web script (that is, a unit of work) and its environment (that is, the host within which the unit of work is executed), which is known as a Web Script Runtime.

New runtimes may be plugged-in allowing web scripts to be re-used and re-hosted in a number of different applications.

Available Web Script Runtimes

Today, the following Web Script Runtimes are available:

Servlet Runtime (HTTP Access)

The Servlet Runtime maps HTTP requests to web scripts.

It's configured just as any other servlet in web.xml:


The following initialization parameters are supported:

authenticator : the web script Authenticator as specified by its unique id

Multiple web script servlets may be configured, allowing multiple url mappings where each mapping may use a different authenticator.


Pre-defined web script URL mappings

/alfresco/service or /alfresco/s : mapped to HTTP Basic Authenticator

/alfresco/wcservice or /alfresco/wcs : mapped to Web Client Authenticator

/alfresco/168service or /alfresco/168s : mapped to JSR-68 Authenticator

JSR-168 Runtime (Portlet Access)

The JSR-168 Runtime maps a portlet to a web script.

A JSR-168 proxy portlet class is provided which may be configured as follows:

  <description>A Portlet</description>
  <portlet-name>Portlet Name</portlet-name>

    <title>Portlet Title</title>
    <short-title>Portlet Short Title</short-title>

Note: For versions beyond 3.3 the WebScriptPortlet class has been moved to Spring. Instead use:


The following initialization parameters are supported:

authenticator (optional) : the web script Authenticator as specified by its unique id.  If not specified, the default JSR-168 authenticator (webscripts.authenticator.jsr168) is used.

scriptUrl : the url to the web script

JSF Runtime (JSF Component Access)

The JSF Runtime maps a JSF component to a web script.

It's configured as follows within a JSP:

<web script url>' />

The following parameters are available:

scriptUrl : the url of the web script

Authentication is handled by the Alfresco Web Client.

Developing a Web Script Runtime

A Web Script Runtime is implemented by deriving a Java class from:


This is an abstract class requiring the following methods to be implemented:

* Get the web script method  e.g. get, post
* @return  web script method
protected abstract String getScriptMethod();

* Get the web script Url
* @return  web script url
protected abstract String getScriptUrl();
* Create a web script request
* @param match  web script matching the script method and url
* @return  web script request
protected abstract WebScriptRequest createRequest(WebScriptMatch match);
* Create a web script response
* @return  web script response
protected abstract WebScriptResponse createResponse();
* Authenticate web script execution
* @param required  required level of authentication
* @param isGuest  is the request accessed as Guest
* @return true if authorised, false otherwise
protected abstract boolean authenticate(RequiredAuthentication required, boolean isGuest);

Implementations of:


are also required as they are instantiated by createRequest and createResponse respectively. The helper class:


provides a skeleton implementation of WebScriptRequest given a URL string.

Executing a web script

The following pattern is used to execute a web script via a Web Script Runtime:

WebScriptRuntime runtime = new CustomWebScriptRuntime(...);

Runtime context is passed in via the constructor, for example, for a servlet, the HttpServletRequest and HttpServletResponse.

A new Web Script Runtime must be instantiated for each invocation (where the context changes), for example, for each servlet request.

Future Runtimes

JSP Runtime : allow access via JSP - converts any web script into a JSP Tag