Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

image text in transcribed

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. Crente a Socket object from the URL's web address, connecting on port 80 (the default HTTP port). You will probably want to attach a Print Writer 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 Sfilepath> HTTP/1.1 Host: In other words, if the user typed "http://es.okstate.edu/students.html, your program should seud these three lines to the Socket: GET /students.html HTTP/1.1Nrhn Host: cs.okstate.edur n rn Don't forget to flush your output afterwards, or your request will never be sent. l'he web server will respond with a bunch of text including the web pace, which you should read into a String. In the progran panel, display (as plain text) the: body of the webpaige (explainedd below). Make sure tluat you set up the display so that. it ineludes a scroll bar when newded. Yo must also handle exceptions and errors gracefully, If the user enters a nonexistent URI, for instance, or if the H'TI response is formatted incorrertly, then t progral should inform the use A proper HTT respoill look like the following: HTTP header junk Several lines User doesn t vant to see this stuff Chead maybe some additional stuff>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started