290 likes | 594 Views
Tim Berners-Lee. First ever web server. First ever website. August 6 th 1991: info.cern.ch. First ever web server. First ever website. info.cern.ch/hypertext/WWW/TheProject.html. HTTP history. Hypertext Transfer Protocol “//” unnecessary. TimBL says ‘sorry’ HTTP 0.9 released 1991
E N D
First ever web server. First ever website August 6th 1991: info.cern.ch
First ever web server. First ever website info.cern.ch/hypertext/WWW/TheProject.html
HTTP history • Hypertext Transfer Protocol • “//” unnecessary. TimBL says ‘sorry’ • HTTP 0.9 released 1991 • HTTP 1.0 released 1996 • HTTP 1.1 released 1997 (persistent tcp conn.) • HTTP 1.1 update 1999
HTTP RFC2616 • Hypertext Transfer Protocol • “//” unnecessary. TimBL says ‘sorry’ • HTTP 0.9 released 1991 • HTTP 1.0 released 1996 • HTTP 1.1 released 1997 • HTTP 1.1 update 1999
Request Response Cycle HTTP response HTTP request TCP Connection
HTTP REQUEST • Request Line <CR><LF> • Headers <CR><LF> • Empty Line <CR><LF> • Message Body <CR><LF> (optional)
HTTP REQUEST • GET /downloads/download.htm http/1.1 • Host: notborder.org
HTTP Request Methods • GET • HEAD • POST • PUT • DELETE
HTTP Request Methods • GET • HEAD • POST • PUT • DELETE C R U D
HTTP Request Methods • GET • HEAD • POST • PUT • DELETE Create Read Update Delete
HTTP RESPONSE • Status Line <CR><LF> • Headers <CR><LF> • Empty Line <CR><LF> • Message Body <CR><LF> (optional)
HTTP RESPONSE HTTP/1.1 200 OK<CR><LF> Date: Mon, 23 May 2005 22:38:36 GMT Server: Apache/2.1.1.6 (Red-Hat/Linux) Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT Content-Length: 4387 Connection: close Content-Type: text/html; charset=UTF-8 <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Trasitional… <html> <head>
HTTP Status Codes • OK • Bad Request • Unauthorized • Forbidden • Not Found • I’m a teapot 500 Internal Server Error
HTTP Status Codes • OK • Bad Request • Unauthorized • Forbidden • Not Found • I’m a teapot 500 Internal Server Error RFC 2324 released April 1st 1998 Hyper Text Coffee Pot Control Protocol http://tools.ietf.org/html/rfc2324 http://en.wikipedia.org/wiki/Hyper_Text_Coffee_Pot_Control_Protocol
Java EE6 Reference Implementation Glassfish
Server Machine Web Server App Web Container App HTTP request Servlet
Server Machine Web Server App Web Container App Servlet HTTP response
Server Machine HTTP request Container Servlet request response
Server Machine Container thread Servlet request response
Server Machine HTTP response Container thread Servlet service() response request Dfdsjkl;fdjksl; Fdsflkjsfs Sfjdkljlfslss Fjklsl Fjkdlsjfklsjljsls Jljlksjkljl;fkjl; doGet()
Server Machine Container thread Servlet response request
Example Code import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class TestServletextends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { PrintWriter out = response.getWriter(); java.util.Date today = new java.util.Date(); out.println(“<html>” + “<body>” + “<h1 style = ‘text-align:center’>” + “Test Servlet</h1>” + “<br>” + today + “</body>” + “</html>”); } }
Servlet Deployment • web.xml“Web Application Deployment Descriptor” <web-app> <context-root>/GreatWebApp</context-root> <servlet> <servlet-name>Freddy</servlet-name> <servlet-class>foo.MyServlet1</servlet-class> </servlet> <servlet-mapping> <servlet-name>Freddy</servlet-name> <url-pattern>/public/downloads</url-pattern> <url-pattern>/public/tracy/*.jsp</url-pattern> <servlet-mapping> </web-app>
Alternative Deployment • Annotations @WebServlet( name = “Freddy”, urlPatterns = {“/public/downloads”, “/public/tracy/*.jsp”}) public class MyServlet1 extends HttpServlet { …