This parameter has two values separated with a delimiter of "|". The first value contains the name "Diana Luckevich" which we put in our itemList. The second value contains "info@doubleologic.com" which we put into the email_address array. Though both values are placed in different data structures, each will be referenced with the same relative index.
The Contact applet attempts to read 50 parameters from the HTML document. The readParam() method has a loop that executes 50 times in search of parameters in the HTML. The statement
param_data = getParameter("a" + j) searches for parameters with the names a1, a2, a3 all the way to a50.
The statement
if (param_data != null) determines if there is input data in the parameter. If true, a StringTokenizer object is created with this statement st = new StringTokenizer(param_data,"|");. The StringTokenizer is a very powerful object that locates tokens within a String. Tokens are delimited text strings. The delimiter, "|" is defined when the StringTokenizer object is created. The
if (st.hasMoreTokens()) statement determines if there is another token in the string.
The statement
email_name = st.nextToken() retrieves the next token in the String and places it in the method variable email_name. The next token is retrieved from the String and both values are stored in the appropriate data structure for later use.
When a method is called within its own class it is not preceded with a dot. For example when we call readParam(); nothing precedes it. When calling the nextToken() method of the st object like
st.nextToken(); the dot must be there. You can optionally code
this.readParam(). The "this" keyword is a special way to refer to the current object when code clarity is required, though this technique is rarely used in such a simple applet.