Tuesday, November 13, 2007

Internet Alphabet Soup: TCP/IP, HTML & HTTP

To demonstrate how HTML is communicated across the internet, have a look at the HTML without the benefit of a browser. Simple commands entered in the computer's command window can fetch the HTML text of a web page and print it in the command window. Assuming you have Tomcat running on your system using the default port, enter the following two commands:
c:\>telnet 127.0.0.1 8080
GET /
You'll see the unrendered HTML of the web page. Telnet will also display the source of a web page you create, including the "hidden" fields. Create a text file hidden.html in the Tomcat webapp/ROOT folder and add this HTML to the file:
<html>
<body>
    <div> Here's what I'm talking about</div>
    <input type="text" readonly value="readonly"/>
    <input type="hidden" value="hidden"/>
</body> 
</html>
To view the HTML, telnet to 127.0.0.1 port 8080 and GET /hidden.html. In the telnet session, you'll see the hidden field even though it won't be displayed in the browser if you navigate it to http://127.0.0.1:8080/hidden.html.