Develop a simple web server in two steps

Assignment Help Computer Networking
Reference no: EM13682709

Part -1:

Develop a simple Web server in two steps. In the end, you will have built a Web server that is capable of processing simple web requests such as an HTML page with embedded images. You should be able to demonstrate that your Web server is capable of delivering a simple home page to a Web browser.

As you are developing the code, you can test your server from a Web browser. But remember that you are not serving through the standard port 80, so you need to specify the port number within the URL that you give to your browser. For example, if you are testing your program on toolman, your server is listening to port 5910, and you want to retrieve the file index.html, then you would specify the following URL within the browser

To simplify this programming task, you should develop the code in two stages. In the first stage, you will write part of the server that simply displays the contents of the HTTP request message that it receives. After this program is running properly, you will add the code required to generate an appropriate response.

Write a java program named HttpServer.java that opens a TCP socket at a user specified port to listen to HTTP GET requests. This should be relatively easy and similar to the TCP Socket programs that we wrote in class. Create a S that listens for incoming client requests at a specified port. When the server receives a request, obtain the input and output streams from the socket. Read the HTTP packet from the client as a set of strings, each of which is terminated by a line feed (\n). Once the packet is read, display the content to the screen.

How would you know that you are done reading the packet?

The last string should have length zero since it only has a carriage return (\r) and line feed (\n) character in it.

Part -2:

In this assignment, you will complete the web server that you started in the last assignment. At this point, your program should be able to analyze the HTTP packets sent by the browser. You will need to implement the HTTP GET method alone for completing the assignment. At the end of this assignment, your web server should be able to deliver a simple HTML web page with an embedded image.

Your program should parse the HTTP packet sent by the client to obtain the filename requested by the client. Look at the StringTokenizer java class to see how you can use it to parse the request line in the HTTP packet. You can ignore the header lines, since we are not interested in these in the assignment. In case if the file is not found, you should generate a response with status 404 Not found response. How can we generate this response? The HTTP response has three main parts - thes status line, header lines, and the Entity body. You would need to populate these values, and send these as a stream of bytes to the client. An example code snippet is given for your benefit.

Reference no: EM13682709

Questions Cloud

Obtain the duration of the time interval : A wheel is rotating about an axis that is in the z-direction. The angular velocity is 6 rad/s at t=0, increases linearly with time and is +8.00 rad/s at t=7 second. Obtain the duration of the time interval when the speed of the wheel is increasing
Weight-loss plan that involves repeatedly lifting : Brad tries out a weight-loss plan that involves repeatedly lifting a 45.0-kg barbell from the floor over his head to a height of 2.3 m. If he is able to complete three such lifts per minute, how long will it take for him to lose 0.50 kg of fat? "Burn..
Determine the mass of the second asteroid : You are working on a project to determine the density of asteroids in order to figure out what minerals they might contain for mining. You figure out the volume fairly easily from images of the asteroids taken from various angles. Determine the ma..
Elevator-scale reading : Elevator-Scale Reading-What will the scale read if the elevator moves in free fall? (in kg) What will the scale read if the elevator moves with downward acceleration 0.340g?
Develop a simple web server in two steps : Develop a simple Web server in two steps. In the end, you will have built a Web server that is capable of processing simple web requests such as an HTML page with embedded images -
Obtain the current and the voltage drop in the resistor : The frequency for an AC source in an RLC circuit is 5 x 102 rad/s and its half of the resonance frequency. Obtain the current and the voltage drop in the resistor
Straight-line amortization of the discount : Straight-line amortization of the discount.
Passes over frictionless pulley connects two blocks : A mass less rope that passes over a frictionless pulley connects two blocks. The mass of the block on the left is 10kg, and it rests on a plane making an angle of 40 degrees with respect to the horizontal. The block on the right rests on a plane maki..
Evaluate the mutual inductance of these solenoids : One solenoid is centered inside another. The outer one has a length of 47 centimeter and contains 6800 coils, Evaluate the mutual inductance of these solenoids

Reviews

Write a Review

Computer Networking Questions & Answers

  Why an organization block icmp traffic

CMP provides many useful services, yet some organizations block ICMP traffic. Why should an organization block ICMP traffic?

  Describe the imap protocol

List and illustrate 5 RFCs that describe the IMAP protocol. Print and read the first two pages of one of these RFCs.

  Explain privacy issues related with acxiom-s business

Break into small groups with classmates, and explain privacy issues related with Acxiom's business. Do you believe they are doinganything wrong?

  For the given data below what should the product

for the given data below what should the product specification be set at if the company would like to have cp 1.4 ?

  What are the most significant criteria for choosing a wan

question 1 what are the most important criteria for selecting a wan service provider? list and explain at least five.

  Define throughput in regards to wireless network

Define 'throughput' in regards to wireless network. Use a practical method (e.g., using an software) to measure throughput of a wireless network? You should provide any appropriate screenshots.

  Compare and contrast some of the options or technologies

compare and contrast some of the options or technologies available to secure a wi-fi network. what are the benefits of

  Question 1amake a distinction between passive and active

question 1amake a distinction between passive and active attacks.bprovide two reasons why it is very important to

  Benefits of authentication scheme

An example of when a failure may occur is if the clinet's MAC address is explicitly excluded in the AP/router configuration. What are the benefits of this authentication scheme?

  Design such a password protocol

Such schemes need careful evaluation of their usability and effectiveness using the tools of applied psychology. Design such a password protocol and evaluate its usability and effectiveness. (A verbal text description is enough.)

  Snmp securitybullsnmpv1 is the most commonly used version

snmp securitybullsnmpv1 is the most commonly used version of snmp even though it provides little support for security.

  How internet works for organization-s office administration

What would be needed along with precautionary measures, and an overview of how the Internet works for the organization's office administration.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd