cis 285 robinson winter 2005 cis 285 web application development with java cis 285 sinclair...
TRANSCRIPT
CIS 285 ROBINSON WINTER 2005
CIS 285CIS 285 Web Application Web Application
Development with JavaDevelopment with Java
CIS 285Sinclair Community CollegeInstructor: Mary Robinson
CIS 285 ROBINSON WINTER 2005
Course Objectives
Create attractive Web sites that include graphics, forms, tables & form validation
Understand the JavaScript/HTML Object model
Use Cookies to access Web applications Construct and use JavaServer Pages and
integrate Java Beans Construct and launch Java Servlets from
HTML and JavaServer Pages
CIS 285 ROBINSON WINTER 2005
Course Objectives
Use JDBC to retrieve, insert and update data in a back end database from a Web page
Generate dynamic Web pages using JavaServer Pages, JavaBeans, Java Servlets, JDBC and XML
Understand the model-view-controller (MVC) Design, create and deploy a small e-business
Web-site using all the tools taught in the class Introduce “Best Practices”
CIS 285 ROBINSON WINTER 2005
Course Progress
Class attendance Labs & Projects Assignments Exams Contacting the instructors
CIS 285 ROBINSON WINTER 2005
Introduction
Name and organization Object-oriented programming
experience HTML, XHTML, XML, JavaScript
background Java, WebSphere Studio Application
Developer or other IDE experience
CIS 285 ROBINSON WINTER 2005
Agenda – 4 Jan 2005
General Web Architecture Web Evolution Server-Side Technologies Servlet / Java Server Page (JSP) Lab Exercise (HTML) Lab Assignment
CIS 285 ROBINSON WINTER 2005
Class #1 Objectives:
Define the stages of Web application development
Discuss static content - HTML Dynamic content – client-side Dynamic content – server-side Create an HTML page Instructions for Lab #1
CIS 285 ROBINSON WINTER 2005
General Web Architecture
Web server requests a Web page from a Web server
Web server locates requested page Web server could process some code in the
requested page Web server send page to the client that
requested it
CIS 285 ROBINSON WINTER 2005
Client / Server Model
Data LayerDatabase
Legacy Store
BusinessLogic
Separates execution of tasks evenly (goal)
Makes optimal useof resources
Based on the distributionof the components, N-tierclient-server models havebeen developed
PresentationLogic
CIS 285 ROBINSON WINTER 2005
Two Tier Client / ServerArchitecture
DatabaseServer
Accesses databaseIssues queries
Return results to client
Presentation LogicBusiness Logic Database Management
CIS 285 ROBINSON WINTER 2005
Three Tier Client / ServerArchitecture
DatabaseServer
Presentation LogicDatabase
Management
ApplicationServer
Business Logic
Client Application Server Database
Send requestto application
server
Access databaseand issuequeries
Send anddisplay results
Business logicmanipulatesquery result
CIS 285 ROBINSON WINTER 2005
Web Application – Static
Server
Client
Web Browser
Web Server
File System
HTTP Request
HTTP Response
Network
CIS 285 ROBINSON WINTER 2005
Web Application – Static Pages
Content exists before the page is requested
User requests a page via URL into the browser, and the request is sent from the browser to the Web server via HTTP (HTTP request)
Web server receives the request (via HTTP) and locates the .htm /.html page in file system
Web server sends HTML stream (response) back across the Internet (via HTTP) to client browser
Browser interprets the HTML and displays the page
CIS 285 ROBINSON WINTER 2005
Web Application – DynamicClient-Side
Server
Client
Web BrowserJVM & JScript, JS
(Interpreters)
Web Server
File System
HTTP Request
HTTP Response
Network
CIS 285 ROBINSON WINTER 2005
Web Application – DynamicClient - Side
Content (some or all) does not exist before a page is requested
Content can be improved with client-side programs such as: JavaScript, VBScript, JScript, Applets
Browsers must provide the appropriate interpreter to execute scripting code (Browser Dependent)
All browsers come with built-in engines – not all have the same engines ( Ex. Netscape cannot interpret VBScript or JScript)
Examples: Current time on your system
CIS 285 ROBINSON WINTER 2005
Web Application – DynamicClient - Side 2
Notes on Applets: Have security constraints which restrict access to
back-end systems
Web browser (or JDK’s appletviewer) uses the HTML document to locate the applet’s byte code files on the Internet or the system’s hard drive
HTML file must contain an <applet> tag
Web browser will then load the JVM, which will load applet’s code into memory – interpret and execute it
CIS 285 ROBINSON WINTER 2005
Web Application – DynamicServer-Side
Server
Client
Web Browser
Web Server
File System
(URL) HTTP Request
HTTP Response
Network
Server-sideScript
Business Logic
Accessdatabase
Result
Result
Server-sideProgramDynamic ReqStatic Req
CIS 285 ROBINSON WINTER 2005
Web Application – DynamicServer - Side
Content (some or all) does not exist before a page is requested
Server-side scripts are executed on the server
Content can be improved with server-side programs such as: CGI, ASP, ASP.NET, JSPs (Servlets) – different ext.
Servers must be equipped with an engine that can interpret the corresponding scripting code
Server-side scripts have Nothing to do with client browsers
CIS 285 ROBINSON WINTER 2005
Server–Side Application NotesFor CGI, ASP & ASP.NET
CGI Compiled, runs fast Difficult to modify and update (recompile program) Not convenient to connect to database Security issues – poor code and tainting
ASP ASP script is contained within HTML tags Using Active control and DLL ASP script itself needs to be interpreted every time it is
requested
ASP.NET Overcomes drawbacks discussed above Limited support - primarily used on Windows platform
CIS 285 ROBINSON WINTER 2005
Web Application – ServletsServer - Side
ServerClient
Web Browser
Web Server Plug-in
Web Container
HTTP Request
HTTP ResponseWeb Server
File System
NetworkStaticResourceRequests
DynamicResourceRequests
DynamicResponse
CIS 285 ROBINSON WINTER 2005
Web Application: Servlets
Servlets are small Java programs that run on a Web server in response to client requests
Servlets generate dynamic content that is sent back to client
Servlets are compiled and represented as .class files
Servlets are loaded either on demand or by the server at start-up
When a servlet is requested from client, a method or function is called in response to the request
CIS 285 ROBINSON WINTER 2005
Web Application: Servlets
Once a servlet has been loaded, it remains in memory until the server decides to remove it or the server is shutdown.
A servlet is loaded either at start-up or upon the first client request to it, and after that, every time a client makes a request to the servlet, the server merely runs a method within the servlet. This dramatically reduces the response time experienced by client.
Servlets are completely written in Java.
Platform independent, server-side modules (components) that are download, on demand, by the system that needs these application components.
CIS 285 ROBINSON WINTER 2005
Web Application: Servlets Many major software vendors currently provide native support
for servlets and JSP within their product:
IBM WebSphere server
BEA WebLogic Application Server
Netscape Enterprise Server
Servlet and JSP engines:
JRUN from Live Software
ServletExec from New Atlanta Communications
Apache Tomcat from the Apache Software Foundation
Support many popular Web servers including Microsoft Internet Information Server (IIS) and Apache (HTTP)
CIS 285 ROBINSON WINTER 2005
Web Application – Servlets
ServerClient
Web Browser
Web Server Plug-in
Web Container
HTTP Request
HTTP ResponseWeb Server
File System
NetworkStaticResourceRequests
DynamicResourceRequests
DynamicResponse
CIS 285 ROBINSON WINTER 2005
Servlet Problem When a JSP page is requested, the first time, it is compiled into its
corresponding servlet
Servlets give poor separation between business logic and presentation logic
If this servlet is responsible for handling all corresponding requests and content from the browser, then the HTML and other content must be embedded in the Java code:
A Java editor must be used
Code must be produced by a Java developer
Application flow and presentation may be “colluded” - limiting reuse, maintenance becomes difficult, and parallel development may be limited or not even possible
CIS 285 ROBINSON WINTER 2005
Web Application: Servlet Problem
Web Container
Request
Response
Servlet
RequestDispatcher – not being utilized
service (req, res)
methods()
forward (req, res)
service (req, res)
CIS 285 ROBINSON WINTER 2005
Web Application Solution for Servlets – JSP Evolution
Web Container
Request
Response
Servlet
RequestDispatcher
JavaServer Page
JavaBean
service (req, res)
service (req, res)
methods()
forward (req, res)
methods()
CIS 285 ROBINSON WINTER 2005
JSP Benefits
Uses HTML / XML tags that encapsulate the logic that generates the content for the page
Application logic can reside on other servers – separation of logic from display
Formatting tags are passed to the response page
Can use JSP technology without having to learn the Java language – ease of administration
CIS 285 ROBINSON WINTER 2005
JSP Benefits
Separates the page logic from its design and display
Supports a reusable component-based design – Web-based applications can be built quickly
Extension of Java Servlet technology Platform independent, enhanced
performance, extensible and easy to use.
CIS 285 ROBINSON WINTER 2005
J2EE Architecture Diagram
Java 2 Platform Enterprise Edition Specification, v1.4 11/24/03 Shannon
CIS 285 ROBINSON WINTER 2005
Resources
http://www.w3.org/MarkUp/ http://www.w3.org/MarkUp/Guide/ http://validator.w3.org/ http://www.w3.org/TR/html401/index/elements.html http://java.sun.com/products/jsp/overview.html http://www.course.com/catalog/downloads.cfm?isbn=0-61
9-06343-2 http://www.brainopolis.com/jsp/book/jspBook_Architecture
s.html
CIS 285 ROBINSON WINTER 2005
Questions?