indy java user’s group march 27, 2001 sallie mae 6:00p.m

27
Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

Upload: hollie-stewart

Post on 23-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

Indy Java User’s Group

March 27, 2001

Sallie Mae

6:00p.m

Page 2: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

Mission Statement

Promote the use of the Java language and components across all levels of interest in the greater Indianapolis area, by serving as a resource for knowledge, experience and career opportunities.

Page 3: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

Agenda

•Pizza Welcome!! 6:00-6:15

•Announcements 6:15-6:30

•Joe Caron 6:30-7:30

•Quality Tip 7:30-7:45

•Performance Tip 7:45-8:00

Page 4: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

Announcements•Next Meeting - April 24, 2002

•Mike Burba – Sun ONE•Java Jam - Kurt Kirkham•Feedback Results•eGroups.yahoo.com

•http://groups.yahoo.com/group/indyJug•http://groups.yahoo.com/group/indyjug_opensource

•BOT Contest – Deadline March 31 •http://developer.digi-net.com

Page 5: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

AnnouncementsCRN – Annual Survey1) Call 1-800-939-62062) Ask for Amy Johnson3) Request your gift –

•Sweatshirt•Cap•T-Shirt

Visit www.metafacts.comVisit www.crn.com

Page 6: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

Presentation Lineup•Mark Steenbarger

•Indy Jug•Joe Caron

•KingArthurFlour.com•Mike Slattery

•SearchSoft.net•Frank Morton

•Base2Inc.com

Page 7: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

JDBC & Servlets/JSP

Joe Caron

Indianapolis Java Users Group

March 27, 2002

Page 8: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

Database access through the web Sample application overview JDBC Fundamentals Servlet/JSP Fundamentals Implementation & sample code Pitfalls, Surprises, Work-arounds

Page 9: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

Sample Application Message Board Membership Based Pass membership info to catalogue

site for “quick check-out” Accumulate “bakers points”

redeemable against online orders Member “recipe box”

Page 10: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

Sample Application JSP for presentation Servlets & other java for app logic MySQL as the RDBMS Tomcat as Servlet/JSP container Linux (Red Hat 6.2)

Page 11: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

Sample Application www.bakingcircle.com Staging Server Entity Relationship Diagram Application Diagram Presentation Diagram

Page 12: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

JDBC Fundamentals Standard means of accessing any

RDBMS for which there is a JDBC driver

Drivers which implement Sun’s JDBC standard capture a DB connection as Java Object

Change DBMS without changing any application code (except driver)

Sun JDBC API overview

Page 13: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

JDBC Fundamentals Key objects

Connection Statement PreparedStatement ResultSet / Rowset ResultSet MetaData DB MetaData

Page 14: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

JDBC Fundamentals Sun JDBC overview Basic Example - MySQL Basic Example - ORACLE Statement vs. PreparedStatement Stand-Alone Example API Documentation JDBC Optional: DataSource

Page 15: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

Servlet/JSP Fundamentals “Servlet Container” (Tomcat, for

example), working in conjunction with Web server (Apache or IIS)

Integrated in J2EE compliant server (BEA, Iplanet, Orion)

Many options regarding both the products and how to set them up

Page 16: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

Servlet/JSP FundamentalsCommon Set-Up

Servlet

Engine

Web

Server

Client

.html &others

.jsp &/servlet/

Redirect based on conf file

Common directorystructure

Page 17: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

Servlet/JSP Fundamentals Servlets like any other Java class,

except: Must extend HttpServlet Must contain a doPost or doGet method Come equipped to handle the laborious

points of http Http requests and responses are made

into Java objects Best alternative to traditional CGI

Page 18: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

Servlet/JSP Fundamentals Anatomy of a Servlet

Optional init method, executes the first time a servlet is invoked

doGet/doPost methods execute when request is made

method signature accepts http request and response as parameters

Optional destroy method www.servlets.com Samples

Page 19: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

Servlet/JSP Fundamentals One instance of Servlet for each

Servlet name Same instance serves all requests

to that name Instance members persist across

all requests to that name. Local /block variables in doPost &

doGet are unique to each request

Page 20: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

Servlet/JSP Fundamentals Instance members vs

local variables Major request and response

methods More major request and response

methods Making use of servlet context Keeping sessions: the bane of all

Web programming

Page 21: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

JSPs: Servlets in disguise...

Better alternative for presentation. Insert special brackets into HTML

page to mark off Java code. A JSP is compiled into a Servlet

the first time it is called. Crash course in JSP syntax

Page 22: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

JSP as presentation model

ServletPerforms the

hard work

Client

request

JSP

Successful

results

Helper objectsPersistent “bean” objectsDB Connections, etc

JSP

Unsuccessful

results

App logic

Presentation Subsequent client

request

Simple calls to bean properties

No servlet need if bean

still set

Page 23: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

JSP alternatives

JSP can still result in unwieldy code creeping into HTML

Most HTML editors don’t like it JSP:Taglibs and other “templating”

programs may help. Much depends on how HTML

documents are produced and what business logic you are presenting

Page 24: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

In Depth Examples Encapsulation of SQL calls List results and view thread detail Post reply and add to favorites Set all bean properties w/ request Edit users Query central

Page 25: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m

Pitfalls, surprises, and work-arounds

HTTP works via requests and responses. Client caching of responses poses a problem.

Guard against evil use of the “back” button

Don’t assume everyone’s client will respond properly to the “defaults”

Guard against easy spoofs of any GET request which alters data.

Page 26: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m
Page 27: Indy Java User’s Group March 27, 2001 Sallie Mae 6:00p.m