Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!

RAD Server Support for Web Files in RAD Studio 10.2.3

The RAD Server (formerly EMS) platform is evolving to be a better backend for JavaScript applications, including of course those built with Ext JS. In the 10.2.2 release we improved support for returning JSON data based on the result of database queries, as covered in http://blog.marcocantu.com/blog/2017-december-dataset-mapping-json.html.

In RAD Studio 10.2.3, we have added to RAD Server the ability to act as a Web Server, with the support for mapping URLs to folders and returning the content of files like HTML, JS, CSS, graphic, and more. This is a handy feature when using the local development and debugging version, so you don’t need to configure both the web service and a separate web server for development, testing and debugging. We do not recommend using this approach for deployment: in that case RAD Server is deployed as a Web Server (Apache or IIS) plugin and the Web Server would of course support file mapping.

How do you configure RAD Server to return files? There is a new section in the EMS.INI file (notice this is a global configuration, not per module) when you can add virtual folders:

[Server.PublicPaths] ;# Identify directories that contain public files, such as .html ;# ;# The following entries define two different virtual directories (“images” and “content”) ;# that may be used to access static files. The “directory” value indicates the physical ;# location of the static files. The optional “default” value indicates a file ;# that will be dispatched by default when browsing to the root of the virtual directory. ;# The optional “mimes” value is an array of MIME file type masks. And optional “extensions” ;# value is an array of file extensions. Only these files will be accessible from this directory. Path1={“path”: “images”, “directory”: “C:||web||images||”, “default”: “index.html”, “mimes”: [“image/*”]} Path2={“path”: “content”, “directory”: “C:||web||content||”, “default”: “index.html”, “extensions”: [“js”, “html”, “css”]}

In this case I have two folders, one with images and one with HTML content, and also a default file with the URL refers to the folder as a whole. So I can now create a JavaScript application invoking a server method. To keep things simple, I’ve used a minimal jQuery application:

$(document).ready(function(){ $(“button”).click(function(){ $.ajax({url: “/xyz”, success: function(result){ $(“#div1”).html(result); }}); }); });

RAD Server JS + Service

Get RAD Server Content


When clicking on the button, the JS app will call the /xyz resource of the RAD Server project and display the result. This is the application in action in a browser (with the RAD Server log below):

Of course, our focus is to help build applications that use Ext JS as the client and RAD Server as the server. I’ll make sure to follow uo with such a demo soon.

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

Marco is one of the RAD Studio Product Managers, focused on Delphi. He's the best selling author of over 20 books on Delphi.
Related posts

Easily Deploy RAD Server With Windows And Linux Installers


iEditor: A Fun Web Document Editor Is Delphi Powered

DelphiRAD Studio

Powerful Enterprise-Grade Medical Office Industry Template Source Code For Your Business

DatabaseDelphiInterBaseRAD Studio

Free Source Code: RAD Server Field Services Industry REST API Template Solution For Your Business

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.