Java Reference
In-Depth Information
// Ignore the leading " / " on the file name.
if (file - name.startsWith ( " / " ))
file - name = file - name.substring (1);
// If no file name is there, use index.html
// default.
if (file - name.endsWith ("/") ||
file - name.equals (""))
file - name = file - name + "index.html";
// Check for a request for the ADC reading.
if (file - name.endsWith ( " adc.html " )) read - adc =
true;
// Check if the file is hypertext or plain text
String content - type;
if (file - name.endsWith (".html") ||
file - name.endsWith (".htm")) {
content - type ="text/html";
}
else {
content - type ="text/plain";
}
// Now either read a file from the disk and
// write it to the output stream to the client
// or send the ADC reading if that is requested
try {
// Send the header.
pw - client - out.print ("HTTP/1.0 200 OK\r\n");
if (read - adc){
pw - client - out.print ("Server: ReadADC
1.0\r\n");
pw - client - out.print ("Content-length: " +
500 + "\r\n");
pw - client - out.print ( " Content-type: " +
content - type +
"\ r \ n \ r \ n " );
pw - client - out.print (fWebPageTop);
// Connect to ADC.
DataPort p0 = new DataPort (0x380001);
//DataPort.CE3);
// read ADC
int adc - value = p0.read ();
 
Search WWH ::




Custom Search