IBM Books

Administration and Programming Guide for OS/400

Java Application Language Environment Example

In this example, the Net.Data macro calls a Java program, echoString. The macro passes two string parameters to the Java language environment. The first string tells the Java program whether to use italic or bold highlighting for the second parameter, a text string, before printing the second parameter to standard output (stdout). Because the program passes "I", for italics, the Web server displays the text string Hello World, in italics, at the browser. The source for the Java program follows the macro.

Macro:

%FUNCTION(DTW_JAVAPPS) echoString(textAttribute, text){ %}                                          
                                             
 %HTML(runjava){                              
 @echoString("I","Hello World")                                                       
 %}                                          

Java program:

class echoString {
   public static void main (String args[]) {
      if (args[0].equals("I"))
        System.out.println("<I>" + args[1] + "</I>");
      else
        System.out.println("<B>" + args[1] + "</B>");
   }
 }


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]