Java Reference
In-Depth Information
public void run() {
try {
// Initializes input and output streams
BufferedReader input # new BufferedReader(
new InputStreamReader(socket.getInputStream()));
PrintWriter output # new PrintWriter(
new BufferedOutputStream(socket.getOutputStream()),
false );
while ( true ) {
// waiting for a request
String message # input.readLine();
if (message ## null ) continue ;
if (message.equals("Bye.")) break ;
else if (message.equals("GETRECORD")) {
String dbInfo[] # new String[3];
dbInfo[0] # input.readLine(); // db name
dbInfo[1] # input.readLine(); // table name
dbInfo[2] # input.readLine(); // key name
String keyValue # input.readLine(); // key value
// extracts a record from the selected database
DBValueRecord record #
DBConnector.getRecord(dbInfo, keyValue);
// serializes the record's attributes
output.println("" ! record.getSize());
for ( int i # 0; i < record.getSize(); i !! )
output.println(record.getAttribute(i) ! " " !
record.getValue(i));
output.flush();
}
}
input.close(); output.close(); socket.close();
server.disconnect(this);
}
catch (Exception e){ server.disconnect( this ); }
}
}
Class GisApplet implements the applet that displays the cartographic map
within the user's browser. The list of available cartographic maps is loaded
from the HTML file that embeds the applet as shown in the HTML code in
Figure 15.13.
When the applet is loaded within the web browser, it creates a socket to
establish a connection with the remote application server in order to
retrieve data records associated with the selected geographic features.
public class GisApplet extends JApplet {
Socket socket;
// the IP address of the remote application server is set
Search WWH ::




Custom Search