Question: java this is whole question do you want the code that i did it in first task , no idea what do you want Problem
java
this is whole question do you want the code that i did it in first task , no idea what do you want
Problem 1 Implement a simple web server that accepts multiple client connections on some port ( 1000) using the ServerSocket class. The server should serve (at least) HTML and using the GET method in the HTTP protocol. files from a local directory, The response from the server should include correct and relevant headers as well as the requested file. The server should run until you terminate it (ctrl-c or ctrl-d keyboard shortcut). Two program arguments the port Path to /public directory. This of this folder as the serving directory from which our web-server will serve html files and images. Accessing http://yourip:port/shrek.html will serve a file from your_project_folder/public/shrek.html . Start by implementing a server that accepts connections and returns a predefined (valid) HTTP/HTML response. Once you can connect to the server with a web browser and view the predefined HTML page, you should add support for reading HTML files from disk and returning these. Finally, add support for images (binary files). If a user requests a specific directory, e.g. or userl/pages and this directory contains index.html file, then this file should be returned. Note that the ending / is optional, so http://myserver.com/userl and http://myserver.com/user1/ should both return the index.html file in the userl directory. Prepare a few HTML and PNG files in a directory hierarchy (e.g., /memes/rarepepe.png) and use this to test your web server. Make sure to include both index.html files as well as other named HTML files, e.g., myfile.html . Your report should include screenshots of the browser window when you request a named HTML page, an image, and a directory (with an index.html file). Your web server should be robust -- you have to handle possible exceptions. Document which exceptions you handle. Note*: You are not allowed to use third-party libraries or existing Java classes (such as com.sun.net.httpserver ) since these make the problem trivial. Hint: You can reuse your code from the first assignment. Hint: You can use the provided test script to check if your implementation works as expected. Problem 2 The web server you implemented in Problem 1 only supports the HTTP response 200 OK . You should now add support for the following response types: 302, 403, 404, and 500 . Include a description of how you tested each of these response codes with screenshots of the result in your report. Problem 1 Implement a simple web server that accepts multiple client connections on some port ( 1000) using the ServerSocket class. The server should serve (at least) HTML and using the GET method in the HTTP protocol. files from a local directory, The response from the server should include correct and relevant headers as well as the requested file. The server should run until you terminate it (ctrl-c or ctrl-d keyboard shortcut). Two program arguments the port Path to /public directory. This of this folder as the serving directory from which our web-server will serve html files and images. Accessing http://yourip:port/shrek.html will serve a file from your_project_folder/public/shrek.html . Start by implementing a server that accepts connections and returns a predefined (valid) HTTP/HTML response. Once you can connect to the server with a web browser and view the predefined HTML page, you should add support for reading HTML files from disk and returning these. Finally, add support for images (binary files). If a user requests a specific directory, e.g. or userl/pages and this directory contains index.html file, then this file should be returned. Note that the ending / is optional, so http://myserver.com/userl and http://myserver.com/user1/ should both return the index.html file in the userl directory. Prepare a few HTML and PNG files in a directory hierarchy (e.g., /memes/rarepepe.png) and use this to test your web server. Make sure to include both index.html files as well as other named HTML files, e.g., myfile.html . Your report should include screenshots of the browser window when you request a named HTML page, an image, and a directory (with an index.html file). Your web server should be robust -- you have to handle possible exceptions. Document which exceptions you handle. Note*: You are not allowed to use third-party libraries or existing Java classes (such as com.sun.net.httpserver ) since these make the problem trivial. Hint: You can reuse your code from the first assignment. Hint: You can use the provided test script to check if your implementation works as expected. Problem 2 The web server you implemented in Problem 1 only supports the HTTP response 200 OK . You should now add support for the following response types: 302, 403, 404, and 500 . Include a description of how you tested each of these response codes with screenshots of the result in your report
Step by Step Solution
There are 3 Steps involved in it
To implement a simple web server in Java that meets the requirements given you will need to use the ServerSocket class to handle connections and manage HTTP responses manually Heres a breakdown of how ... View full answer
Get step-by-step solutions from verified subject matter experts
