addressbook using servlets and intro to jsp

20
AddressBook using Servlets and Intro to JSP Lec - 33

Upload: jared

Post on 14-Jan-2016

38 views

Category:

Documents


0 download

DESCRIPTION

AddressBook using Servlets and Intro to JSP. Lec - 33. Servlets Example. A part of Address Book. Design Process. Step 1 – Create a database (AddressBook) Make a table named Person. Design Process. Step 2 – Make a PersonInfo class Three attributes: name, address, ph. No. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: AddressBook using Servlets and Intro to JSP

AddressBook using Servlets

andIntro to JSP

Lec - 33

Page 2: AddressBook using Servlets and Intro to JSP

Servlets Example

A part of Address Book

Page 3: AddressBook using Servlets and Intro to JSP

Design Process Step 1 – Create a database (AddressBook)

Make a table named Person

Page 4: AddressBook using Servlets and Intro to JSP

Design Process Step 2 – Make a PersonInfo class

Three attributes: name, address, ph. No. Has Parameterized constructor Override toString() method

Step 3 – Make a DAO class which contains an establishConnection( ) method a searchPerson(string name) method that

returns PersonInfo object

Page 5: AddressBook using Servlets and Intro to JSP

Design Process Step 4 – Write SearchPerson servlet

Will take input for name to search in address book Submits the request to ShowPerson servlet

Step 5 – Write ShowPerson servlet Recieves request from SearchPerson servlet Instantiate objects of PersonInfo and DAO class Call searchPerson method Show results

Page 6: AddressBook using Servlets and Intro to JSP

package What is package?

Examples: java.lang Javax.swing

How to use package import java.lang.*; import javax.swing.*;

Page 7: AddressBook using Servlets and Intro to JSP

JSP Example

A part of Address Book

Page 8: AddressBook using Servlets and Intro to JSP

JavaServer Pages

Overview

Page 9: AddressBook using Servlets and Intro to JSP

Agenda Introducing JavaServer PagesTM (JSPTM) JSP scripting elements The JSP page Directive Including Files in JSP Documents Using JavaBeans™ components with JSP Creating custom JSP tag libraries Integrating servlets and JSP with the MVC

architecture

Page 10: AddressBook using Servlets and Intro to JSP

The Need for JSP With servlets, it is easy to

Read form data Read HTTP request headers Set HTTP status codes and response headers Use cookies and session tracking Share data among servlets Remember data between requests Get fun, high-paying jobs

But, it sure is a pain to Use those println statements to generate HTML Maintain that HTML

Page 11: AddressBook using Servlets and Intro to JSP

The JSP Framework Idea:

Use regular HTML for most of page

Mark servlet code with special tags

Entire JSP page gets translated into a servlet (once), and servlet is what actually gets invoked (for each request)

Page 12: AddressBook using Servlets and Intro to JSP

What are Java Server Pages? The Java Server Pages technology combine Java code and

HTML tags in the same document to produce a JSP file.

Java <HTML> JSP+ =

Page 13: AddressBook using Servlets and Intro to JSP

Advantages of JSP Over Competing Technologies Versus ASP or ColdFusion

Better language for dynamic part Portable to multiple servers and operating systems

Versus PHP Better language for dynamic part Better tool support

Versus WebMacro or Velocity Standard

Versus pure servlets More convenient to create HTML Can use standard tools (e.g., UltraDev) Divide and conquer JSP developers still need to know servlet programming

Page 14: AddressBook using Servlets and Intro to JSP

JSP/Servlets in the Real World Google:

the world’s biggest search portal

Page 15: AddressBook using Servlets and Intro to JSP

JSP/Servlets in the Real World ofoto.com:

print and manage digital and conventional photos.

Page 16: AddressBook using Servlets and Intro to JSP

JSP/Servlets in the Real WorldFirst USA Bank: largest credit card issuer in the world; most on-line banking customers

Page 17: AddressBook using Servlets and Intro to JSP

JSP/Servlets in the Real WorldDelta Airlines:entire Web site, including real-time schedule info

Page 18: AddressBook using Servlets and Intro to JSP

JSP/Servlets in the Real WorldAmerican Century Investments: more than 70 mutual funds, $90 billion under management, two million investors

Page 19: AddressBook using Servlets and Intro to JSP

JSP/Servlets in the Real World Excite: one of the top five Internet portals; one of

the ten busiest sites on the Web

Page 20: AddressBook using Servlets and Intro to JSP

JSP – The Page becomes a Class Page Compiler

Chunks

Page compiled into a Servlet

First invocation is slow – has to compile

Subsequent invocations more rapid