30
CSCI 6962: Server-side Design and Programming Course Introduction and Overview

CSCI 6962: Server-side Design and Programming

  • Upload
    etana

  • View
    51

  • Download
    0

Embed Size (px)

DESCRIPTION

CSCI 6962: Server-side Design and Programming. Course Introduction and Overview. Topics. Introduction to Client-Server Web Architectures Java Server Faces and Active Server Pages Problems and Topics in Server-side Programming Programming Assignments. Client-Server Web Architecture. - PowerPoint PPT Presentation

Citation preview

Page 1: CSCI 6962:  Server-side Design and Programming

CSCI 6962: Server-side Design and Programming

Course Introduction and Overview

Page 2: CSCI 6962:  Server-side Design and Programming

Topics• Introduction to Client-Server Web Architectures• Java Server Faces and Active Server Pages• Problems and Topics in Server-side Programming• Programming Assignments

2

Page 3: CSCI 6962:  Server-side Design and Programming

3

Client-Server Web Architecture• Client browser sends request for page to server

– May contain form data and other information

• Server sends response page and sends to client• May need to generate response page dynamically

– Form parameters– Previous requests (such as items purchased so far)– Information in database

Focus of this course

Page 4: CSCI 6962:  Server-side Design and Programming

4

Client-Server Web Architecture

ClientBrowserwww.csis.ysu.edu/~john/Syllabus.html

Request to www.csis.ysu.edu for Syllabus.html

Server

john public_html

port

Response containing Syllabus.htm as a long string (<html><head><title>CSCI 6962 Syllabus</title> </head><body>…)

Syllabus.html

Page 5: CSCI 6962:  Server-side Design and Programming

5

Dynamic Form Handling• Form data appended to request string

Generates the request:http://www.cis.ysu.edu/~john/cgi-bin/test.pl&quantity=3

<FORM NAME="purchaseform" METHOD=GET ACTION=http://www.csis.ysu.edu/~john/cgi-bin/test.pl >

Quantity: <INPUT TYPE="text" NAME="quantity" /><BR /><BR />

<INPUT TYPE="submit" VALUE="SUBMIT">

/FORM>

Page 6: CSCI 6962:  Server-side Design and Programming

6

Form HandlingServer must:

– Listen on port for requests– Parse request to determine values of parameters– Dynamically generate appropriate response page based on

parameter values– Send response page back to client

Page 7: CSCI 6962:  Server-side Design and Programming

7

Web Containers• Program running continuously on server• Runs code to handle requests• Built-in methods for parsing requests, generating

responses• Handles other important functions:

– Session tracking– Database access– Email generation– Security and encryption– …

Page 8: CSCI 6962:  Server-side Design and Programming

8

Web Containers

Client

Browser

Server

Port

http://homer.cis.ysu.edu/reciept.jsp&quantity=3

Web Container

Constantly running in background

Listen on portExecute code in requested server pageGenerate corresponding html page

<HTML><HEAD><TITLE>cgi-bin response</TITLE></HEAD><BODY><P>Thank you for your order of <%= request.getParameter(“quantity”) %>widgets!</P></BODY></HTML>

Page 9: CSCI 6962:  Server-side Design and Programming

9

Web Containers• Glassfish

– Written in Java – Built on Apache Tomcat– NetBeans IDE– Acts as engine for Java servlets, Java Server Pages and Java

Server Faces

• Microsoft Internet Information Server (IIS)– Visual Basic/C#– Acts as engine for Active Server Pages

Page 10: CSCI 6962:  Server-side Design and Programming

Server-side Evolution• Servlets

– Programmatically generating response page

• Server pages– Inserting dynamically generated code into web page– Goal: separate web design and dynamic code

• Server faces/Active server pages– Directly linking client-side form elements to server-side

objects (JavaBeans)– Goal: separate web page development from underlying

business logic 10

Page 11: CSCI 6962:  Server-side Design and Programming

Java Servlets

11

Get quantity from request

Create output to response

Write response page as string to output with quantity inserted

Page 12: CSCI 6962:  Server-side Design and Programming

12

Java Server Pages

Java code executed inside web page

Resulting value inserted into html

