Show TOC

Resource HandlingLocate this document in the navigation structure

The handling of resources in SAPUI5 is divided in a client-side and a server-side part. The two parts are complementary and do not depend on each other.

The server-side resource handling is an optional component to improve the client-server interaction. The server-side resource handling is mainly used in Eclipse to support the modularized development of SAPUI5 applications and libraries.

Client-side Resource Handling

SAPUI5 provides the following mechanism for handling resources on the client:

In both cases, SAPUI5 loads additional resources from a server. This server can be any kind of web server (simple, Java, ABAP, ...). Both do not depend on a specific server-side technology.

Server-side Resource Handling

For the Java server and the integration into Eclipse, SAPUI5 provides a resource handler to improve the interaction between client and server, for example by providing a server-side locale fallback for the language to avoid multiple requests to get the correct language. It is also used to support modularized development of SAPUI5 applications and libraries. The Java resource handler is aligned with the concept of the JavaServer Faces.

  • The default implementation must support packaging resources in the web application root under the path resources/<resourceIdentifier> relative to the web app root.

  • Resources packaged in the classpath must reside under the JAR entry name META-INF/resources/<resourceIdentifier>

The SAPUI5 resource handler extends this concept to support standard and test-relevant resources. The resources are therefore packaged into the following paths:

  • resources/**

    Resources are all kind of JavaScript, CSS, Mimes, Resource Bundles, which are relevant for the runtime.

  • test-resources/**

    Test resources are resources which are samples and only relevant for testing purposes e.g. the content of the SAPUI5 test suite.

The resource handler in SAPUI5 provides the following additional features:

  • Theme fallback:

    If resources are not available for a theme, the resource handler automatically checks the base theme for such resources and returns them instead of a 404 error message.

  • Resource bundle fallback:

    This fallback is similar to the client-side mechanism for loading resource bundles, but it negotiates the request on the server and returns the best found resource bundle instead of issueing a 404 error, for example: > >

Resource Servlet

For Java Servlet containers, SAPUI5 provides a ResourceServlet to manage the access to SAPUI5 resources within the web application and the various UI libraries in the classpath. The following snippet shows how to enable the resource servlet for SAPUI5:


  <!-- ============================================================ -->
  <!-- SAPUI5 resource servlet used to handle application resources -->
  <!-- ============================================================ -->














Before you use it, make sure that the ResourceServlet is available in the classpath as JAR file.


The resource handler is configured via context parameters which are defined in the web.xml. The following table gives an overview about configuration parameters:

Key Description Flag for resource cache enabling; default: true Specifies the maximum age of resources in millis; default: 604800000 = 1 week List of accepted origins, for example *, *mycompany.corp, or server.mycompany.corp; default: empty Flag development mode enabling; default: false Specifies path to template for resource listing; default: /templates/listing.html Specifies verbosity of the resource handler; default: false Specifies the location that is used to proxy requests to resources that are not available locally; default: empty Flag to resolve the resource from the remote location before fallback to classpath; default: false Flag to enable caching of any resources in resource servlet; default: true (default in dev mode: false

Configuration parameters are added as context parameters to the web.xml.

Development Mode

When starting to develop SAPUI5 controls and modules being located inside the servlet paths resources/ or test-resources/ it makes the development process easier to disable the caching of such resources as well as to enable the resource browsing. To activate the development mode, add the following context parameter:


  <!-- BEGIN: DEV MODE -->
  <!-- END: DEV MODE -->
Resource Browsing

If the development mode is active, you can browse resources via the resource browser:

  • %SERVER_URL%!/resources/
  • %SERVER_URL%/test-resources/
Tunneling a Remote Location

You can use the ResourceServlet to tunnel/proxy requests to another server that provides SAPUI5 resources instead of referring to SAPUI5 from a remote location inside the bootstrap script tag and thus avoid cross domain issues. To activate the remote location tunneling/proxying, add the following context parameter to the web.xml of your application:


This dispatches the requests from resources/sap/ui/commons/Button.js to http://%server%:%port%/sapui5/resources/sap/ui/commons/Button.js.

If you are located behind a proxy and the remote location is outside your local network you can configure the proxy settings via the standard Java Networking and Proxy configurations by setting the system properties (for HTTP): http.proxyHost, http.proxyPort, http.nonProxyHosts, or (for HTTPS) https.proxyHost, https.proxyPort, https.nonProxyHosts of your Java runtime environment.

In general for the resources returned from the proxy the ResourceServlet is enabling caching. By default, it uses the configured to avoid too much load on the ResourceServlet.

Verify that a Resource was Retrieved from Remote Location

When in development mode it is possible to verify that a resource was retrieved from the desired remote location by checking the response header of the respective request. In this case the response header has an entry x-sap-ResourceUrl = remote resource URL, for example:

x-sap-ResourceUrl = http://%server%:%port%/sap/public/bc/ui5_ui5/resources/sap-ui-core.js
Resource Packaging

Resource packaging for web applications and Java modules can be any kind of JAR file, for example SAPUI5 UI library that is available in the classpath of the web application.

Store the resources as follows:

  • Web application:

  • SAPUI5 UI libraries:


    For custom JAR files you need to apply to this on your own.

OSGi Servlet Container

When you run SAPUI5 as an OSGi web bundle and reference the UI libraries as OSGi bundles, you need to determine the SAPUI5 OSGi bundles:

  • Extend the ResourceServlet in the OSGi servlet container by using an OSGi fragment that is responsible to add the OSGi flavor for the determination of UI libaries. Now the ResourceServlet is aware of the OSGi bundles and can search within the OSGi servlet container for UI libraries.

  • The OSGiResourceServlet uses the following entry in the MANIFEST.MF of the UI library's JAR files to determin the relevant UI libraries:

    x-sap-ui5-ContentTypes: UILibrary