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

  From the second e-activity decide which you would select to

envision that you are a systems administrator managing five different web servers for your company. each web server

  Remote network implementation plan

Remote Network Implementation Plan

  Assignment on mirror mirror on the ceiling flexible

assignment on mirror mirror on the ceiling flexible wireless links for the data center.please answer the following

  Relationship-individual characteristics and job satisfaction

What is the relationship between individual characteristics and job satisfaction?

  Create variant of kerberos in which workstation generate tgt

Create variant of Kerberos in which the workstation generates TGT. TGT will be encrypted with user's master key rather than KDC's master key.

  Acknowledge technoogy-s polypotency

Richard Sclove argues that we must do more to acknowledge technoogy's 'polypotency.' What does this term mean, why does Sclove think that it is significant to acknowledge this characteristic of technology?

  What are the components and network infrastructure and end

1. please write a three page paper on the designbuild of a computer network within a hospital in relations to

  Describe file system principles and interpret the system

Identify, and describe the advantages, disadvantages, organization and functions of the major components of a modern operating system.

  Identify and briefly explain any four key requirements

An organization called Ranbaxy Inc. has currently 3 divisions in 3 different locations within Sydney city. One of the divisions serves as the company headquarters.

  Explaining dns resolver queries

When a DNS resolver queries the name server, does case of the domain name affect response?

  How to decrement the ttl field of the packet

In addition to the above-mentioned  KeyboardInterrupt (used to terminate the program), you will need to handle any I/O-related exceptions.

  What is the required bandwidth for the transmission

Calculate the Network ID/Subnet ID of the host having an IP address 192.32.24.70 with a subnet mask 255.255.255.224. What would be the IP address of the 1st host and the last host of the subnet?

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