This Java program consists of a simple HTTP client and server. The server can handle two types of requests:
- Chat Messages - The client can send text messages to the server.
- File Uploads - The client can upload files to the server.
The Client class provides a command-line interface for users to interact with the server. It offers two main functionalities:
- Chat - Allows users to send messages to the server.
- Upload File - Allows users to upload files to the server.
The Server class sets up an HTTP server that listens for requests on port 8000. It supports:
- ChatHandler - Handles incoming chat messages.
- UploadHandler - Handles file uploads.
- Java Development Kit (JDK) 11 or higher
- Clone the repository or download the source files.
- Compile the Java files.
- Run the server.
- In a separate terminal, run the client.
-
Chat:
- When prompted, enter
1to send a chat message. - Type your message and press Enter.
- The server's response will be displayed.
- When prompted, enter
-
Upload File:
- When prompted, enter
2to upload a file. - Provide the full path to the file you want to upload.
- The server's response will be displayed, confirming receipt and processing of the file.
- When prompted, enter
- The server logs all received chat messages and uploaded files to the console.
- Uploaded files are currently saved to
C:\Java Tutorial\RyanProject\HttpMultiPurposeServer\StoredFiles\.