Tutorials

Hello World

This is the most basic version of a tutorial. It will guide you to writing your own 'Hello World'-application.

If you haven't setup Helma yet, then go ahead and download a recent Helma package from http://helma.org/download/, unzip it anywhere on your disk and start Helma by double-clicking on the hop.bat, resp. hop.sh residing in the unzipped directory (to which we will refer as [HelmaHome] from now on).

Now, open the file [HelmaHome]/apps.properties with your favourite text editor, and add the following line:

helloworld

As soon as you save your changes to disk, Helma will automatically detect these changes, will create a directory named [HelmaHome]/apps/helloworld (with several subdirectories) and will activate this application.

Now change to the directory [HelmaHome]/apps/helloworld/Root and save the following JavaScript-code as a new text-file named 'functions.js' (again with your preferred editor).

function main_action() { 
  res.write("Hello World!"); 
}

And that's already it. We just created a new web accessible function named 'main' for the Root object. So, go ahead, open up http://localhost:8080/helloworld/main with your web browser of choice, and you will see the "Hello World" message being displayed to you.

Some explanations:

  • The Root object is always there in Helma, so we didn't had to create it explicitly.

  • By having our defined function end with '_action' we told Helma, that this particular function should be callable for browsers.

  • The single line of code in that function simply appends the string "Hello World" to the response.