Download presentation
Presentation is loading. Please wait.
1
Web programming for project students Dr Jim Briggs
2
What is the web? Distributed system Client-server system Characteristics of clients and servers –Servers always on / Clients choose when on –Clients do not need high performance if the work is done on the server Protocol based
3
Basic architecture of the web
4
Common web tools Browsers –Microsoft Internet Explorer –Netscape Navigator –Mozilla (Firefox) –Opera –Safari –Konqueror –Lynx Servers –Apache –Internet Information Server (Microsoft) –Sun –Netscape –Omni –Roxen –NCSA
5
HTTP protocol Specified by –http://www.w3.org/Protocols/rfc2616/rfc2616.htmlhttp://www.w3.org/Protocols/rfc2616/rfc2616.html Based on requests and responses A response can contain any document –MIME ( Multipurpose Internet Mail Extensions ) types –http://www.iana.org/assignments/media-types/http://www.iana.org/assignments/media-types/ A stateless protocol Normally transported via a TCP/IP connection –Default port is TCP 80
6
HTTP requests Requests –GET –POST –PUT –HEAD Example request GET http://www.port.ac.uk/index.htm HTTP/1.1
7
HTTP responses HTTP/1.1 200 OK Server: Microsoft-IIS/4.0 Date: Mon, 29 Apr 2002 08:50:53 GMT Content-Type: text/html Accept-Ranges: bytes Last-Modified: Wed, 10 Apr 2002 16:12:34 GMT ETag: "085fb85aae0c11:54fb" Content-Length: 13845 University of Portsmouth - Our University...
8
An error response HTTP/1.1 404 Object Not Found Server: Microsoft-IIS/4.0 Date: Mon, 29 Apr 2002 08:58:12 GMT Content-Length: 11891 Content-Type: text/html University of Portsmouth - Our University...
9
Dynamic web pages Four models: –Server-side includes –CGI –Server modules –Auxiliary servers
10
CGI architecture
11
CGI specification Specified at http://hoohoo.ncsa.uiuc.edu/cgi/ http://hoohoo.ncsa.uiuc.edu/cgi/
12
Server module
13
Auxiliary server
14
Common web languages Java/JSP ASP (.NET) / C# PHP Perl Ruby on Rails
15
Architecture of a Java web application
16
Introduction to Java web apps Servlets and JSPs Servlet container –Tomcat A container may run several (independent) web applications (webapps) Each must have a WEB-INF directory: –web.xml configuration file –classes directory –lib directory
17
Important classes and interfaces 1 All servlets must implement the Servlet interface Class HttpServlet –init/destroy –doGet/doPut –Your servlet will derive from this
18
Important classes and interfaces 2 2 parameters to a request handling method Class HttpServletRequest –String param = request.getParameter(name); Class HttpServletResponse –PrintWriter out = response.getWriter(); Class HttpSession –Holds data common to related requests
19
JavaServer Pages (JSP) Distinction: –servlets: HTML embedded in program –JSP: program embedded in HTML Useful where majority of effort is page design Translated automatically into a servlet –Retranslated if changed (no need to restart server) Can be placed anywhere in a web application –but not visible to client if in the WEB-INF directory
20
JSP elements Scriptlets Actions Directives Standard tags Custom tags Expression language
21
Scriptlets Any Java code between Expressions – Declarations – DEPRECATED –Do not use - not XML –Much easier to use JSTL
22
JSP actions Including other files – –Request time inclusion Accessing beans –
23
JSP directives Page directive – Include directive – –Translation time inclusion
24
Java Standard Tag Library (JSTL) Taglib directive – Core – SQL XML Format
25
Custom tags Implement your own tags Create a Tag Library Definition (tld) file Extend predefined classes Specify your library in a @taglib directive Use like JSTL tags
26
Expression language Refer to Java Beans and other common classes ${expression} can appear as tag attributes or (since JSP 2.0) in the page itself Several implicit objects: –header ${header["user-agent"]} –param ${param['name']} ${param.name}
27
Java tools NetBeans –IDE –edit, compile, build, run, debug –lots of wizards –support for Struts –support for Hibernate (through nbxdoclet) Eclipse
28
Web application system architecture
29
Model View Controller (MVC)
30
MVC in Java
31
Relationship between Struts and Hibernate
32
Struts information flow
33
Role of the persistence layer
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.