| 1 | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
| 2 | * |
| 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
| 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 | |
| 7 | /** |
| 8 | * liveConnect.js: a simple demonstration of JavaScript-to-Java connectivity |
| 9 | */ |
| 10 | |
| 11 | // Create a new StringBuffer. Note that the class name must be fully qualified |
| 12 | // by its package. Packages other than "java" must start with "Packages", i.e., |
| 13 | // "Packages.javax.servlet...". |
| 14 | var sb = new java.lang.StringBuffer(); |
| 15 | |
| 16 | // Now add some stuff to the buffer. |
| 17 | sb.append("hi, mom"); |
| 18 | sb.append(3); // this will add "3.0" to the buffer since all JS numbers |
| 19 | // are doubles by default |
| 20 | sb.append(true); |
| 21 | |
| 22 | // Now print it out. (The toString() method of sb is automatically called |
| 23 | // to convert the buffer to a string.) |
| 24 | // Should print "hi, mom3.0true". |
| 25 | print(sb); |