JavaScript – how to trim leading or trailing spaces of a string

There are tons of publications on the subject in Internetm but let me put my “50-cents” on this.
The problem is that in javascript there is no built-in function to trim leading and trailing spaces on a string.
This can be easily implemented by adding required method to the javascript’s String object:

String.prototype.trim = function(str) { return str.replace(/^\s+|\s+$/g, ""); }

How to install Myna Application Server

Myna – is a server-side javascript. More details can be found here.
Installation is possible in two ways:
1. as a regular servlet on any Java server (Tomcat, JBoss, Glassfish, WebSphere, etc)
2. as a standalone application (in this case, Tomcat is already included).
At the time of this writing, the latest released version was myna-1.0_beta_9. Do not be afraid suffix beta – , the authors state that the application is very stable and successfuly works on many servers in a production mode.

For myself, I chose to install Myna as a standalone application. To do this, downloaded an archive myna-1.0_beta_9.war
Installation as simple as follows:

java-jar / path/to/myna-1.0_beta_9.war-m install

, followed by the number of additional parameters. To know more about possible option, run

java-jar / path/to/myna-1.0_beta_9.war - help

But! When you run this command under your regular unix user (if you’re not root) you will receive these messages:

Installing / upgrading Myna in '/ var / www / myna' ...
Done unpacking.
Install mode must be run as root.

I do not know why, but it did not help even when I’ve added sudo to the beginning of the team.I have not achieved success…
The secret was found and it revels the you must run the installation comand as a real root user.
And, yes, besides that, I have the full path to a war-file of the Myna. Next, the installation finished without any problem.
Apparently, the thing is that the installer is trying to register a startup script for the Myna in the /etc/init.d/

After installation, the server will start automatically and you can see the result at
http://localhost:8180/ (8180 – myna port by default).

Once you are finished and the server up and runnning, go further to dig into manuals how to write server side application with help of Myna and pure JavaScript.
Good luck to you!