
Updated Scheduling Program
function findTestTypes(grp){
var url = "/tests/lookup?cmd=test&gc="+grp.value;
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
req.open("GET", url, true);
req.onreadystatechange = showTestTypes;
req.send(null);
}
function showTestTypes(){
if (req.readyState == 4 && req.status == 200) {
var html = req.responseText;
var tt = getItem("tests");
tt.innerHTML = html;
fireChangeEvent("test_code");
}
}
// for mozilla
function fireChangeEvent(fieldName){
if (window.ActiveXObject) {
getItem(fieldName).fireEvent('onchange');
}else{
// target is some DOM node on which you wish to fire an event.
var target = getItem(fieldName);
var oEvent = document.createEvent( "Events" );
oEvent.initEvent(
"change", // the type of mouse event
true, // do you want the event to
// bubble up through the tree? (sure)
true, // can the default action for this
// event, on this element, be cancelled? (yep)
window, // the 'AbstractView' for this event,
// which I took to mean the thing sourcing
// the mouse input. Either way, this is
// the only value I passed that would work
1, // details -- for 'click' type events, this
// contains the number of clicks. (single click here)
1, // screenXArg - I just stuck 1 in cos I
// really didn't care
1, // screenYArg - ditto
1, // clientXArg - ditto
1, // clientYArg - ditto
false, // is ctrl key depressed?
false, // is alt key depressed?
false, // is shift key depressed?
false, // is meta key depressed?
0, // which button is involved?
// I believe that 0 = left, 1 = right,
// 2 = middle
target // the originator of the event
// if you wanted to simulate a child
// element firing the event you'd put
// its handle here, and call this method
// on the parent catcher. In this case,
// they are one and the same.
);
target.dispatchEvent( oEvent );
}
}
DataInputStream dis;
try {
String urlString = "http://www.ibm.com";
URL url = new URL(urlString);
dis = new DataInputStream(url.openConnection().getInputStream());
BufferedReader in = new BufferedReader(new InputStreamReader(dis));
String total = "";
String line = "";
While ((line = in.readLine()) != null) {
total += line;
}
in.close();
} catch (Exception e) {
System.out.println(e);
}
// Listing 2
//
// Applet client-side code to send a student object
// to a servlet in a serialized fashion.
//
// A POST method is sent to the servlet.
//
URL studentDBservlet = new URL( webServerStr );
URLConnection servletConnection = studentDBservlet.openConnection();
// inform the connection that we will send output and accept input
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
// Don't use a cached version of URL connection.
servletConnection.setUseCaches (false);
servletConnection.setDefaultUseCaches (false);
// Specify the content type that we will send binary data
servletConnection.setRequestProperty ("Content-Type", "application/octet-stream");
// send the student object to the servlet using serialization
outputToServlet = new ObjectOutputStream(servletConnection.getOutputStream());
// serialize the object
outputToServlet.writeObject(theStudent);
outputToServlet.flush();
outputToServlet.close();