Page 13: CSCI 6962:  Server-side Design and Programming

Java Server Faces• Use managed beans to control information

– Data storage between pages– Computation methods (total bill, taxes, etc.)– Validation methods (positive quantity, items available)– Long-term storage (database read/write of orders)

13

JSF web page JSF managed bean

Web design team Business logic team

Page 14: CSCI 6962:  Server-side Design and Programming

Java Server Faces

14

Bean stores quantity

Getters and setters to allow access

Page 15: CSCI 6962:  Server-side Design and Programming

Java Server Faces

15

XML tags specific to JSF

Input bound to quantity property of bean

Page 16: CSCI 6962:  Server-side Design and Programming

Java Server Faces

16

widgetBean

quantity: 33

Page 17: CSCI 6962:  Server-side Design and Programming

17

Active Server Pages• Active Server Page approach:

Create “form” which is translated to html

Page 18: CSCI 6962:  Server-side Design and Programming

18

Active Server Pages• Server-side code manipulates “form elements”

– Subroutine called when page submitted– Data read from elements (actually request string)– Used to set value of other elements

Page 19: CSCI 6962:  Server-side Design and Programming

19

Active Server Pages• Resulting form translated to response page

Page 20: CSCI 6962:  Server-side Design and Programming

Why Two Platforms• Both widely used in practice

– Other platforms (Springs, Ruby, etc.) based on JSF model• Different approaches but common ideas

– Same underlying representation– Same best practices for web site design

20

Page 21: CSCI 6962:  Server-side Design and Programming

Other Major Topics• Session management• Modular web site design• Validation and error handling• Database manipulation• AJAX client-server communication• Security

21

Page 22: CSCI 6962:  Server-side Design and Programming

22

Session Handling• Most web transactions are sessions consisting of

series of requests and responses• Must associate steps if multiple clients

Who submitted this request?

Page 23: CSCI 6962:  Server-side Design and Programming

Modular Web Pages• Most pages on same

site have similar content,layout, etc.

• Goal: Write once, include in all pages

• Tools:– Facelets (Java)– Master Pages (ASP)

23

Page 24: CSCI 6962:  Server-side Design and Programming

24

Form Validation

• Detecting user error– Built-in validation tools

• Correcting user error– Providing information or how to correct error

• Preventing user error– Field types/values – Error tolerance

Page 25: CSCI 6962:  Server-side Design and Programming

25

Database Manipulation• Database driver provides access to databases• Built-in tools to manipulate/display data

– JDBC: classes to query/manipulate database– Java Persistence API beans– ASP Data Source objects

web container

JPA bean

JSFpage database

database driverJDBC DBMS

database server

Page 26: CSCI 6962:  Server-side Design and Programming

26

AJAX• Asynchronous JavaScript and XML • Based on JavaScript running in browser

– JavaScript code sends data to server, reads response– Response is simple data instead of entire page – JavaScript code then modifies page without re-rendering it completely

Method call

Web Page

Server

Return valueJavaScript

Page 27: CSCI 6962:  Server-side Design and Programming

Web Site Security

• SSL/TLS for encryption• Certificates for server authentication• Secure programming against attacks

– SQL injection– Cross-site scripting

27

Request Server

Response

Client

Certificate

database

database server

Page 28: CSCI 6962:  Server-side Design and Programming

Programming Assignments• Introductory Assignments

– Simple Java Server Faces web site– Simple Active Server Pages web site

• Web Site Project (four parts)– Modular user interface design– Validation and error handling– Database access– Shopping cart and other support objects

28

Page 29: CSCI 6962:  Server-side Design and Programming

Web Site Project• “E-Commerce” site of your design• You choose platform (JSF or ASP)

29

List of products

List of productsList of

productsList of products

IndividualProduct

pages with “add” option

“Cart” of added

products

Shipping/payment/

etc. information

\Database of products and orders

Page 30: CSCI 6962:  Server-side Design and Programming

30

Background Knowledge• Java or C++ (for JSP)

– May want to get Java reference– I will cover basics in class

• Visual Basic or C# (for ASP)– Basics covered in class– If more familiar with C# can get corresponding text

• Basic html (including forms and tables)• Basic SQL