Implement a simple but a complete web server in java that is listening on port 9000...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Implement a simple but a complete web server in java that is listening on port 9000 using socket programming. The user types in the browser something like http://localhost:9000/ or http://localhost:9000/index.html or http://localhost:9000/image.png, etc The program should check 1- if the request is / or /index.html (for example localhost:9000/ or localhost:9000/index.html) then the server should send index.html file with Content-Type: text/html. The index.html file should contain HTML webpage that contains 1- "SPIDERMAN Simple Webserver" in the title 2- "Welcome to my " SUPERMAN" (part of the phrase is in Green) 3- Write "New York 90" and "Oklahoma 99" 4- Some information about spider man and super man. For instance, spider man, age: 33,City: Oklahoma, job: save people / super man age: 26,City: New York job : homeless 5- Use CSS to make the page looks nice (for example, you can divide the page using CSS) 6- An image with extention.jpg and an image with extension.png 3 2- if the request is /imagename.png then the server should send the png image with Content-Type: image/png. You can use any image. 3- if the request is /imagename.jpg then the server should send the jpg image with Content-Type: image/jpeg. You can use any image. 4- Include a text file (or you can use csv file) that contains names and prices of least 5 smartphones 5- if the request is /SortName then the output on the browser should be the 4- Include a text file (or you can use csv file) that contains names and prices of at least 5 smartphones 5- if the request is /SortName then the output on the browser should be the names and prices of the smartphones sorted by the name. The server should send text page with Content-Type: text/plain. I you wish, you can use text/html to display the output in a more convenient way. 6- if the request is /SortPrice then the output on the browser should be name and price of the smartphones sorted by its price. The server should send text page with Content-Type: text/plain. I you wish, you can use text/html to display the output in a more convenient way. 7- If the request is wrong or the file doesn't exist the server should return a simple HTML webpage that contains (Content-Type: text/html) 1- "HTTP/1.1 404 Not Found" in the response status 2- "Error" in the title 3- "Not Found" in the body 4- "Spider", "Super" names and their ages "33", "26"in Bold 5- The IP and port number of the client The program should print the HTTP requests on the terminal window (command line window). Provide screenshots of the browser to show that your project works as expected. (/index.html /imagename.pna. /SortName. etc.). Test the proiect from a browser The program should print the HTTP requests on the terminal window (command line window). Provide screenshots of the browser to show that your project works as expected. (/index.html /imagename.png, /SortName, etc.). Test the project from a browser on the same computer and from a different computer or phone. Provide also a screenshot of the HTTP request printed on the command line. Hint: Have a look on HTTP response in Listing 1 and the HTML code In Listing 2. You may use the minimal header and HTML code. Have a look also on rfc2616 (https://tools.ietf.org/html/rfc2616) HTTP/1.1 200 OK Connection: close Date: Fri, 03 Mar 2017 06:19:37 GMT Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.4.16 Last-Modified: Fri, 03 Mar 2017 05:28:07 GMT Content-Length: 6821 Content-Type: text/html data data data data data ... Listing 1: HTTP Response XYZ Company INC. Welcome XYZ Company We are so happy that you have chosen to visit our website. Listing 2: Simple HTML Code Implement a simple but a complete web server in java that is listening on port 9000 using socket programming. The user types in the browser something like http://localhost:9000/ or http://localhost:9000/index.html or http://localhost:9000/image.png, etc The program should check 1- if the request is / or /index.html (for example localhost:9000/ or localhost:9000/index.html) then the server should send index.html file with Content-Type: text/html. The index.html file should contain HTML webpage that contains 1- "SPIDERMAN Simple Webserver" in the title 2- "Welcome to my " SUPERMAN" (part of the phrase is in Green) 3- Write "New York 90" and "Oklahoma 99" 4- Some information about spider man and super man. For instance, spider man, age: 33,City: Oklahoma, job: save people / super man age: 26,City: New York job : homeless 5- Use CSS to make the page looks nice (for example, you can divide the page using CSS) 6- An image with extention.jpg and an image with extension.png 3 2- if the request is /imagename.png then the server should send the png image with Content-Type: image/png. You can use any image. 3- if the request is /imagename.jpg then the server should send the jpg image with Content-Type: image/jpeg. You can use any image. 4- Include a text file (or you can use csv file) that contains names and prices of least 5 smartphones 5- if the request is /SortName then the output on the browser should be the 4- Include a text file (or you can use csv file) that contains names and prices of at least 5 smartphones 5- if the request is /SortName then the output on the browser should be the names and prices of the smartphones sorted by the name. The server should send text page with Content-Type: text/plain. I you wish, you can use text/html to display the output in a more convenient way. 6- if the request is /SortPrice then the output on the browser should be name and price of the smartphones sorted by its price. The server should send text page with Content-Type: text/plain. I you wish, you can use text/html to display the output in a more convenient way. 7- If the request is wrong or the file doesn't exist the server should return a simple HTML webpage that contains (Content-Type: text/html) 1- "HTTP/1.1 404 Not Found" in the response status 2- "Error" in the title 3- "Not Found" in the body 4- "Spider", "Super" names and their ages "33", "26"in Bold 5- The IP and port number of the client The program should print the HTTP requests on the terminal window (command line window). Provide screenshots of the browser to show that your project works as expected. (/index.html /imagename.pna. /SortName. etc.). Test the proiect from a browser The program should print the HTTP requests on the terminal window (command line window). Provide screenshots of the browser to show that your project works as expected. (/index.html /imagename.png, /SortName, etc.). Test the project from a browser on the same computer and from a different computer or phone. Provide also a screenshot of the HTTP request printed on the command line. Hint: Have a look on HTTP response in Listing 1 and the HTML code In Listing 2. You may use the minimal header and HTML code. Have a look also on rfc2616 (https://tools.ietf.org/html/rfc2616) HTTP/1.1 200 OK Connection: close Date: Fri, 03 Mar 2017 06:19:37 GMT Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.4.16 Last-Modified: Fri, 03 Mar 2017 05:28:07 GMT Content-Length: 6821 Content-Type: text/html data data data data data ... Listing 1: HTTP Response XYZ Company INC. Welcome XYZ Company We are so happy that you have chosen to visit our website. Listing 2: Simple HTML Code
Expert Answer:
Answer rating: 100% (QA)
Heres a Java implementation of a simple web server that fulfills the requirements you provided import javaio import javanet import javautil public class SimpleWebServer public static void mainString a... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Spiderman uses his spider webs to save a runaway train moving about 60km/h Fig. 6-44. His web stretches a few city blocks (500 m) before the 104 -kg train comes to a stop. Assuming the web acts like...
-
Write a simple TCP program for a server that accepts lines of input from a client and prints the lines onto the server's standard output. (You can do this by modifying the TCPServer java program in...
-
The ENR construction cost index for New York City had a value of 12,381.40 in February 2007. For Pittsburgh and Atlanta, the values were 7341.32 and 4874.06, respectively. If a general contractor in...
-
A medical research study on a new medicine for multiple sclerosis is being conducted with 24 patients. After the study was concluded, it was determined that 16 patients reacted favorably to the...
-
True or false The efficient-market hypothesis assumes that a. There are no taxes. b. There is perfect foresight. c. Successive price changes are independent. d. Investors are irrational. e. There are...
-
Electric eels and electric fish generate large potential differences that are used to stun enemies and prey. These potentials are produced by cells that each can generate 0.10 V. We can plausibly...
-
The accounting records of Compass Bookstores, Inc., include the following: Requirement Report these liabilities on Compass Bookstores' balance sheet, including headings and totals for current...
-
Alitech Corporation is liquidating under Chapter 7 of the Bankruptcy Act. The accounts of Alitech at the time of filing are summarized as follows: The land and building are pledged as security for...
-
Sunny Days Corporation is deciding whether to automate one phase of its production process. The equipment has a six-year life and will cost $300,000. Projected net cash inflows from the equipment are...
-
Balance sheets for P Company and S Company on August 1, 2019, are as follows: Required: Prepare a workpaper for a consolidated balance sheet for P Company and its subsidiary on August 1, 2019, taking...
-
Scenario Background: Analyze the logistic support needs of the company in your chosen case study. Consider the companys production requirements, time, cost, and quantity of materials needed. What are...
-
Discuss some of the accounting policy decisions and management decisions made by Office Equipment. Which of these should be cause for concern? Why?
-
On January 1, 2021 the Parent buys 80% of the Subsidiary for $1 million, $400,000 of Goodwill was generated in the transaction, there were no other bump-ups of assets or liabilities, the fair market...
-
According to Alcntara Armando, it is a very important element to understand the direction that university systems are following, particularly in developing countries. Select one: The economic and...
-
Suppose there is a test for checking the presence of skin cancer. When cancer is present, the test is positive 98.5% of the time and negative the other 1.5%. When cancer is not present, the test is...
-
What general competencies, from those that you scanned, do you think are the most important for you professionally in accounting? Why?
-
2) When a policyholder rejects a replacement Medicare Supplement insurance policy during the free look period, the replaced policy must be reinstated regardless of the insured's health if: a) The...
-
Describe the Operations (+,,*,/) that can cause negligible addition (NA), error magnification (EM), or subtractive cancellation (SC) in calculating ?((x^2)+1) - x . Give the range of where they might...
-
Write a program that uses the Purchase class in Listing 5.13 to set the following prices: Oranges: 10 for $2.99 Eggs: 12 for $1.69 Apples: 3 for $1.00 Watermelons: $4.39 each Bagels: 6 for $3.50 Then...
-
Given a persons year of birth, the Birthday Wizard can compute the year in which the persons nth birthday will occur or has occurred. Write statements that can be used in a Java program to perform...
-
Complete and fully test the class Characteristic that Exercise 5 describes. Include the following methods: getDescriptionreturns the description of this characteristic. getRatingreturns the rating of...
-
Find the fundamental natural frequency of vibration of a uniform beam of length \(l\) that is fixed at one end and simply supported at the other end. Assume the deflection shape of the beam to be...
-
Determine the fundamental frequency of a uniform fixed-fixed beam carrying a mass \(M\) at the middle by applying Rayleigh's method. Use the static deflection curve for \(W(x)\).
-
Applying Rayleigh's method, determine the fundamental frequency of a cantilever beam (fixed at \(x=l\) ) whose cross-sectional area \(A(x)\) and moment of inertia \(I(x)\) vary as \(A(x)=A_{0} x /...
Study smarter with the SolutionInn App