Writing a Java applet that uses the network

  1. You may choose to design your own applet/application that uses network sockets or RMI to communicate between the applet and application (or two applications). For ideas, you can see the CPS606 assignment page for the networking assignment.
  2. or try the following applet:

  3. Password Protected File Server

    This server will be a Java application that has one or more directories of files that it can send to the client, but only if the client knows the right password. The client will be a Java applet that asks the user for a password, and if it's correct, will allow the user to request one of several files to be downloaded.

    The server can be based on the ThreadedEchoServer shown in class. It will expect the user to first send a password. You can have the usernames and passwords as built-in data to the program. Then the server will send back a message to the client either accepting or rejecting the password. In the case of reject, it can wait for another password. In the case of accept, it will wait for a request for a file. When it receives such a request, it reads the file and sends it back to the client.

    The client applet can be based on EchoClient shown in class. It will have buttons to connect and disconnect from the server. It will first ask the user to type a name and password into textfields, and send them to the server. If it receives a reject reply, it can ask the user to retype the password. If it receives an accept reply, the user must request the name of a file. This is sent to the server, and when the file is returned, the contents of the file are displayed in a textarea.

    In this simplest version, the user is expected to know what are file names that they can ask for. A better version would have the server send the names of available files from the server directory, and display them in the applet.

    Note that this is an outline of one way to do this. You may choose different design decisions, and additional work (such as displaying file names) will be given extra credit. Please document and submit your programs with a description as usual.