Question: Web Browser Write a very simple GUI web browser. Your program should have a text edit box at the top of the window for the
Web Browser
Write a very simple GUI web browser. Your program should have a text edit box at the top of the window for the user to type a URL. Provide a listener that activates when the user types something in and presses Enter. The HTTP specification is fairly simple. Create a Socket object from the URLs web address, connecting on port 80 (the default HTTP port). You will probably want to attach a PrintWriter and a BufferedReader to the Socket. Send the following lines of text, ending in both carriage return and newline characters (yes, HTTP follows Windows line-ending conventions, rather than Unix): GET HTTP/1.1 Host: In other words, if the user typed http://cs.okstate.edu/students.html, your program should send these three lines to the Socket: GET /students.html HTTP/1.1 Host: cs.okstate.edu Dont forget to flush your output afterwards, or your request will never be sent. The web server will respond with a bunch of text including the web page, which you should read into a String. In the program panel, display (as plain text) the body of the webpage (explained below). Make sure that you set up the display so that it includes a scroll bar when needed. You must also handle exceptions and errors gracefully. If the user enters a nonexistent URL, for instance, or if the HTTP response is formatted incorrectly, then the program should inform the user. A proper HTTP response will look like the following: HTTP header junk Several lines User doesnt want to see this stuff Javascript definitions Other stuff the user doesnt care about. 2 Heres all the stuff the user really cares about.
Along with a bunch of formatting,
links, and images. Browsers display HTML by following the instructions provided by tags delineated by angle brackets. The first word inside a bracket specifies the kind of tag; tags can then have other information inside, and then end with a closing bracket. All of the text after a tag is formatted according to the tags instructions, until a closing tag is encountered. These tags are also delineated by angle brackets, and include a slash and then the name of the tag. Thus, in the example, the line Along with a bunch of formatting, is enclosed by the h1 tag, which instructs the browser to display it with a font size indicating that it is a first-level heading. According to the HTML specification, browsers are not required to implement all of the scores of tags that exist, and they should ignore any tags they do not recognize. Your browser will ignore almost all of them. It will be able to do the following:
Web BrowserStep by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
