Java Reference
In-Depth Information
}
}
If this is a regular HTML text character, then append it to the StringBuilder .
else
{
buffer.append((char)ch);
}
System.out.println(buffer.toString());
Finally, once the entire document has been read, it is displayed.
Recipe #9.3: JavaScript Forms
Another very common use for JavaScript is to validate forms. Usually these
forms can be treated as normal forms. However, sometimes these forms will make
use of an <input type="button"> tag to submit, rather than the usual
<input type="submit"> . If an <input> tag makes use of the button type,
rather than submit , then JavaScript must be used to submit the form. This recipe will show
how to process such a form. You can see the form that this recipe will process at the following
URL:
http://www.httprecipes.com/1/9/form.php
This recipe is shown in Listing 9.3:
Listing 9.3: JavaScript Forms (JavaScriptForms.java)
package com.heatonresearch.httprecipes.ch9.recipe3;
import java.io.*;
import java.net.*;
import java.util.*;
import com.heatonresearch.httprecipes.html.*;
public class JavaScriptForms
{
/** Advance to the specified HTML tag.
* @param parse The HTML parse object to use.
* @param tag The HTML tag.
* @param count How many tags like this to find.
* @return True if found, false otherwise.
* @throws IOException If an exception occurs while reading.
*/
private boolean advance(ParseHTML parse, String tag, int count)
Search WWH ::




Custom Search