1 / 33

Web Basics: HTML and HTTP

http:// www.computerhistory.org /timeline/images/1993_mosaic_browser_large.jpg. Web Basics: HTML and HTTP. What is HTML?. HyperText Markup Language Main language for writing web pages that can be displayed in a web browser. Implies links. Implies formatting tags. Brief History of HTML.

nmcduffie
Download Presentation

Web Basics: HTML and HTTP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. http://www.computerhistory.org/timeline/images/1993_mosaic_browser_large.jpghttp://www.computerhistory.org/timeline/images/1993_mosaic_browser_large.jpg Web Basics: HTML and HTTP

  2. What is HTML? HyperText Markup Language Main language for writing web pages that can be displayed in a web browser Implies links Implies formatting tags

  3. Brief History of HTML • 1991ish: Born • Thru 1990s: Evolves • Versions 0 to 4 • By 2000: Ver. 4.01 wins! • Still most common/supported • 2008: HTML5 introduced • Rich media and mobility • Not yet final • Not fully supported We’ll use HTML5

  4. HTML5 = 3 Technologies • HyperText Markup Language (HTML) for Structure • Cascading Style Sheets (CSS) for Style • JavaScript for Behavior I’ll cover Explore on your own

  5. How HTML Works You write HTML text <!DOCTYPE html> <html> <head> <title>Hello!</title> </head> <body> <h1>Howdy Y'all</h1> <p> How do ya like my HTML? </p> </body> </html> Then load it in a browser

  6. HTML Elements Note slash! Tag name Start tag End tag <p>This is a paragraph.</p> Renders as This is a paragraph.

  7. Elements can be nested Nested element <p>This is a<b>paragraph</b>.</p> Renders as This is a paragraph.

  8. Elements can have attributes Attribute Attributename Equals Valuestring <p style="color:blue">I'm blue!</p> Renders as I’m blue!

  9. HTML Page Structure Doctype info <!DOCTYPE html> <html> <head> <title>Hello!</title> </head> <body> <h1>Howdy Y'all</h1> <p> How do ya like my HTML? </p> </body> </html> head element for metadata html element body element for content

  10. Oh yeah, and … • A few tags don’t come in pairs: • E.g.: <br> for line breaks • E.g.: <img> for images • Browsers collapse whitespace (spaces, newlines): • Consecutive whitespace treated as single space • Leading/trailing whitespace eliminated • Special symbols: • E.g.: &nbsp; for non-breaking space • See: http://www.w3schools.com/html/html_entities.asp and http://www.w3schools.com/tags/ref_symbols.asp

  11. Now, all you need to do is learn these tags:http://www.w3schools.com/tags/ref_byfunc.asp(Ignore the ones marked “new” for now)(Ignore the “not supported” ones)

  12. But how does the Web work?When you open a web page in your browser,where does that page come from, andhow does it get there?

  13. The architecture of the Web Head First Servlets and JSP (2nd edition), p. 3

  14. Typical web browser/server interaction At the very least, what must to give your browserso that it can request a web page? A URL! Head First Servlets and JSP (2nd edition), p. 4

  15. Anatomy of a URL http://www.wickedlysmart.com:80/beeradvice/select/beer1.html Path Server Resource Port (optional) Protocol (http, https, etc.)

  16. So what do requests and responsesactually look like anyway? Head First Servlets and JSP (2nd edition), p. 4

  17. Example HTTP GET request Protocolversion Path toresource HTTPMethod GET /select/selectBeerTaste.jsp HTTP/1.1 Host: www.wickedlysmart.com User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X… Accept: text/xml,application/xml,application/xhtml+xml… Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Requestheaders

  18. Example HTTP response HTTP status code Protocolversion Text version of status code HTTP/1.1 200 OK Content-Type: text/html Content-Length: 397 Date: Wed, 19 Nov 2003 03:25:40 GMT Server: Apache-Coyote/1.1 Connection: close <html> … </html> Responseheaders Response body

  19. Let’s see the request/response in a bit more detail… Head First Servlets and JSP (2nd edition), p. 18

  20. Head First Servlets and JSP (2nd edition), p. 18

  21. But the example only covers staticweb pages(i.e., just retrieve an HTML file) • What if we want a richer user interaction? • User sends additional data • Server processes data and • generates custom response We need to create a web app(aka dynamicweb page)

  22. Typical architecture of a web app Head First Servlets and JSP (2nd edition), p. 27

  23. Typical architecture of a web app Given to you(e.g., Rails server) You write(e.g., yourRuby/Railscode) Head First Servlets and JSP (2nd edition), p. 27

  24. Typical architecture of a web app Head First Servlets and JSP (2nd edition), p. 27

  25. Typical architecture of a web app Head First Servlets and JSP (2nd edition), p. 27

  26. Recall step #2… How send parametersfrom browser? Head First Servlets and JSP (2nd edition), p. 27

  27. GET requests can embed parameters in the URL Parameter list Head First Servlets and JSP (2nd edition), p. 14

  28. Limitations of GET parameters • Total characters limited (varies by server) • Parameters are exposed • Bad for passwords! Another way to pass parameters:The HTTP POST method

  29. Example HTTP POST request HTTPMethod Path toresource Protocolversion POST /select/selectBeerTaste.do HTTP/1.1 Host: www.wickedlysmart.com User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X… Accept: text/xml,application/xml,application/xhtml+xml… Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive color=dark&taste=malty Requestheaders Requestbody But how do you make a POST request? HTML Forms!

  30. Structure of a form OptionalID for form Helper app URL (more next lecture) HTTP method Text onbutton Submit button input element <form name="myName" action="myHelperApp.do" method="post"> ...input elements here... <input type="submit" value="Submit"> </form> formblock

  31. Common Input-Element Types(attributes vary) text submit password radio select/option textarea checkbox See http://www.w3schools.com/html/html_forms.asp

  32. In Rails Tutorial Chapter 2,the generated scaffoldincludes HTML and forms

  33. Summary • HTML element syntax • HTML page structure • HTML tags • Dynamic web pages and POST requests • Form structure and input elements http://flic.kr/p/YSY3X

More Related