electronic commerce on business application

178
University of Nebraska at Omaha University of Nebraska at Omaha DigitalCommons@UNO DigitalCommons@UNO Student Work 11-1-1999 Electronic Commerce on Business Application Electronic Commerce on Business Application Fang Xiao University of Nebraska at Omaha Follow this and additional works at: https://digitalcommons.unomaha.edu/studentwork Recommended Citation Recommended Citation Xiao, Fang, "Electronic Commerce on Business Application" (1999). Student Work. 1213. https://digitalcommons.unomaha.edu/studentwork/1213 This Thesis is brought to you for free and open access by DigitalCommons@UNO. It has been accepted for inclusion in Student Work by an authorized administrator of DigitalCommons@UNO. For more information, please contact [email protected].

Upload: others

Post on 01-Jan-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

University of Nebraska at Omaha University of Nebraska at Omaha

DigitalCommonsUNO DigitalCommonsUNO

Student Work

11-1-1999

Electronic Commerce on Business Application Electronic Commerce on Business Application

Fang Xiao University of Nebraska at Omaha

Follow this and additional works at httpsdigitalcommonsunomahaedustudentwork

Recommended Citation Recommended Citation Xiao Fang Electronic Commerce on Business Application (1999) Student Work 1213 httpsdigitalcommonsunomahaedustudentwork1213

This Thesis is brought to you for free and open access by DigitalCommonsUNO It has been accepted for inclusion in Student Work by an authorized administrator of DigitalCommonsUNO For more information please contact unodigitalcommonsunomahaedu

Electronic Commerce on Business Application

A Thesis

Presented to the

Department of Computer Science

and the

Faculty of the Graduate College

University of Nebraska

In Partial Fulfillment

of the Requirements for the Degree of

Master of Science

University of Nebraska at Omaha

By

Fang Xiao

Novermber 1999

UMI Number EP73453

All rights reserved

INFORMATION TO ALL USERS The quality of this reproduction is dependent upon the quality of the copy submitted

In the unlikely event that the author did not send a complete manuscript and there are missing pages these will be noted Also if material had to be removed

a note will indicate the deletion

D issertation RyblisMrtg

UMI EP73453

Published by ProQuest LLC (2015) Copyright in the Dissertation held by the Author

Microform Edition copy ProQuest LLCAll rights reserved This work is protected against

unauthorized copying under Title 17 United States Code

ProQuest LLC789 East Eisenhower Parkway

PO Box 1346 Ann Arbor Ml 48106 - 1346

THESIS ACCEPTANCE

Acceptance for the faculty of the Graduate College

University of Nevraska in partial fulfillment of the

Requirements for the degree of Master of Science

University of Nebraska at Omaha

Committee

DepartmentSchoolName

Chairperson_

Date rdquo l l - l l - i m

Acknowledgements

I would like to express my sincere appreciation to my thesis advisor Professor Peter A

NG for his kind guidance time and support I would also like to say thank you to my

supervisory committee Dr Qiuming Zhu Dr Bin Chen for their suggestions help and

cooperation

Abstract

For some time now Whole size business enterprises have used electronic commerce

to conduct their business activities The On-Line store is one of a number of popular

web applications This thesis focuses on one of the emerging On-Line store

technologies which is known as Server-Side Java Application

In early 1960 private networks were dedicated for the use of electronic data

interchange (EDI) and electronic funds transfer (EFT) in banking business Recently

however with the increased awareness and popularity of the Internet electronic

commerce has come to encompass individual consumers as well as businesses of all

size For most people electronic commerce is defined as the buying and selling of

products and services over the Internet but there are many more aspects We will

discuss different definitions of electronic commerce in this paper

The most popular Web applications are the On-Line Stores Most of such applications

involve functions as searching for product information ordering products paying for

goods and services and for providing online customer service A Web server running

continuously accepts userrsquos connection gets user requests and forward requests to

business procedure retrieves data (answers to user requests) from business procedure

and sends it back to the user

An on-line store system is different from a traditional web publishing It needs a

customerrsquos interactive communication and frequent data update The traditional

HTML page does not satisfy the customerrsquos needs because all it does is simply

publish static contents More complex technologies are required in order to produce

dynamic contents

There are a few technologies that can be used for implementing the on-line stores

Common Gateway Interface (CGI) Microsoft Active Server Page (ASP) and Server-

side Java application are the most popular technologies Introducing the Server-Side

Java application is one of the latest and most exciting trends in Java programming

The Server-side Java application has many advantages over the other technologies

Table of Contents

Chapter 1 Introduction 1

Chapter 2 Electronic Commerce 2

21 What Is Electronic Commerce2

22 The Importance of Electronic Commerce3

23 Types of Electronic Commerce3

24 Why Most Internet Based Electronic Commerce Is In

The Business-To-Consumer W orld 6

25 Current State of Business-To-Consumer E-Commerce7

26 The Structure of The On-Line Store8

Chapter 3 Technologies For On-Line Store System11

31 Traditional Web Application - Common Gateway Interface(CGI) 11

32 Active Server Page 12

33 Server-Side Java Application 14

Chapter 4 Design of On-Line Bookstore Using Java Servlets

A Practical Verification18

41 The Design of Home Page of Tiny Book Store18

42 Design of Search by Different Requests27

43 Servlets Chaining To Process Requests In Different Levels28

44 Database Connectivity and Search from Database29

45 Session Tracking 35

46 Check O ut42

47 Customer Information Processing 43

Chapter 5 Future Work50

51 Connection Pooling50

52 More Object-Oriented - Better Encapsulation51

Chapter 6 Conclusion 53

Appendix A Bibliography54

Appendix B The Source Code of An On-Line Store System -

Tiny Book Store57

Appendix C Screen Display of the Test 135

List of Figure

Figure 261 The Structure of An Online Store 10

Figure 321 Handle Requests Flow Chart 13

Figure 331 HttpService of The Java Web Server Using Servlets 15

Figure 411 The Home Page of Tiny Book Store 22

Figure 412 One of The Searching by Author Pages26

Figure 441 One of The Outputs of Servlet AuthorProces 34

Figure 451 A Page Show All Information About A Book 39

Figure 452 A Page Show Items In The Shopping Cart After A User

Added Books To The Shopping Cart 40

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A

Book From The Shopping Cart42

Figure 461 A Check Out Page 43

Figure 471 An Invoice Page48

1

Chapter 1

Introduction

As we step in the year 2000 we can no longer look to the past as the guide for the

future A combination of business social and technical possibilities drives the rapid

progress in electronic commerce

Electronic commerce can offer a company both short-term and long-term benefits

Not only can it open new markets enabling a business firm to reach new customers

but it can also make it easier and faster for the firm to do business with their existing

customer base Moving business practices such as ordering invoicing and customer

support to network-based systems can also reduce the paperwork involved in

business-to-business transactions When more of the information is digitized it

allows that business firm to focus on meeting their customerrsquos needs Tracking

customer feedbacks and presenting customer solutions for their clientele are just

some of the opportunities that can stem from electronic commerce

2

Chapter 2

Electronic- Commerce

21 What Is Electronic Commerce

For some time now large business enterprises have used electronic commerce to conduct

their business-to-business transactions In early 1960 private networks were dedicated

for the use of electronic data interchange (EDI) and electronic funds transfer (EFT) in the

banking industry Recently however with the increased awareness and popularity of the

Internet electronic commerce has come to encompass individual consumers as well as

businesses of all size

To many electronic commerce is defined as the buying and selling of products and

service over the Internet But there are many other aspects Depending on whom you ask

electronic commerce has different definitions

From a communications perspective electronic commerce is the delivery of information

productsservices or payments via telephone lines computer networks or any other

means From a business process perspective electronic commerce is the application of

technology toward the automation of business transactions and workflow From a service

perspective electronic commerce is a tool that addresses the desire of firms consumers

and management to cut service costs while improving the quality of goods and increasing

3

the speed of service delivery From an online perspective electronic commerce provides

the capability of buying and selling products and information on the Internet and other

online services [16]

These definitions are valid with their perspectives It is a matter of which lens is used to

view the electronic commerce landscape Broadly speaking electronic commerce

emphasizes the generation and exploitation of new business opportunities by ldquogenerating

business valuerdquo or ldquodoing more with lessrdquo

22 The Importance of Electronic Commerce

As we approach the year 2000 we can no longer look to the past as guide to the future In

the face of strong market forces created by electronic commerce and mounting

competition corporations can no longer plod along historical tracks or seek the

preservation of the status quo Companies are discovering that old solutions do not work

with new problems The business parameters have changed and so have the risks and

payoffs

23 Types of Electronic Commerce

From a broad view there are three distinct general classes of electronic commerce

applications Inter-organizational (business-to-business) intra-organizational (within

business) and customer-to-business application [16]

4

231 Inter-Organizational Electronic Commerce

Inter-organizational electronic commerce makes business more convenient on the

following aspects

Firstly e-commerce can improve supplier management since electronic applications can

reduce the processing costs and cycle times for each purchase order and it can reduce the

number of people who work on purchase orders

Secondly e-commerce can improve inventory management since electronic applications

make the business partners can fast exchange information and easy track their documents

to ensure that they were received This not only can eliminate out-of-stock occurrences

but also can reduce inventory and improve inventory turn

Thirdly e-commerce can improve distribution management since electronic applications

can make the business partners receive the shipping documents as soon as possible and

enable better resource management by ensuring that the documents contain more accurate

data

Fourthly e-commerce can improve channel management since electronic application can

let the business partner post the information to electronic bulletin boards This can

eliminate repeated telephone calls and countless labor hours

Fifthly e-commerce can improve payment management since the business partner are

linked by network so the payments can be sent and received electronically Electronic

payment is more accurate and fast than traditional payment

232 Intra-Organizational Electronic Commerce

5

Intra-organizational electronic commerce facilities the following business applications

Workgroup communications Electronic applications enable manager to

communicate with employees using electronic mail videoconferencing and

bulletin boards

Electronic publishing Electronic applications enable companies to publish

information by using tools such as the World Wide Web On-line publishing can

show information immediately and clearly and reduce costs for printing and

distributing documentation

Sales promotion Electronic application improve the flow of information between

the production and sales forces and between the firms and customers This can

make companies have greater access to market and competitor information

Today Intranets are primarily set up to publish and access vital corporate information

Some of the most common types of information are Human Resources information

employee communications product development and project management data internal

catalogs sales support data equipment and shipment tracking and accessing corporate

database

233 Consumer-To-Business Electronic Commerce

In consumer-to-business transactions customers learn about products through electronic

publishing buy products with electronic cash and other secure payment systems and

even have information goods delivered over the network

6

From the consumerrsquos perspective there are three transactions

1 Electronic applications enable consumers to communicate with each other through

electronic mail videoconferencing and news groups

2 Electronic applications enable consumers to manage investments and personal finances

using online banking tools

3 Electronic application enable consumers to find online information about existing and

new products services

Consumers consistently demand greater convenience and lower prices Electronic

commerce provides consumers with convenient shopping methods from online catalog

ordering to phone banking both of which eliminate the costs of expensive retail

branches Electronic commerce facilitates factory orders by eliminating many

intermediary steps thereby reducing manufacturersrsquo inventory and distribution costs and

indirectly providing consumers with lower prices

24 Why Most Internet Based Electronic Commerce Is In The Business-To-

Consumer World

For the Business-to-Business e-commerce the lack of well-accepted standards is

hindering the success in promoting Business-to-Business electronic commerce

solutions[5] VAN (Value-Added Networks) EDI (Electronic Data Interchange) based

solutions are only accessible to large organizations due to the cost factor Corporate

buyers and suppliers large and small are looking for Internet based solutions to

streamline the procurement procedures and to reduce the cost of establishing trading

relationship and the trading transactions Such demands put forward some fundamental

challenge on issue like trust infrastructure on the Internet standards and inter-operability

etc

25 Current State of Business-To-Consumer E-Commerce

Business activity on the Internet is currently limited to publicizing the business

opportunity and to catalog based sales but it will rapidly expand to include the

negotiations conducted to settle the price of the goods or commodities being traded

These negotiations are currently conducted by human intermediaries through various

forms of auctions bidding systems for awarding contracts and brokerages The role of

the intermediaries can now be performed by Internet trading applications at a fraction of

the cost[4] Trading on the Internet allows a business to reach a large number of potential

customers and suppliers in a shorter time and a lower cost than possible by other modes

of communication and to settle business transaction with lower cost overhead in a shorter

time

Auctioned or brokered sales are the norm in business world for negotiating trades of large

monetary value But consumer sales and small-scale purchases have used the fixed price

mode perhaps because of the high overhead cost of using the auction or brokerage

method The new economics of the Internet will make auctions popular in consumer and

small business transactions also

Auctions are just one form of business negotiations Other examples are competitive bids

for procurement brokeragesexchangescartels and two party negotiations

Nowadays the free-market economy of software agents is in the embryonic stage But in

the near future the software agents will populate the Internet and provide trade and use

a rich variety of information goods and services in an open free-market economy In a

free-market economy of software agents information is produced traded and consumed

by vast numbers of autonomous self-motivated agents An essential task in such an

economy is the retailing or brokering of information gathering it from the right

producers and distributing it to the right consumers[10] The overall research goal is to

characterize and understand the dynamic behavior of information economies very large

open economies of automated information agents that are likely to come into existence in

the Internet

26 The Structure of The On-Line Store

9

Nowadays there are thousands of on-line stores running on the Internet A few well-

known ones are amazoncom and bookpoolcom Most of such applications involve

common functions which are as following

Searching for product information

Ordering products

Paying for goods and services

Providing online customer service

So they have a similar structure as shown in Figure 261 The system contains the

following components

1 A web server running continuously accepts userrsquos connection gets user requests and

forward requests to business procedure retrieves data (answers to user requests) from

business procedure and send it back to user

2 Business procedure usually consists of a user identification procedure like credit card

check user request analysis procedure analyzing requests calculating discomposing (if

necessary) and dispatching request to different data source component Also in some

case business procedure is responsible to compose data obtained from different data

sources into user-readable format

3 Database is the place to hold relevant data These data not only serve as a data source

describing commercial goods and prices but can be used for data mining to improve

store service quality as well Database is updated and maintained by both customersrsquo

input and system applications A customerrsquos input usually includes order information

10

Figure 261 The Structure of An Online Store

(through browser)

Databas

(through browser)client

client

serverWeb

Systemapplication

Busines

procedu

4 System applications can include a search engine running all the time and searching

relevant information from the internet data mining application deals with mining and

analyzing customer and sale data for management use database maintaining application

handles update data when product information changes Varying from system size to

system size not every system has cleardistinct boundaries between these components

The system can be 3-tired or n-tired but these systems all operate in similar ways

11

Chapter 3

Technologies For On-Line Store System

An on-line store system is different from traditional web publishing It needs customerrsquos

interactive communications and frequent data update The traditional HTML page is

insufficient because all it does is provide static content publishing Other technologies

are required in order to implement the on-line store

Currently there are three mainstream technologies which are widely used Common

Gateway Interface (CGI) Microsoft Active Server Page (ASP) and Server-side Java

application We briefly explore these technologies here

31 Traditional Web Application - Common Gateway Interface (CGI)

The common Gateway Interface normally referred to as CGI is one of the first practical

techniques for creating dynamic content With CGI a web server passes certain requests

to an external program The output of this program is then sent to the client in place of a

static file The advent of CGI makes it possible to implement all sorts of new

functionality in web pages and CGI quickly become a defacto standard implemented on

dozens of web servers Even though a CGI program can be written in almost any

language the Perl programming language is the predominant choice However CGI have

some distinct disadvantages

Firstly CGI program is transient A request is made each time to a CGI program It must

be loaded and executed by the Web server When the CGI program is complete it is

removed from memory and the results are returned to the client All program

initialization (such as connecting to a database) must be repeated each time a CGI

program is used

Secondly when a server receives a request that accesses a CGI program it must create a

new process to run the CGI program and then pass to it via environment variables and

standard input Every bit of information might be necessary to generate a response

Creating a process for every such request requires time and significant server resources

which limits the number of requests a server can handle concurrently

Thirdly a CGI program cannot interact with the web server or take the advantage of the

serverrsquos abilities once it begins execution because it is running in a separate process

32 Active Server Page

As shown in figure 321 the following list walks you step-by-step through what

happens if the client requests the page xyzasp

The client requests the page xyzasp from the server The Web server checks the file

extension to see whether a special program (such as the Active server Pages engine)

13

must be invoked to process the request If therersquos a asp extension the Web server

determines that it should invoke ASP to process this page

Figure 321 Handle Requests Flow Chart

Request

Response

WEB SERVERComponents

Databas

ns

ASP File

CLIENT

Active X Data

VBScript

If this page has never been requested before or has been changed since the last

request it must be parsed and the syntax checked and then be compiled by the Web

server Otherwise the page might be read from a cache of recently processed pages

which aids in performance During the parsing process the HTML and scripting code

14

are separated IIS (Internet Information Server) determines which scripting engine is

responsible for which part of the script and delegates the work of syntax checking and

compiling to the proper scripting engine (such as VB Script)

Now the code is executed by the scripting engine using resources from IIS which is

hosting the scripting engines All objects that the language engine cannot handle are

requested by the IIS which is also responsible for handling inputs and outputs for the

external ActiveX objects that are created and used inside the script If it is not able to

supply the object an error is generated

Script output and static HTML code in the ASP file are merged

The final HTML is sent back to the user in an HTTP response

The important point about ASP is that the Script runs entirely in a server to protect the

intellectual property by shielding it from browser which are different from the account

for when writing client-side code The entire server-side code is processed and only plain

HTML - or whatever kind of content you chose to generate - is sent to the client

33 Server-Side Java Application

The rise of server-side Java applications is one of the latest and most exciting trends in

Java programming A Servlet can be thought of as a server-side applet Servlets are

loaded and executed by a Web server in the same manner that applets are loaded and

executed by a Web browser

15

As shown in Figure 331 a servlet accepts requests from a client (via the Web server)

performs some task and returns the results

The client (mostly likely a Web browser) makes a request via HTTP The Web server

receives the request and forwards it to the servlet If the servlet has not yet been loaded

the Web server will load it into the Java virtual machine and execute it The servlet will

receive the HTTP request perform some type of process and return a response back to

the Web server The Web server will forward the response to the client

Figure 331 HttpService of The Java Web Server Using Servlets

RequestResponseRequestResponse

RequestResponse

Java Web Server

Administrative SERVLET

SERVLETHTTP

SERVLETWeb Proxy

Servlets have distinct advantages over CGI program

Servlets are persistent Servlets are loaded only once by the Web server and can

maintain services (such as a database connection) between requests

Servlets are fast since servlets only need to be loaded once

16

Servlets are platform independent Servlets are written in Java and conform to a well-

defined and widely accepted API They are highly portable across operating systems

and across server implementations A servlet can be developed on a Windows NT

machine running the Java Web Server and later can be deployed effortlessly on a

high-end Unix server running Apache

Servlet portability is not the stumbling block it so often is with applets There are two

reasons Firstly servlet portability is not mandatory Unlike applets which have to be

tested on all possible client platforms servlets have to work only in the server

machines that you are using for development and deployment Unless you are in the

business of selling your servlets you donrsquot have to worry about complete portability

Secondly servlets avoid the most error-prone and inconsistently implemented portion

of the Java language the Abstract Windowing toolkit (AWT) that forms the basis of

Java graphical user interfaces

Servlets are extendable Servlets that are written in Java brings all of the other

benefits of Java to servlet Java is a robust object-oriented programming language

which can be extended easily to suit our needs

Servlets are secure The only way to invoke a servlet from the outside world is

through a Web server This brings a high level of security especially if the Web

server is protected behind a firewall

Servlets can be used with a variety of clients

Servlets are tightly integrated with the server This integration allows a servlet to

cooperate with the server For example a servlet can use the server to translate file

paths to perform logging and to check authorization

Servlets are quite flexible An HTTP servlet can be used to generate a complete web

page it can be added to a static page using a ltSERVLETgt tag in whatrsquos know as a

server-side include and it can be used in cooperation with any number of other

servlets to filter content in something called a servlet chain

18

Chapter 4

Design of On-line Bookstore Using Java Servlets A Practical

Verification

Server-side Java application is one of the latest technologies used to implement an onshy

line store system Servlet is a set of classes that come up from Java language It is

designed to be used for server-side Java applications There are many techniques people

can use when they utilize servlet such as Server-Side Include (SSI) Servlet Chaining

Applet and Servlet communication etc We tried to use as many such techniques as

necessary in our implementation to demonstrate the advantages of servlets

The demonstration system module is same as the one we mentioned above Figure 331

We use this module to show how such system works

The system called Tiny Book Store emulates an on-line bookstore selling computer

books It has the full functionality of other on-line stores The only difference between

this system and the other on-line systems is the database size We donrsquot want to spend

much developing time for database maintaining part because this part is similar to

ordinary database maintaining and it is an independent subsystem The Tiny Book Store

mainly consists of three modules user interface business procedure and data access

19

41 The Design of Home Page of Tiny Book Store

The home page - welcome page - is designed using the Server-Side Include technique

That is embedding a servlet inside HTML file with a specific HTML tag ltSERVLETgt

In our case this servlet when invoked can run a query on database via data access

objects to retrieve most recent top 5 best-seller books and then returns the retrieved data

to the place within the page where the ltSERVLETgt tag was As long as the data in

database update timely it is guaranteed that customer will get the most recent data

The embedded servlet is invoked by Java Web Server before the page is sent back to

client Java Web Server processes any HTML file having shtml extension and invokes

the embedded servlet marked by ltSERVLETgt tags

Server-Side Includes are useful when a page is primarily static but contains a few distinct

dynamic portions One of the servlets produces the ldquo Five Hot Books ldquo which is shown in

the following example

Example 411 A Part of Code of welcomeshtml

lt P gt

lth3xstrongxf ont color= f f 6347 gtWelcome to theltigt

TinyBookStorecomltigtltfontgtltstronggtlth3 gt

20

ltstrongxbxh3gtltcentergtFive Hot

Booksltc e n t e r x h3gtltbgtltstronggt

ltbrgt

ltservlet code=EchoServletTaggt

ltservletgt

The servlet EchoServletTag searches database according to some business rule and gets

data from data access objects to produce the Five Hot Books The following example is

the sample code

Example 412 A Part of Code of The EchoServletTagjava

public void service(HttpServletRequest req

HttpServletResponse res)

throws ServletException IOException

res setContentType ( text Jhtml)

PrintWriter out = resgetWriter()

try

Statement stmt = concreateStatement()

21

ResultSet rs = stmtexecuteQuery(select from

book where

title like Programming)

int count = 1

outprintln(ltdlgt)

while (rsnext() ampamp count lt 6)

out print In ( ltdtxbgt + count + )

String isbn =

rsgetObj ect(ISBN) toString()

outprintln(lta

href=servletDetailContent + isbn +

outprintln(rsgetObj ect(Title) toString()

+ lt a x bgt )

out println ( ltddxnobrxfont color=990033gtUsuallY

ships in 24 hoursltBRxfontxnobrgt )

outprintIn(ltbrgt +

rsgetObject(Author) toString() )

outprintIn( +

r s getObject(Publisher)toString() + +

r s getObj ect(PublicationDate) toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

out println ltbrxbrgt )

22

count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()

The servelt EchoServletTag by the business mle that searching a specific table sends a

request query through data access object stmt and gets search result through another

data access object rs It then passes data to the page The content between ltservletgt and

ltservletgt tags in the HTML of home page is replaced by the search result at run time

The center part of the sample result page in Figure 411 is an example

23

Figure 411 The Home Page of Tiny Book Store

gj Search TinybookstGiecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

^ bullgt o a 4 i a a j ugt- a a Back lt7gtn Stop Refresh Home j Search Favorites History Mail Print Etfe

-Six

sfekinlfeSsI 3 Address |iS1 httpiVlocalhosLSOSCVwelcomeshtrnl Cj

f S M B l TinyBookStorecom

Search B o o k sW e l c o m e tc f l i e

HomeFive H ot Books 1 1

Category i-si

IA uthor

Title1 The C + + Programming L a n g u a g e B

Usually ships in 114 hoursISBN

k

IPublisher D a teBjame Stroustrup Addis on-Wesley Pub Co 1997Our Price 3147

m2 Programming Visual C+ +

Usually ships in 24 hours y

David J Krn^dinski Dlicrosoft Press 1998 c damp Local intranet

From this practice we know Server-Side Include not only can produce dynamic portion

of the page but also prevent from other people spy into your code Since Java servlet runs

entirely on a server thus protecting your intellectual property and shielding you from the

browser This means what the client sees can be totally different from what the server

does From the client side it is difficult to figure out how the server works

The left-hand menu items are implemented by using a characteristic of servlet - extra

path information or virtual path The extra path information can be used as a kind of

parameter passed to a servlet In general this extra path information is used to indicate a

24

file on the server that should use for something We use this feature here in an abnormal

way to manage customer requests and process these requests in a single place

Consider a traditional method When a menu item is selected by a customer it redirects

the customer to another page where it hyperlinks to If we have several ten items we

need to pre-create several ten pages This is the disadvantage of static HTML pages

However with servlet which can dynamically generate page content we can direct all the

customer requests to a central servlet and process the requests there according to some

condition (parameters) and then generate the page which customer need to see In this

way we only need one place to hold the code to save serverrsquos space And this place is

easy to maintain

The following is how it was doing for the Tiny Book Store

The Author item uses the following hyperlink

ltA

href = servlet ReqCo 11 ect author gtAuthorlt fontx AxTDgt

ltTRgt

The ReqCollect is the name of a servlet We pass the ldquoauthorrdquo in the hyperlink as a

parameter to ReqCollect When the Author item is selected ReqCollect is invoked by

lava Web Server ReqCollect generates a html page to let a user input author search

condition The ReqCollect code is listed below

25

Example 413 A part of Source Code of ReqCollectjava

public class ReqCollect extends HttpServlet

protected final String AUTHOR = author

public void service(HttpServletRequest req

HttpServletResponse res) throws ServletException

IOException

PrintWriter out = resgetWriter()

String path = reqgetPathlnfo ()

if (path == null)

error handling

else

Create standard header

CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

26

path = pathsubstring(1)

if (pathequalsIgnoreCase(CATEGORY))

Create category request collect

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

outprintln(ltfont color=CC66 0 0

face-verdana arial helvetica size = + lxbgtEnter

Authorltbgtltfontgt )

outprintln(ltbrgt You can enter

authors full name first name or last nameltpgt)

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess

id=forml name=formlgt)

outprintln(lttable border=0gt)

outprintln(lttrgt lttd valign=middle

align = lef txttgtltbgtAuthor ltbxttxtdgt )

outprintln(lttd valign=middle

align = lef txinput type = text name= author size = 40

value=x tdgt )

outprintln(lttrgt)

27

outprintln(lttrgt lttd colspan=2gt ltfont

size=-lgt)

outprintln(ltcentergt ltinput

type=radio name=author_mode value=exact

checkedgt Exact Name)

outprintln(ltinput type=radio

name=author_mode value=lastgtLast First Name (or

Initial) )

outprintln(ltcentergt)

outprintln(ltfontgt)

outprintln(lttdgt lttrgt)

outprintln(lttrgt lttd colspan=2gt ltpgt

ltbrgt lttdgt lttrgt)

outprintln(lttablegt)

outprintln(ltcentergt)

outprintln(ltinput type=submit

value=Search Now id=submitl name=submitlgt)

outprintln(cinput type=reset

value=Clear Form id=resetl name=resetlxpgt )

outprintln(ltcentergt ltformgt)

Create standard footer

28

CreateFooter(out)

outflush()

outclose()

The generated page looks like this

Figure 412 One of The Searching by Author PagesTinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorite l o o k H e lp

^ 3 4 s j ] S o zdStop Refresh Home Search Favorites History Mail Print EditBack bull

I t i h f e l f f httplocalhost8080servletReqCollectauthor

S ea rch Books

Home

C a t e g o r y

Author

Title

ISBN Publisher Date

poundj

TinyBookStore com

You can enter authors foil name first name or last name

A u t h o r jbjarne

C Exact N ame amp Last First N atne (or Initial)

Search Now | Clear Form

Taw boekstofeeoraH om e | Category | A uthor | Title | IS3M | Publisher Date

jpyright and disclaimer copy 1999-2001 F ang Xiao

ihtterteti

42 Design of Search by Different Requests

29

According to different requests the different pages should be produced There are many

common parts in the produced pages So we donrsquot need to code the common parts for

each page We can design the common parts into standard utility classes or static

functions You can simply call the standard classes or functions when you needed them

An example looks like this

CreateHeader(out)

CreateLeftMenu(out)

CreateFooter(out)

The three lines above invoke the standard functions CreateHeader() CreateFooter() and

CreateLeftMenu() which are developed in this thesis writing The CreateHeader()

function produces the top part of the pages The CreateLeftMenu() function produces the

left part of the pages The Createfooter() function produces the bottom part of the pages

You can find the source code in several servlets in Appendix

43 Servlet Chaining To Process Requests In Different Levels

A request can be handled by a sequence of servlets This system is designed to use the

first level servlets to handle the search requests If needed the first level servlets can

cooperates with the second level servlets by passing their processing result to the second

level servlets and let them to proceed the request until the final result is obtained The

final result is returned by the last servlet This is called servlet chaining The request

30

from the client browser is sent to the first servlet in the chain The response from the last

servlet in the chain is returned to the browser In between the output from each servlet is

passed as an input to the next servlet Each servlet in the chain has the option to change

or extend the content W e can see the example in the ReqCollect code

Example 431 A Part of Code of The ReqCollectjava

if (pathequalsIgnoreCase(AUTHOR))

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess id=forml

name=formlgt)

The ReqCollect servlet uses the getPathInfo() method to get the extra path information

This method returns the extra path information associated with request According to the

different extra path information the first level servlet invokes the different servlet of the

second level In this case ReqCollect invokes AuthorProcess servlet The final output

has been listed in Figure 412

31

44 Database Connectivity and Search from Database

The biggest advantage for servlets with regard to database connectivity is that the servlet

life cycle allows servlets to maintain open database connections An existing connection

can trim several seconds from a response time compared to a CGI program that has to

reestablish its connection for every invocation

Another advantage of the servlets over CGI and many other technologies is that JDBC is

database-independent JDBC is a SQL-level API - one that allows you to execute SQL

statements and retrieve the results if any The API itself is a set of interfaces and classes

designed to perform action against any database

An individual database system is accessed via a specific JDBC driver that implements the

javasqlDrivers interface Drivers exist for nearly all-popular RDBMS systems The

database connection used for Tiny Book Store uses a JDBC-ODBC bridge driver coming

along with the JDK 12 to allow access to standard ODBC data source such as the

Microsoft Access database

The first step in using a JDBC driver to get a database connection involves loading the

specific driver class into the applicationrsquos Java Virtual Machine This makes the driver

available later when we need it for opening the connection An easy way to load the

driver class is to use the ClassforNameQ method

32

ClassforName(sunj dbcodbcJdbcOdbcDriver)

When the driver is loaded into memory it registers itself with the javasqlDriverManager

class as an available database driver

The next step is to ask the DriverManager class to open a connection to a given database

where the database is specified by a specified formatted URL The method used to open

the connection is DriverManagergetConnection() It returns a class that implements the

javasqlConnection interface

Connection con =

DriverManagergetConnection(j dbcodbcsomedb

user passwd)

A JDBC URL identifies an individual database in a driver-specific manner Different

drivers may need different information in the URL to specify the host database

During the call to getConnection() the DriverManager object asks each registered driver

if it recognizes the URL If a driver says yes the driver manager uses that driver to create

the Connection object Here is an example

Example 441 A Part of Code of AuthorProcessjava

public void init() throws ServletException

try

ClassforNamesunj dbcodbcJdbcOdbcDriver)

con =

DriverManagergetConnection(j dbcodbcfxbookstore null

null)

catch (ClassNotFoundException e)

catch (SQLException e)

After we got the database connection we need to have some way to execute queries The

simplest way to execute a query is to use the javasqlStatement class Statement objects

are never instantiated directly instead a program calls the createStatement() method of

Connection to obtain a new Statement object

Statement stmt = concreateStatement()

34

A query that returns data can be executed using the executeQuery() method of Statement

This method executes the statement and returns a javasqlResultSet that encapsulates the

retrieved data

Example 442 A Part of Code of AuthorProcessjava

String sqlStmt =

if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where author= + name +II i n

else

sqlStmt = select from BOOK where author like +

name +

ResultSet rs = null

Statement stmt = concreateStatement()

rs = stmtexecuteQuery(sqlStmt)

35

A ResultSet object can be thought as a representation of the query result returned one row

at a time The next() method of ResultSet is used to move from row to row The

ResultSet interface also boasts a multitude of methods designed for retrieving data from

the current row The getStringO and getObject() methods can be used for retrieving

column values

Example 443 A Part of Code of AuthorProcessjava

while (rsnextO )

count++

outprintln(ltdtgtltbgt + count + )

String isbn = rsgetObject(ISBN)toString()

outprintln(lta href=servletDetailContent + isbn +

gt )

outprintln(rsgetObj ect(Title) toString() +

ltagtltbgt)

outprintln (ltnobrxfont color=990033gtUsually ships

in 24 hoursltBRgtltfontxnobrgt)

outprintln(ltddgt +

rsgetObj ect(Author) toString() )

36

outprintln( +

rs getOb j ect ( Publisher) toString () + +

rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

outprintln(ltbrgtltbrgt)

One of the outputs of servlet AuthorProcess is show in Figure 421 and Figure 441

Figure 441 One of The Outputs of Servlet AuthorProcess

37

File Edit View Favorites lo o k - Help M i

T 1 bdquo - 0 L Q 4 pound $ L L lBack r s Stop Refresh Home S earch Favorites History

A - Mail Print

Links rdquo Address | jyen j http7ocalhost808O$ervletAuthorProcess 3

Search B ooks

Home

CategoryA uthor

Title

ISBN

P u b l i sh e r D a te

Tiny Bookstore com

1 The C++ Prograitmuitg Language Usually ships in 24 hour Bjame Stroustrup Addison-Wesley Pub Co i 1997 Our Price 3147

T in yb o oks to re c om H ora e | Category | A uthor | Till | ISBN | Publisher P a t

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top of Page

gk j Local intranet

45 Session Tracking

Session Tracking is one of the most important techniques for any on-line store systems

This is because that HTTP protocol is a stateless protocol A HTTP server sees only a

series of requests and it by itself has no way to know exactly who is making the request

This means that when a customer puts a book in his shopping cart and then goes to other

pages to find more books next time when he puts another book in his shopping cart there

is no guarantee that he puts the book in the same cart It is very possible that he uses

another customerrsquos shopping cart at this time

38

To solve this problem session-tracking is introduced Traditional techniques used by

CGI include hidden form fields URL rewriting user authorization and persistent cookies

For server-side Java applications a built-in class supplied servlet can be used easily to

handle such tasks

When a user first accesses the site web server assigns a new HttpSession object and a

unique session ID to the user The session ID identifies the user and is used to match the

user with the HttpSession object in subsequent requests Usually the session ID is saved

on the client in a cookie or sent as part of a rewritten URL The Tiny Book Store uses this

technique

The Tiny Book Store is a classic shopping cart application A client can put items in his

virtual cart accumulating them until he checks out several page requests later How to

make sure a userrsquos shopping items will be put in his shopping cart or delete from his

shopping cart The Java Servlet API provide built in session tracking to handle this

problem Every user of a site is associated with a javaxservlethttpHttpSession object

that servlets can use to store or retrieve information about that user We can save any set

of arbitrary Java objects in a session object For example a userrsquos session object provides

a convenient location for a servlet to store the userrsquos shopping cart contents An example

shows below

Example 451 A Part of Code of AddToShoppingCartjava

39

1 Get current session object create one if necessary

2 HttpSession session = reqgetSession(true)

3 m_cart = (ShoppingCart)sessiongetValue(cart)

4 if (ra_cart == null) need new cart

5 create a shopping cart

6 m_cart = new ShoppingCart()

7 add to current session

8 sessionputValue(cart m_cart)

9

10

11 try

12 Statement stmt = m_concreateStatement()

13 ResultSet rs = stmtexecuteQuery(select from

book where ISBN= + isbn +)

14 if (rsnext())

15 book - new

BookDetails(rsgetObj ect(ISBN) toString()

16 rsgetObject(Title)toString()

rsgetObj ect(Authorrdquo) toString()

17 rsgetDouble(Price)

rsgetObj ect(PublicationDate) toString() )

18

40

1 9

2 0 catch (SQLException e)

21 e printStackTrace()

22

23 m_cartadd(bookgetlSBN() book)

The servlet uses its request objectrsquos getSession() method to retrieve the current

httpSession object

public HttpSession HttpServeltRequestgetSession (boolean create)

This method returns the current session associated with the user making the request If

the user has no current valid session this method creates one if create is true or return

null if create is false To ensure the session is properly maintained this method must be

called at least once before any output is written to the response Please look at the line 2

in the example 451

If you want to add data to an HttpSession object you can use the putValueQ method

public void HttpSessionputValue(String name Object value)

41

This method binds the specified object value under the specified name Any existing

binding with the same name is replaced This specifies at line 8 of the example 451

If you want to retrieve an object from a session you can use getValue() method

public Object HttpSessiongetValue(String name)

This method specified at line 3 of example 451 returns the object bound under the

specified name or null if there is no binding

From line 4 to line 9 the servlet checks whether the user already has a shopping cart If

the user didnrsquot have a shopping cart the servlet assigns a shopping cart to this user and

add the shopping cart to the current session to keep tracking The ShoppingCartjava class

is developed in this thesis writing code is provided in the appendix

From line 10 to line 21 the servlet knows the user already has a shopping cart m_con is

a data member of AddtoShoppingCart class Lines 12-13 have been discussed in the

previous section Lines 16-20 get some information of the book which the user selected

The information will be the data members of the ldquobookrdquo object that is an instance object

of BookDetailsjava class BookDetailsjava class is developed in this thesis writing the

source code is provided in the Appendix

Line 25 puts the book which is selected by the user into the shopping cart

42

Please see a set of pages are shown below

Figure 451 A Page Show All Information About A Book

TinjiRnfikStnre com - M inrnsnfl Interned Explnrpr

File Edit View Favorites Tools Help-

^ O 4 4 1 f i tStop Refresh Home I Search Favorites History Mail Print Edit

I Link gtgt Address [gl hgtplocalhos9l]IBrit-rvetDetailConetit-Ll20183l)544

S e a r c h B o o k s

Home-

C a t e g o r y

Author

Title

ISSNPublisher Pate

TinyBookStore com

The C++ Programming Languageby Bjarne Stroustrup

aISBN 0201889544 Addison-Wesley Pub Co 1997

Price 3147 Availability U sually ships within 24 hours

Add to cart

Done

R ev iew s

In tins brand-new third edition of The C + + Programming Language author Bjame Stroustrup the creator of C++ presents the full specification for the C++ language and standard library a spec that will soon become the joint ISOANSI C++ standard

g ig L o ca l in tranet

43

Figure 452 A Page Show Items In The Shopping Cart after A User Added Books To The Shopping Cart

H H I H I - I I

j File Edit View Favorites l o o k Help I f

| S ack Stop Refresh Home Search FavoritesJ V

History Wail Print

j Links Address |S1 http7localhost8O80servletAddToShoppingCart i i i i a i i i

( O ldquo ii

Shopping Cart Item s Price

An Introduction to fen e tic Algorithm sMelanie MteheU Quantity 1 Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

drle trgt

delete

delete

Price $ 2 2 0 Subtotal $ 2 2 0

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 6 7 5 6

|euro

rfuj Local intranet

44

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A Book From The Shopping Cart

^ A m a z o n c o m Shopping Cart - Microsoft Internet Explorer

- J A l 4Stop Refresh Home

gtH bdquo ] Back bdquo

httplocalhost8080servletDeleteFromShoppingCartitemgetltem()getlSBN()

Ji _J 3Search Favorites History

j - JMarl Print

~U ccdeg

Shopping Cart Item s

Core Java 2Cay S Horstrnaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d elete

delete

Price

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 4 5 5 6

rsquo0 1 Done gSsfLocat intranet

46 Check Out

This part is designed only using the HTML It collects all information from a user The

information will be written into the database

An important line in this HTML file is shown below

45

ltform method=POST

action=httplocalhost808 0servletCustomerlnfoProcessgt

This line will invoke the servlet CustomerlnfoProcess that will process all data collected

from the user This servlet will discuss in the next section The check out page shows in

Figure 461

Figure 461 A Check Out Page

M M iH M M M i M MmmrnfrnM File Edit View Favorites too ls Help

^ gt a 3 A hi -ltamp f V j HISllll mmB ack S lop R efresh H em e S earch 1 i l lie History M 1 Print Edit

^Links A ddrecs j ig ] h ltp localhostSO SO checkouth tm l i i i l a s

Custom er Information

First name (Fang

Middle initial |a

Last name [Xiao

Email address |fgtdaomitecnet

Account password Jxxxxx

C red it card num ber jl 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7

Credit card type ttV isa O BluebirdO MasterCard O Fisher

Credit card holder jFarig Xiao

Credit card expire date (tnmddyy) joi 0102 ~

Select shipping method t UPS 0 NormalO Express C Abnormal

| | ] Dorraquo raquo f j^ I o c a l intranet

47 Customer Information Processing

The customer information processing is handled by a servlet CustomerlnfoProces Its

source code is provided in the appendix

46

All information collected from the user should be written into the database therefore we

have to open a connection to a given database at first Example 461 is given for this

purpose

Example 471 A Part of Code of CustomerlnfoProcessjava

public void init() throws ServletException

try

ClassforName(sunjdbcodbcJdbcOdbcDriver)

m_con = riverManagergetConnection(jdbcodbcfxbookstore

null null)

catch (ClassNotFoundException e)

e printStackTrace()

catch (SQLException e)

e printStackTrace( )

There is a PO ST request in the check out page The servlet CustomerlnfoProcess will

handle the PO ST request by doPost function which is demonstrated in the following

example

47

Example 472 A Part of Source Code of CustomerlnfoProcessjava

public void doPost (HttpServletRequest req HttpServletResponse res)

throws ServletException IOException

ressetContentType(texthtml)

PrintWriter out = resgetWriter()

get information

String[] values = reqgetParameterValues(firstname)

if (values = null)

firstname = values[0]

values = reqgetParameterValues(middleinit)

if (values = null)

middleinit = values[0]

In the example the HttpServletRequest object res will get each data which was input by

the user by the getParameterValues() function

If the user is a returned user we donrsquot need open a new account again If the returned user

use the same credit card as previous we also donrsquot need to insert the credit card

48

information into the CREDITCARD table Otherwise we should insert all related

information into related table This is shown in the following example

Example 473 A Part of Source Code of CustomerlnfoProcessjava

Statement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where EmailAddress= +

email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext())

sql = insert into CUSTOMERACCOUNT (emailaddress password

firstname middleinit lastname) values ( + + email +

password + + firstname + + middleinit + lastname +

)

stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber= + creditcard

+

rs = stmtexecuteQuery (sql)

if (rsnext())

49

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype

HolderName ExpirationDate) values( + + creditcard + +

cardtype + + cardholder + 11 + expiredate + )

stmtexecute (sql)

All information related the books selected by the user can be obtained from the

shopping cart as shown in the following example

Example 474 A Part of Source Code of CustomerlnfoProcessjava

BookDetails book = null

ShoppingCartltern bookAndQuantity = null

Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getltems()

int aQuantity =0

String alSBN = null

while (itemshasMoreElements())

insert into Orderltems

bookAndQuantity = (ShoppingCartItem)itemsnextElement()

book = bookAndQuantitygetltem()

50

aQuantity = bookAndQuantitygetQuantity()

alSBN = book getISBN()

sql = insert into ORDERITEMS (shoppingCartID ISBN quantity)

values ( + + m_cartID + + aISBN + + aQuantity + )

stmtexecute (sql)

After all information inserted into related tables the servlet CustomerlnfoProcess will

produce invoice page The example page shows in Figure 471

51

Figure 471 An Invoice Page 3 Order List Microsoft Internet Explorer

is File Edit View Favorites Tools Help

J J J U r PS to p Refresh Hom e i -S earch Favorites History s Mai Print

Links Address iff 1 httpVlocalhostBOSOservletCustomerlnfoProcess 3

s5al Local intranet

Y ou r order reads as fo llow sE-MailAddress fiiiaomitecnet

ship to

Tel

Items

F ang Xiao12345 Western Plaza 23OmahaNE68154(402)123-4567

TitleCore Java 2Qtyl Price2579Subtotal2579

TitleJava Servlet PrograrnmingQtyl Price 1977 Sub total 1977 Total4556

i|51 D one

52

Chapter 5

Future Work

In this chapter we discuss two major problems for our future work They are the

Connection Pooling and Object-Oriented for better encapsulation

51 Connection Pooling

After we have used JDBC for a short time it will become evident that the major

performance bottleneck often comes right at the beginning when you are opening a

database connection This is because that opening a connection might involve a series of

low level communications between network protocols and database connection protocols

such as TCPIP ODBC etc

Servlet life cycle allows for extremely fast database access Servlet is loaded into Web

server only once Once it is loaded it can hold a connection to database all its life cycle

Every time it receives a request to read from or write data to database it can just use the

connection to do this

Here comes a problem however Suppose that a customer comes to the on-line store

During the period of selecting some items from the store he leaves his desktop and do

something else leaving this connection to database idling This will waste the precious

resource on the database From database port of view the connection to the database will

assign a space to hold corresponding status and to cache data For example Microsoft

SQL-Servertrade assigns about 36K bytes for each of its connection Resource on the

53

database is limited and idling connection causes such resource unable to be reused for

other users

To solve this problem we can use the technique called connection pooling Essentially a

connection pool is an object holding connections to backend database and managing the

number and status of connections For example if a connection in the pool idles over a

certain time of period the pool can terminate this connection if the requests are not the

same size of the connection pool the pool can dynamically shrink or expand the size of

itself A connection pool can run on a separate thread and is initialized when the server

starts or when a request to database is arrived

To implement a connection pool is pretty straight-forward Because of time constraint

however we did not do it in this paper and leave it as a possible future improvement

52 More Object-Oriented - Better Encapsulation

Another improvement might be done in the future is to create a HTML-related utility

class We have seen in this thesis that there are some duplicated code processing HTML

output such as ldquoout printIn ( lttbxtrgt lttrxtbgt)rdquo All these HTML-

related processes right now are used in a raw way That is they are not encapsulated A

better way to do this is to create a utility class or classes to deal with all HTML-related

processes and hide all HTML tags and format inside the class or classes For example

suppose that we create a Table class then we can use it in a way like

Table table = new Table()

54

table(somerow somecol contents)

table(somerow somecol some_image)

In this way we do not need to use HTML tags in our program and concentrate on the

programming logic The implementation is enriched with more object-oriented property

and therefore it is easy to maintain

55

Chapter 6

Conclusion

The increased awareness and popularity of the Internet make all kinds of electronic

commerce grow vigorously The most popular Web applications are the on-line stores

An on-line store system usually contains four components Web server business

procedure Database system application An on-line store system is different from web

publishing Currently there are three mainstream technologies which are widely used to

develop the on-line store systems CGI Microsoft ASP and Server-side Java application

Introducing the server-side Java application is one of the latest and most exciting trends

in Java programming We have discussed this technology in detail in this thesis The

server-side Java applications have many distinct advantages over CGI and other

technologies We present plenty of examples and figures to analysis the characteristics of

the server-side Java application

As a glance into the future electronic commerce will continue to grow driven by

purchases of home computers and other Web-enabled devices as well as new business

opportunities Electronic commerce is changing whole business procedures The future of

electronic commerce will be exciting and full of opportunities

56

APPENDIX A

Bibliography

57

[1] Karl Moss 1998 Java Servlets Mcgraw-Hill

[2] Jason Hunter William Crawford 1998 Java Servlet Programming O rsquoReilly

[3] Manoj Kumar Anand Rangachari Anant Jhingran Rakesh Mohan 1998 Sales Promitions on the Internet h ttpwwwibmcomiactech-paperhtml

[4] Manoj Kumar Stuart I Feldman 1998 Business Negotiations on the Internet httpwwwibmcomiactech-paperhtml

[5] Manoj Kumar Stuart I Feldman 1998 Internet Auction httpwwwibmcomiactech-paperhtml

[6] Shiwa Fu Jen-Yao Chung Walter Dietrich Vibby Gottemukkala Mitchell Cohen Shyhkwei Chen 1999 A Practical Approach to Web-Based Internet EDI httpwwwibmcomiacpapersicdcsws99indexhtml

[7] Zhong Tian Leo Y Liu Jing Li Jen-Yao Chung Vibby Guttemukkala 1999 Business-to-Business e-Commerce with Open Buying on the Internethttpw w w ibm comi acpapersobi -paperindex html

[8] Gerald J Tesauro Jeffrey O Kephart 1998 Foresight-Based Pricing Algorithms in an Economy os Software Agents http wwwi bm comi actech - paper html

[10] Jeffrey O Kephart James E Hanson Jakka Sairamesh 1998 Price and Niche Wars in a Free-Market Economy o f Software Agents httpwwwibmcomiactech-paperhtml

[11] Jeffrey O Kephart James E Hanson David W Levine Benjamin N Grosof Jakka Sairamesh Richard B Segal Steve R White 1998 Dynamics o f an Information-filtering Economy httpwwwibmcomiactech-paperhtml

[12] James E Hanson Jeffrey O Kephart 1998 Spontaneous Specialization in a Free-Market Economy os Agents httpwwwibmcomiactech-paperhtml

[13] Jakka Sairamesh Jeffrey O Kephart 1998 Price Dynamics o f Vertically differentiated Information Markets httpwwwibmcomiactech-paperhtml

[14] David Kosiur 1997 Understanding Electronic Commerce Microsoft Press

[15] Gunther Birznieks Selena Sol 1997 CGI fo r Commerce MampT Books - A Division of MIS Pres

58

[16] Ravi Kalakota Andrew B Whinston 1997 Electronic Commerce Addison Wesley

[17] Alex Fedorov Richard Harrison Dave Sussman Brian Francis Stephen Wood 1998 Profession Active Server Page 20 Wrox Press

[18] Calvin Austin Minica Pawlan 1999 Writing Advanced Application for the Java PlatformhttpVdeveloper iavasuncomdeveloperonlineTrainingProgrammin gJDCBooki ndexhtml

59

APPENDIX B

The Source Code of An On-Line Store System - Tiny Book Store

60

1 welcomeshtml

lthtmlgtltheadgtlttitlegtSearch Tinybookstorecomlttitlegtltheadgtltbodygt

lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=eeeeccgtlttrgtlttd rowspan=2 align=left valign=top width=15 cellspacing=0 cellpadding=0xIM G border=0 hspace=0 id=IMGl src=flowergif gtlttdgtlttd rowspan=2 align=left valign=centergtltstronggtlth2gtltigtTinyBookStorecomltigtlth2gtltstrongxtdgtlt trx tab legt

lttable border=0 width=100 cellspacing=0 cellpadding=0gtlttrgtlttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtltPgt

lttable width=100 cellspacing=0 cellpadding=5 border=0gtltTRgt ltTDgt ltTDgt ltTD colspan=2gt ltFONT FACE=verdanaarialhelvetica SIZE=-1 gtampnbsp ltFONTgt ltTDgt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD co lsp an = 2 x stro n g x fo n t face=verdanaarialhelvetica size=-lgtSearch B ooksltfontxstronggt ltTDgt ltTRgtltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt ltTD x f o n t face=verdanaarialhelvetica size=-l gt

lta href=w elcom eshtm lgtH om eltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt c T D x fo n t face=verdanaarialhelvetica size=-1 gt

lt A href= servletReqC ol 1 ec tc ategory gtC ate gory ltf o n tx A x T D gtltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollectauthorgtA uthorltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollecttitlengtTitleltorfo n tx A x T D gt ltTRgt

61

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectisbngtISBN ltA xfontxTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectpublisher_dategtPublisherD a telt A x fo n tx T D gtltTRgtlt tab lex p gtlttdgt

lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgtlttd valign=top align=leftgt

ltbr clear=allgtltPgtlt h 3 x s tro n g x fo n t color=ff6347gtWelcome to theltigt T in y B o o k S to rex o m lt ix fo n tx s tro n g x h 3 gt

ltbrgtlt s tro n g x b x h 3 x c e n te rgt F iv e Hot B o o k slt cen te rx h 3 x B x s tro n g gt

ltbrgtltservlet code=EchoServetTag myArgI=myValuel myArg2=myValue2gt ltparam name=myParm 1 value=Hellogtltparam name=myParml value=Worldgtltparam name=myParm2 value=myParmValue2gtltservletgt

lt td x trgt

lttablegt

ltTABLE width=100gtltTRgt ltTD width=50 valign=top align=Ieftgt ltTDgtltTD width=50 valign=top align=rightgtltfont size=-lgtltA href=topgtTop of P ag elt A x fo n tx T D gt ltTRgt

62

ltTABLEgt

ltcentergtltfont size=-lgtltA href=indexhtml gtTinybookstorecom HomeltAgt ampnbsplampnbsp ltA href=categoryhtml gtCategoryltAgt ampnbsplampnbspltA href= author html gtAuthorltAgt ampnbsplampnbspltA href= title html gtTitleltAgt ampnbsplampnbspltA href=7isbnhtml gtISBNltAgt ampnbsplampnbspltA href=publisherhtmrgtPublisher DateltAgtltpgtltfontgtltcentergt

ltPgtltcentergtlt b rx fo n t size=-lgtltA href=copyrighthtml gtCopyright and disclaimerltAgt copy 1999-2001 Fang Xiao ltfontgtltcentergt

ltbodygtlthtmlgt

63

2 AddToShoppingCartjava

ltpgt AddToShoppingCart is the servlet that process the action of adding item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javasql import javautil import javaxservlet import javaxservlethttp

public class AddToShoppingCart extends HttpServlet

protected Connection m_con = null protected ShoppingCart m_cart protected BookDetails book

public void initQ throws ServletException try

Class forName( sunj dbc odbc JdbcOdbcDriver)m_con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintstackTrace ()catch (SQLException e)

e prints tackT race ()

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

String[] params = reqgetParameterValues(isbn)

64

String isbn = get isbn from extra path infomationif (params = null)

isbn = params [0]

Get current session object create one if necessary HttpSession session = reqgetSession(true) m_cart = (ShoppingCart)sessiongetValue(cart)

if (m_cart == null) need new cart create a shopping cart m_cart = new ShoppingCart() add to current session sessionputValue(cart m_cart)

try Statement stmt = m_concreateStatement()ResultSet rs = stmtexecuteQuery(select from book where

ISBN=rsquo + isbn + rsquo)

if (rsnext()) book = new BookDetails(rsgetObject(ISBN)toString()

rsgetObject(TitIe)toStringOrsgetObject( Author) toStringO

rsgetDouble( Price) rs getObj ect( PublicationDate) toStringO)

catch (SQLException e)

eprintStackTrace()m_cartadd(bookgetISBN() book)

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lt h tm lxheadx titlegt T inyB ookS tore com S hopping

Cartlttitlexheadgt)outprintln(ltbody bgcolor=FFFFFF lmk=003399

alink=FF9933 vlink=996633 text=000000ngt)outprintln(lta nam e= topxmdashTop of Pagemdashx a gt )

65

outprin tln(ltpxa href=httplocalhost8080checkouthtmlximg src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=cccc99 gt)ou tp rin tln (lt tdxbrx tdgt )ou tp rin tln (lt tdxbrx tdgt )o u tp rin tln (lt tdxbrx tdgt )outprintln(lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=2xfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=left valign=topxfont

face=verdanaaria lhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=cccc99gt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lt td x b rx td gt ) outprintln(lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantityQ

outprintln(lttr bgcolor=FFFFFFgt) ou tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt )outprintln(ltbrgt + item getltem() get Author()) outprintln(ltbrgtQuantity + itemgetQuantityO) outprintln( ltbrgt) outprintln(lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=POST

action=7servletDeleteFromShoppingCartitemgetItem()getISBN()gt)

66

outprintln(ltpgt cinput type=hidden name=isbn value= + itemgetItem()getISBN())

outprintln(ltpgt ltinput type=submit name=ditemvalue=deletegt)

outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelve tica color=000000gt)

outprintln(ltNOBRgtltbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fon tx bx N O B R gt ltbrgt )

outprintln(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantity() + lt fo n tx b x N O B R x b rgt )

outprintln(ltfontgt) out println( lttdgt)

out printl n( lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)out println( lt fo n tx fo n tgt )outprintln(lttdxtrgt)outprintln(lttablegt)outprin tln(ltpxa href=httplocalhost8080checkouthtmlYximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)outprintln(ltbodygt lthtmlgt)

outflush()outclose()

67

3 AuthorProcessjava

bull ltpgt AuthorProcessbull This is the servlet that process the Author-search request and generatebull search resultbull Author Fang Xiao Purpose Thesis project Copyrightcopy Fang Xiao 1999-2001

import javaxservlet import jav ax servlet http import javaio import javasql

public class AuthorProcess extends HttpServlet protected final String EXACT = ldquoexactrdquo protected final String OTHERS = ldquolastrdquo

protected Connection con = null

public void init() throws ServletException try

ClassforName(ldquosunjdbcodbcJdbcOdbcDriverrdquo)con = DriverManagergetConnection(ldquojdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(ldquotexthtmlrdquo)PrintWriter out = resgetWriterQ

68

String[] valuesString name =

values = reqgetParameterValues(ldquoauthorrdquo) if (values = null)

name = values [0]

String mode = ldquordquovalues = reqgetParameterValues(ldquoauthor_moderdquo) if (values = null)

mode = values [0]

String sqlStmt = ldquordquo if (modeequalsIgnoreCase(EXACT))

sqlStmt = ldquoselect from BOOK where author=rsquordquo + name +else

sqlStmt = ldquoselect from BOOK where author like lsquordquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

ldquoYour Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ldquoltdlgtrdquo) 11 start Glossary List

while (rsnext()) count++outprintln(ldquolt d tx b gt rdquo + count + ldquo ldquo)String isbn = rsgetObject(ldquoISBNrdquo)toString()

69

outprintln(ldquolta href=servletDetailContentrdquo + isbn+

outprintln(rsgetObject(ldquoTitlerdquo)toString() +ldquolt a x b gt rdquo)

outprintln(ldquolt n o b rx fo n t color=990033gtUsually ships in 24 h o u rslt B R x fo n tx n o b rgt rdquo)

outprintln(ldquoltddgtrdquo +rsgetObject(ldquoAuthorrdquo)toString())

outprintln(ldquo ldquo +rsgetObject(ldquoPublisherrdquo)toString() + ldquo ldquo + rsgetObject(ldquoPublicationDaterdquo)toString())

outprintln(ldquoltbrgt Our Price ldquo +rsgetObject(ldquoPrice)toString())

outprintln(ldquolt b rx b rgt rdquo)

if (count == 0) outprintln(ldquoltdtgt No matched data foundrdquo)

outprintln(ldquoltdlgtrdquo) end Glossary List

catch (SQLException e) create footer here outprintln(ldquolttdgt lttrgtrdquo) outprintln(ldquolttablegtrdquo)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(ldquolthtmlgtrdquo) outprintln(ldquoltheadgtrdquo) outprintln(ldquolttitlegt TinyBookStorecom lttitlegtrdquo) outprintln(ldquoltheadgtrdquo)

outprintln(ldquoltbodygtrdquo)

70

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspacing=0 cellpadding=0 bgcolor=rdquoEEEECCYrsquogtrdquo)

outprintln(ldquolttrgtrdquo)outprintln(ldquolttd align=left valign=top width=90 gtrdquo) outprintln(ldquoltIMG border=0 hspace=0 id=IMGl

src=rdquodJavaWebServer20public_htmlflowergifrdquogtlttdgtrdquo) outprintln (ldquolttd width=30gtlttdgtrsquorsquo) outprintln(ldquolttd align=left valign=center width=300gtrdquo)

outprintln(ldquolt stro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x s tro n g x td gt rdquo) outprintln(ldquolttd align=right valign=centergtrdquo) outprintln(ldquolttdgtrdquo) outprintln(ldquolttd w id th= 20x tdgt rdquo) out pri ntln (ldquolttrgtrsquo rsquo) outprintln(ldquolttablegtrdquo)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ldquolttable width= 100gtrdquo)outprintln(ldquolttrgt lttd width=50 valign=top align=leftgt lttdgtrdquo) outprintln(ldquolttd width=50 valign=top align=rightgtrdquo) outprintln(ldquoltfont s iz e = - lx a href=rdquotoprdquogtTop of P agelt ax fon tgt rdquo) outprintln(ldquolttrgtrdquo) outprintln(ldquolttablegtrdquo)

outprintln(ldquoltcentergtrdquo) outprintln(ldquoltfont size=-lgtrdquo) outprintln(ldquolta

href=rdquohttplocalhost 8080welcomeshtmlrdquogtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080$ervletReqCollectcategoryrdquogtCategoryltagtampnbsplampnbsprdquo)

outprintln(ldquoltahref=Yhttplocalhost8080servletReqCollectauthorrdquogtAuthorltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_daterdquogtPublisheramp44Dateltagtrdquo)

outprintln(ldquoltpgtrdquo)

71

outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltpgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquolt b rx fo n t size=-lgtrdquo)outprintln(ldquoltA href=Y7copyrighthtmlrdquogtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiaordquo)outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltbodygtrdquo) outprintln(ldquolthtmlgtrdquo)

i

protected void CreateLeftMenu(PrintWriter out) System out println(ldquoLeftMenurdquo)

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspaeing=0 cellpadding=0gtrdquo)

outprintln(ldquolttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtrdquo)

outprintln(ldquoltpgtrdquo)

outprintln(ldquolttable width=rdquo 100rdquo cellspaeing=0 cellpadding=5border=0gtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquoltfont face=verdanaarialhelvetica SIZE=rdquo- l rdquogtampnbsp

ltfontgtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquolt strongxfon t face=verdanaarialhelvetica size=rdquo-

1 rdquogtSearch B ooksltfontxstronggtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd ldquo) outprintln(ldquoltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080welcomeshtmlYgt H o m elt fo n tx ax td gt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=rdquo-1rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080servletReqColIectcategoryrdquogt C ateg o ry lt fo n tx ax td gtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

72

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectauthorrdquogtAuthorltfontgtltagtlttdgtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width-2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l W rsquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltfontgtltagtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo-lYgtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_dateVrsquogtPublisher Dateltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolt tab lex p gt rdquo)

outprintln(lsquolsquolttdgtrdquo)outprintln(ldquolttd rowspan=4 width=5gtampnbspampnbspltbrgtlttdgtrdquo) outprintln(ldquolttd valign=top align=leftgtrdquo) outprintln(ldquoltbr clear=allgtrdquo)

73

4 BookTeatailsjava

ltpgt This is the class describing a book item in shopping cart

Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class BookDetails private String m_isbn = null private String m_title = null private String m_author = null private double m_price = 00 private String m_year = null

public BookDetails(String isbn String title String author double price String year)

thism_isbn = isbn thism_title = title thism_author = author thism_price = price thism_year = year

public String getISBN() return m_isbn

public String getTitle() return m_title

public String getAuthor() return m_author

public double getPrice() return m_price

ipublic String getYearQ

return m_year

75

5 CategoryProcessjava

ltpgt CategoryProcess This is the servlet that process the Category-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql import javautil

public class CategoryProcess extends FlttpServlet protected final String EXACT = exactprotected final String OTF1ERS = last

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

76

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentType( texthtml)Print Writer out = resgetWriterQ

String[] values String name = String sqlStmt =

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

else

path = pathsubstring(l) if (pathequalsIgnoreCase(cO 1))

sqlStmt = select from BOOK wherecategoryid=rsquo + cOl +

else if (pathequalsIgnoreCase(c02))sqlStmt = select from BOOK where

categoryid=rsquo + c02 +else if (pathequalsIgnoreCase(c03))

sqlStmt = select from BOOK wherecategoryid=rsquo + c03 +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftM enu(out)

Your Book Search Results try

77

if (con = null) Statement stmt = concreateStatement() rs = stmt executeQuery (sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn

+outprintln(rsgetObject(Title)toString() +

lt ax bgt )outprintln(ltnobrxfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltddgt +

rsgetObject( Author)toStringO)outprintln( +

rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)outprintln(ltbrgt Our Price +

rsgetObject( Price) toStringO) ltfont color=990000gtYou Save $1100

(20)ltfontgtoutprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

78

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)out println( lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20publicbdquohtmlflowergifgtlttdgt) outprintln(lttd width=3 0gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln( lt s tro n g x h 2 x igt T inyB ookS to re com lt ix h2x s tro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlngtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

79

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYrsquogtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln( ltfontgt)outprintln(ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rOwspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt)

outprintln(lttablewidth= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=Y2Ygt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y-1 Yrsquogtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2Yrsquogt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=Y-

lYrsquogtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=Y-lYgt)

80

outprintln(ltahref=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqColIectcategorygtCategoryltfontxagtlttdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(nltahref=httplocalhost8080servletReqCollectauthorVrsquogt A u th o rlt fo n tx ax td gtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httpIocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

6 CustomerlnfoProcessjava

ltpgt CustomerlnfoProcessThis servlet is responsible to process userrsquos information when heshe check out

Author Fang Xiao

Purpose Thesis projectCopyright (C) Fang Xiao 1999-2001

import javasql import javaio import j avau til import javaxservlet import javaxservlethttp

public class CustomerlnfoProcess extends HttpServlet protected Connection m_con = null protected HttpSession m_session = null protected static int m_cartID = 1 protected String firstname =protected String middleinit =protected String lastname =protected String email =protected String password =protected String creditcard =protected String cardtype =protected String cardholder =protected String expiredate =protected String shipping =protected String receiver =protected String address =protected String city =protected String state =protected String zipcode =protected String phone =

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)

82

m_con = DriverManagergetConnection(jdbcodbcfxbookstorenull null)

catch (ClassNotFoundException e)

eprintStackTrace()catch (SQLException e)

eprintStackTrace()i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

get informationString[] values = reqgetParameterValues(firstname) if (values = null)

firstname = values [0]

values = reqgetParameterValues(middleinit) if (values = null)

middleinit = values [0]

values = reqgetParameterValues(lastnameM) if (values = null)

lastname = values [0]

values = reqgetParameterValues(email) if (values = null)

email = values [0]

values = reqgetParameterValues(password) if (values = null)

password = values [0]

values = reqgetParameterValues(creditcard)

if (values = null) (creditcard = values [0]

values = reqgetParameterValues(cardtype) if (values = null)

cardtype = values [0]

values = reqgetParameterValues(cardholder) if (values = null) (

cardholder = values [0]

values = reqgetParameterValues(expiredate) if (values 1= null)

expiredate = values [0]

values = reqgetParameterValues(shippingrdquo) if (values = null)

shipping = values [0]

values = reqgetParameter Values (receiver) if (values = null)

receiver = values [0]

values = reqgetParameterValues(address) if (values = null)

address = values [0]

values = reqgetParameterValues(city) if (values = null) (

city = values [0])

values = reqgetParameterValues(state) if (values = null) (

state = values [0]

84

values = reqgetParameterValues(zipcode) if (values = null) (

zipcode = values [0]

values = reqgetParameterValues(phone) if (values = null)

phone = values[0]i

get session object m_session = reqgetSessionQ

try update databaseStatement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where Email Address=rsquo + email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext()) Systemoutprintln(insert customeraccount)

sql = insert into CUSTOMERACCOUNT (emailaddress password firstname middleinit lastname) values ( +

+ email + + password + + firstname +V + middleinit + + lastname + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber=rsquo +creditcard +

rs = stmtexecuteQuery (sql)

if (rsnext()) Systemoutprintln(insert creditcart)

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype HolderName ExpirationDate) values( +

+ creditcard + + cardtype + +cardholder + + expiredate + rdquo)

Systemoutprintln(sql)stmtexecute (sql)

i

85

sql = insert into SHOPPINGCART (ShoppingCartIDEmail Address CreditCardNumber ShippingType ReceiverName ReceiverAddress ReceiverCity ReceiverState ReceiverZipcode ReceiverPhone) values ( + m_cartID + V + email + Vrdquo +

creditcard + V + shipping + + receiver ++ address + V +

city + V + state + V + zipcode + V + phone +gt gt

Systemoutprintln(sql)stmtexecute (sql)

BookDetails book = nullShoppingCartltem bookAndQuantity = null Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

int aQuantity =0 String alSBN = null

while (itemshasMoreElementsO) insert into Orderltems bookAndQuantity =

(ShoppingCartItem)itemsnextElement()book = bookAndQuantitygetItem()

aQuantity = bookAndQuantitygetQuantity() alSBN - book getISBN()

Systemoutprintln(insert Orderltems)sql = insert into ORDERITEMS (shoppingCartED ISBN

quantity) values ( + m_cartID + +alSBN + + aQuantity + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

im_cartID++ must increase by one

86

catch (SQLException e) eprintS tackTrace()

printOrder(out)

public void printOrder(PrintWriter out) outprintln( lthtmlgt ltheadgt lttitlegt Order List lttitlegt ltheadgt) outprintln( ltbodygt)outprintln(lthlgt Your order reads as follows lthlgt)outprintln(lttablegt)outprintln( lttrgt)outprintln( lttdgtE-Mail Addres s lttdgt) outprintln(lttdgt+ em ail+lttdxtrgt) outprintln(lttrgt) outprintln(lttdgtship tolttdgt) outprintln(lttdgt+ receiver +ltbrgt) outprintln(address +ltbrgt) outprintln(city +ltbrgt) outprintln(state +ltbrgt) outprintln(zipcode + lt b rx td x trgt ) outprintln(lttrgt) outprintln( lttdgtTel lttdgt) outprintln(lttdgt+ phone +lttdxtrgt) outprintln(lttrgt) outprintln( lttdgtItems lttdgt)

BookDetails book = nullShoppingCartltem bookAndQuantity = nullEnumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

double total = 00

while (itemshasMoreElements()) bookAndQuantity = (ShoppingCartItem)itemsnextElement()

total += bookAndQuantitygetItem()getPrice() bookAndQuantitygetQuantityO

book = bookAndQuantitygetltem()

87

outprintln(lttdgtTitle+ bookgetTitle() + Qty + bookAndQuantitygetQuantity() + ltbrgt)

outprintln(Price + bookgetPrice() + Subtotal + bookAndQuantitygetQuantityO bookgetPrice() +ltbrgt)

outprintln(Total + total )outprintln(lttdxtrgt)outprintln(lttablegt)outflush()outclose()

7 DeleteFromShoppingCartjava

ltpgt DeleteFromShoppingCart is the servlet that process the action of deleting item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javautil import javaxservlet imp ort j avax servlet http

public class DeleteFromShoppingCart extends HttpServlet

protected ShoppingCart m_cart protected BookDetails book

public void doPost(HttpServletRequest req FIttpServletResponse res) throws ServletException IOException res setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String[] params = reqgetParameterValues(isbnrsquo) String isbn = get isbn hidden fieldif (params = null)

isbn = params [0]

Systemoutprintlnfisbn = + isbn)

Get current session objectHttpSession session = reqgetSession()m_cart = (ShoppingCart)sessiongetValue(carf)

m_cartremove(isbn)

89

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lthtm lgtltheadxtitlegtAm azoncom Shopping

C artlt titlexheadgt)out pri ntln ( ltb ody bgcolor=FFFFFF link=003399

alink=FF9933 vlink=Yrsquo996633Y text=rdquo000000rdquogtrdquo)outprintln(lta nam e= top xmdashTop of Pagemdashx a gt ) ou tp rin tln (lt pxa href=httplocalhost8080checkouthtmlximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=Yrsquocccc99Yrsquo gt)ou tp rin tln (lt tdxbrx tdgt )out pri ntln ( lt td x b r x td gt )outprintln( lt td x b r x td gt )out println (rsquo1 lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=Y2Yxfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=YleftY valign=YtopYxfont

face=verdanaarialhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=Ycccc99Yrsquogt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantity()

outprintln(lttr bgcolor=FFFFFFgt) o u tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt)outprintln(ltbrgt + itemgetItem()getAuthor())

90

outprintln(ltbrgtQuantity + itemgetQuantityO)outprintln(ltbrgt)outprintln( lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=VPOST

action=7servletDeleteFromShoppingCartVgt)outprintln(ltpgt ltinput type=hidden name=isbn value= +

itemgetItem()getISBN())outprintln(ltpgt cinput type=submit name=ditem

value=Y rsquo deletegt rsquo rsquo)outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelvetica color=000000gt)

outprintln(ltNOBRxbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fo n tx b x N O B R x b rgt )

outprintin(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantityO + lt fo n tx b x N O B R x b rgt )

outprintln( ltfontgt) outprintln( lttdgt)

i

outprintln(lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)outprintln(ltfontxfontgt)outprintln( lt td x trgt ) outprintln(lttablegt)ou tp rin tln (lt pxa href=Yhttplocalhost8080checkouthtmlYximg

src=YdYJavaWebServer20servletsimageproceed-to-checkoutgifYxagt)outprintln(ltbodygt lthtmlgt)

outflushOoutcloseQ

91

8 Detailcontentjava

ltpgt DetailContent is the servlet responsible for generating detailed information page for a book The book is identified by its ISBN Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaio import javasql import jav ax servlet import javaxservlethttp

public class DetailContent extends FIttpServlet protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String isbn = reqgetPathInfo()isbn = isbnsubstring(l) skip over rsquo rsquo

92

try String sql = select from book where ISBN=rsquo + isbn +

Statement stmt = concreateStatement()ResultSet rs = stmtexecuteQuery(sql)

create header here CreateHeader(out)

create left menu here CreateLeftMenu(out)

outprintlnfctd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintlnfctd valign=top align=leftgt)

cellpadding=0gt)

outprintln(ltbrgt)

create detailcontent here while (rsnext())

String strlSBN = rsgetObject(ISBN)toString() outprintln(lttable width=100 border=0 cellspacing=0

+ltbgtlttdxtrgt)

+ lt tdx trgt)

outprintln(lttrgt lttd colspan=3 align=leftxbgt) outprintln( rsgetObject(Title)toString()

outprin tln(lt trxtd colspan=3 align= leftxbgt by ltbgt) out println( rs getObj ec t( Author) toS tringQ

cellpadding=0gt)

outprin tln(lt trx td x i m g src=xtdgt) outprintln( lttd valign=topgt) outprintln( lttable border=0 cellspacing=0

outprintln( lt t r x td valign=topxbgtPrice )outprintln(

rsgetObject(Price)toString() + lt b x td x trgt ) outprintln(

lt trx td x b gt A v ailab ility lt b gt U su a lly lt td x trx b rgt )outprintln( lt t r x td vlign=topgtships within 24

hou rs lt td x trgt )outprintln( lt tab lextdgt)

93

outprintln( lttd align=rightgt) outprintln( lttable border=0 cellspacing=0

cellpadding=0gt)outprintln( lt trx td gt )outprintln( ltform

method=POST action=httplocalhost8080servletAddToShoppingCartgt)outprintln( ltinput

type=hidden name=isbn value= + strlSBN +outprintln( cinput

type=submit value=Add to cart )outprintln( lt tdx trgt )

outprintln( lt tab lex tdgt ) outprintln(rdquolttrgt)outprintln(lttrgt lttd clospan=3 align=leftgt ISBN ) outprintln( strlSBN +lttdxtrgt)outprintln(lttrgt lttd clospan=3 align=leftgt) outprintln( rsgetObject(Publisher)toString()

+rsgetObject(PublicationDate)toString() + lt tdx trgt )outprintln(lttablegt)outprintln(ltbrgt)outprintln(ltbrgt)

output reviewString review = rsgetObject(BookReview)toString() if (review = null)

review =DJavaWebServer20servletsreview + review

outprintln(ltbgtReviewsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(review))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprin tin (thisLine) ou t println( ltpgt)

)

icatch (IOException e)

need do something here eprintstackTrace ()

94

outprintln(ltbrgt)String comment =

rsgetObject(BookComment)toString()if (comment = null) comment = DJavaWebServer20servletscomment +

commentoutprintln(ltbgtReader Commentsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(comment))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprintln(thisLine) outprintln(ltpgt)

catch (IOException e)

need do something here eprintstackTrace ()

ou t pri ntln ( ltb rgt)

catch (SQLException e)

need to do something here

add table end tab outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt)

95

ou t pri ntln ( lthe adgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=YTOO cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d J avaW eb S erver 2 Opublic_htmlflo wer gif gtlttdgt) outprintln(lttd width=30gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyBookStorecomltigtlth2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln( lttd width=20gtlttdgt) out pri ntln ( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-1 gt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

96

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsptampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out prin tin ( ltcen tergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

eellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=Yhttplocalhost8080Avelcom eshtm lgtHom eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-1gt)

97

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=http7localhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref-httpIocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lVgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

98

9 EchoServlettagjava

import javaio import j avasql import javaxservlet import javaxservlethttp

public class EchoServletTag extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintStackTrace ()catch (SQLException e)

eprintStackTrace()

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

try Statement stmt = concreateStatementQResultSet rs = stmtexecuteQuery(select from book where title

like rsquoProgrammingrsquo)int count = 1outprintln(ltdlgt)while (rsnext() ampamp count lt 6)

outprintln(ltdtxbgt + count + )

99

String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn + outprintln(rsgetObject(Title)toString() + lt ax bgt ) outprintln(ltddxnobrgtltfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltbrgt + rs getObject( Author) toStringO) outprintln( + rsgetObject(Publisher)toStringO +

+ rsgetObject(PublicationDate)toStringO)outprintIn(ltbrgt Our Price +

rsgetObject(Price)-toStringO)

out println( lt b rx b rgt ) count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()outprintln(lttdgt lttrgt) outprintln(lttablegt) outflush() outcloseO

ii

100

10 ISBNProcessjava

ltpgt ISBNProcess This is the servlet that process the ISBN-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javax servlet import javaxservlethttp import javaio import j a vasql

public class ISBNProcess extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forN ame( sun j dbc odbc J dbcOdbcDri ver)con = DriverManagergetConnection(j dbc odbc fxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s s e tC on te n tTy pe ( tex th tm l)PrintWriter out = resgetWriter()

String[] values

String alSBN =

values = reqgetParameterValues(isbn) if (values = null)

alSBN = values [0]

String sqlStmt = select from BOOK where ISBN= + alSBN

ResultSet rs = null int count = 0

create header here bullCreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject( IS BN) toStringO

outprintln(lta href=servletDetailContent + isbn+ gt)

outprintln(rsgetObject(Title)toStringO +lt ax bgt )

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toStringO)

outprintln( +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

102

outprintln(ltbrgt Our Price +rsgetObject(rdquoPrice) toStringO)

outprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width= 100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d Uava WebS erver2 Opubhc_htmlflo wer gif gtlttdgt) outprintln(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS tore com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt)

103

out println( lttdgt) outprintln(lttd w id th= 20x tdgt ) out pri ntln( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)out pri ntln (lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) out pri ntln ( lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsp1ampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out println( ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

104

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 eellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Books lt fontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocaihost8080servletReqCollectcategorygtCategoryltfontxaxtdgt lttr gt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

105

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lttablegtltpgt)

o u t println( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

ii

106

11 PublisherDataProcessjava

ltpgt AuthorProcess This is the servlet that process the PublisherampDate-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql

public class PublisherDateProcess extends FIttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbc odbc JdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentT ype ( texthtml)PrintWriter out = resgetWriterQ

String[] valuesString namel =

107

values = reqgetParameterValues(publisher) if (values = null)

nam el = values [0]

String name2 =values = reqgetParameterValues(rdquopublication_date) if (values = null)

name2 = values [0]

String sqlStmt =sqlStmt = select from BOOK where publisher=rsquo + namel + rsquoand

publicationdate=rsquo +name2

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprin tln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toStringO outprintln(lta href=servletDetailContent + isbn

+ gt)outprintln(rsgetObject(Title)toString() + (

lt ax bgt )

108

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rs getObj ect( Author) toS tring())

outprintln(V +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

outprintln(ltbrgt Our Price +rsgetObject( Price) toStringO)

outprintln( lt b rx b rgt )

if (count == 0) (outprintln(ltdtgt No matched data found)

outprintln(rdquoltdlgt) end Glossary List

catch (SQLException e) ( create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 celipadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt)

109

outprintln(ltIMG border=0 hspace=0 id=IM Gl src=dJavaW ebServer20public_htmlflowergifxtdgt)

outprintln(lttd width=3 0 x td gt ) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS to re com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ctable w idths 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt) outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) ou t println( ltcentergt)

no

outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaim er^A gt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) out pri ntln ( lthtml gt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-1 gtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=V-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-1gt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

I l l

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitleYrsquogt T itle lt fo n tx a x td gt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(nltahref=Yhttplocalhost8080servletReqCollectisbnY gtISBNltaxfontxtdgt lttrgt)

outprindn(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdana arial helvetica size=Y -1 gt)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYgtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

1 12

12 ReqCollectjava

ltpgt This is a servlet responsible for generating search request collection page It read extra path information from URL and then according to the extra path information it generates corresponding page format Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001import javaxservlet import javaxservlethttp import javautil import javaio

public class ReqCollect extends HttpServlet

protected final String CATEGORY = categoryrdquo protected final String AUTHOR = author protected final String TITLE = titlerdquo protected final String ISBN = isbnprotected final String PUBLISHER_DATE = publisher_date

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentType( texthtml)PrintWriter out = resgetWriter()

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

)else

Create standard header CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

path = pathsubstring(l) if (pathequalsIgnoreCase(CATEGORY))

I I Create category request collect

outprintln(ltpgt)outprintln(lth3xstronggtProgrammingltstronggtlth3gt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc01gtAlgorithmsltagt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc02gtCampC++ltagt)outprintln( Delphi) outprintln(lta

href=httplocalhost8080servletCategoryProcessc03gtJavaltagt)outprintln( MFC Perl)

outprintln(software Design UML Visual Basic More)

outprintln(lth3xstronggtW eb Developm entltstrongxh3gt) outprintln(ASP Commercem Cyberculture HTML

JavaScript)

outprintln(Security Web Design XML more)

outprintln(lth3xstronggtGraphics amp Softwareltstrongxh3gt) outprintln(Asobe CAD Desktop Publishing Graphics)

outprintln(Microsoft More)

outprintln(lth3xstronggtNetW orking amp O Sltstrongxh3gt) outprintln(Linux Macs Oracle PCs SAp R3 SQL)

outprintln(TCPIP Unix WindowsampDOS W indowsNT)

out println( More)

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

1 14

outprintln(ltfont color-CC6600 face=verdana arial helvetic a size=+1 gtltbgtEnter Authorltbgtltfontgt)

outprintln(ltbrgt You can enter authorrsquos full name firstname or last nameltpgt)

outprintln(ltform method=POST action=httplocalhost 8080servletAuthorProcessY id=form 1 name=form 1 gt)

outprintln( lttable border=0gt) outprintln(lttrgt lttd valign=middle

ahgn= leftx ttx b gt A u th o rlt b gt lt ttx td gt )outprintln(lttd valign=middle align= leftx input

type=YtextY name=author size=40 value=YYxtdgt)outprintln(lttrgt)outprintln(lttrgt lttd colspan=2gt ltfont size=-lgt) outprintln(ltcentergt ltinput type=radio

name=Yauthor_modeY value=YexactY checkedgt Exact Name)outprintln(ltinput type=radio name=author_mode

value=lastgtLast First Name (or Initial))outprintln(ltcentergt) outprintln(ltfontgt) outprintln(lttdgt lttrgt)outprintln(lttrgt lttd colspan=2gt ltpgt ltbrgt lttdgt lttrgt)outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search NowY

id=submitl name=submitlgt)outprintln(cinput type=reset value=YClear Form

id=resetl nam e= rese tlxpgt )outprintln(ltcentergt ltformgt)

else if (pathequalsIgnoreCase(TITLE))

Create title request collect

outprintln(ltfont color=CC6600 face=verdanaarialhelvetica s ize= + lxbgt E n ter T itlelt bxfontgt)lsquo

outprintln(ltbrgtYou can enter the exact title or part oftitleltPgt)

outprintln(ltform method=YPOSTY action=Yhttplocalhost8080servletTitleProcessY id=form l name=formlgt)

outprintln(lttable border=0gt) outprintln(lt trxtd valign=middle

a lig n = le ftx ttx b gt T itle lt b x t tx td gt )

115

outprintln(lttd valign=middle align= leftx input type=text name=title size=40 value=xtdgt)

outprintln(lttrgt) outprintln(lttrgt) outprintln( lttd colspan=2gt) outprintln( ltfont size=-lgt) outprintln( ltcentergt)outprintln( ltinput type=radio name=title-mode

outprintln(value=exact checkedgt) outprintln( Exact Title)outprintln( ltinput type=radio name=title-mode

outprintln( value=titlewords gt ) outprintln( Title Words )outprintln(ltcentergt ltfontgt lttdgt lttrgt)outprin tln(lt trxtd c o ls p a n = 2 x p x b r x td x tr gt ) outprintln(lttablegt)

outprintln(ltcentergt)outprintln( ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln( ltinput type=reset value=Clear Form

id=resetl nam e= resetlxP gt )outprintln(ltcentergt) ou t println ( ltformgt)

outprintln(lthr noshade size=lgt)

outprintln(ltBgtExamplesltBgt)outprintln(ltULgt)outprintln(ltLIgtEntering ltbgtampquotJava Servlet

Programmingampquotltbgt in the title field )outprintln(and choosing ltemgtExact Titleltemgt finds the

book without also finding the many books)

outprintln(ltLIgtEntering ltbgtampquotJavaampquotltbgt in the Title field and choosing ltemgtTitle Wordsltemgt)

outprintln( finds all books whose title are related toltigtJavaltigt)

outprintln(ltULgt)

out printl n( lttdgtlttrgt) outprintln(lttablegt)

ielse if (pathequalsIgnoreCase(ISBN))

Create isbn request collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n ter ISBN ltbxfontgt)outprintln(ltbrgt) outprintln(ltform method=POSTY

action=httplocalhost8080servletISBNProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

a lig n = le ftx ttx b gt IS B N lt b x t tx td gt ) outprintln(lttd valign=middle a lign= leftx input

type=text name=isbn size=40 value=xtdgt)outprintln(lttrgt)

outprin tln(lt trxtd c o ls p a n = 2 x p x b rx td x trgt ) outprintln(lttablegt)

out println( ltcentergt)outprintln(ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln(ltinput type=reset value=Clear

FormV id=resetl nam e= resetlxP gt )outprintln(ltcentergt)outprintln(ltformgt)

outprintln(lthr noshade size=lgt)

outpiintln(ltULgtrdquo)outprintln(lttdxtrgt)outprintln(lttablegt)

else if (pathequalsIgnoreCase(PUBLISHER_DATE))

Create publisher date collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n te r Publisher and Publication D ate ltb gtltfontgt)

1 17

outprintln( ltbrgt) outprintln(ltform method=POST

action=httplocalhost8080servletPublisherDateProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

align=leftgtlt ttxbgt P ub lisher lt b x t t x t d gt )outprintln(lttd valign=middle align= leftx input

type=text name=publisher size=40 value=xtdgt)outprintln(lttrgt) outprintln(lttrgt lttd valign=middle

a lign= leftx ttxbgt P ub lica tion D a te lt b x ttx td gt )outprintln(lttd valign=middle align= leftx input

type=text name=publication_date size=40 value=xtdgt)outprintln(lttrgt)outprintln( c t r x td c o l s p a n = 2 x p x b r x td x t r gt )outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search Now

id=submitl name=submitlgt)outprintln(ltinput type=reset value=VClear FormYrsquo

id=resetl nam e= resetlxpgt )outprintln(ltcentergt) outprintln(ltformgt) outprintln(lthr noshade size=lgt)

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush()outclose()

)

protected void CreateHeader(PrintWriter out) outprintln(lthtmigt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding bgcolor=EEEECCgt)

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20pubiic_htmlflowergifgtlttdgt) outprindn(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(lt s tro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x stro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt)outprintln(lttd w idth=20xtdgt) ou t println ( rsquo lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

out pri ntln ( ltfon tgt) outpri ntln( ltcentergt ) out pri ntln ( ltpgt) outprintln(ltcentergt) outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)out pri ntln ( ltf on tgt) outprintln(irltcentergt) out println ( ltbodygt) out pri ntln( lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

cellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=YT00 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE= -lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

1 gtS earch B ookslt fontx stronggt)outprintln(lttdgt lttrgt)out pri ntln (lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=l-lgt)

outpri ntln(ltahref=httplocalhost8080servletReqCoilectauthorgtA uthorltfontxaxtdgtlttrgt)

120

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprindn(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=V-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln(lttablexpgt)outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

121

13 ShoppingCartjava

ltpgt This is the definition for ShoppingCart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import Javautil

public class ShoppingCart Hashtable items = null int numberOfltems = 0

public ShoppingCart() items = new Hashtable()

add BookDetails to cart param bookID isbn param book book need to be added to cart copyreturn void

public void add(String bookld BookDetails book) if(itemscontainsKey(bookId))

ShoppingCartltem scitem = (ShoppingCartltem)itemsget(bookld) scitemincrementQuantity ()

else ShoppingCartltem newltem = new ShoppingCartltem(book) itemsput(bookId newltem)

numberOftems++

param bookld isbn

public void remove(String bookld) if(itemscontainsKey(bookd))

items remove (bookld) numberOfltems - -

public Enumeration getltems() return itemselements()

protected void finalize() throws Throwable items clear()

public int getNumberOfItems() return numberOfltems

public void clear() items clear() numberOfltems = 0

123

14 ShoppingCartltemjava

ltpgt This is the definition for the shoppingcart item Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class ShoppingCartltem BookDetails item int quantity

public ShoppingCartItem(BookDetails anltem) this item = anltem this quantity = 1

public void decrementQuantity() if (quantity gt 0)

quantitymdash

public void incrementQuantity() thisquantity++

i

public BookDetails getltem() return thisitem

public int getQuantity() ( return thisquantity

i

124

15 StandardFooterjava

package servlets

import j avax servlet

ltpgt This is a server side include servlet that will format the TinyBookStore HTML footer

public class StandardFooter extends GenericServlet

ltpgtPerform the servlet service

param req The request from the client param res The response from the servlet public void service (ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the response javaioPrintW riter out = new

javaioPrintWriter(resgetOutputStream())

Format the standard footeroutprintln(ctable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(rdquoltfont s iz e = - lx a href=topgtTop of

P agelt ax fon tgt )outprintln(lttrgt) out println( lttablegt) outprintln(ltcentergt) outprintln(rsquoltfont size=-lgt)outprintln(lta href=7welcomeshtmlYgtTinybookstorecom

Homeltagt ampnbsplampnbsp)outprintln(lta href=categoryhtmlgtCategoryltagt

ampnbsplampnbsp)outprintln(lta href-authorhtmlgtAuthorltagt

ampnbsplampnbsp)outprintln(lta href=titlehtmlrdquogtTitleltagt ampnbsplampnbsp)

125

outprintln(lta href=isbnhtmlgtISBNltagt ampnbsplampnbsp) outprintln(lta href=7publisherhtmlgtPublisheramp44

Dateltagt)outprintln(ltpgt)outprintln(ltfontgt)ou t println ( ltcen tergt)outprintln(ltpgt)out println (ltcentergt )outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and

disclaim er^A gt ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln( ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

outflush()outclose()

126

16 StandardHeaderjava

package servlets

import javaxservlet

ltpgt This is a server side include servlet that will format the standard TinyBookStore HTML header The Title of the page will be set to the value of the title property

public class StandardHeader extends Generic Servlet

ltpgt Performs the servlet service param req The request from the client param res The response from the servlet

public void service(ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the responsejavaioPrintWriter out = new javaioPrintWriter(resgetOutputStream())

Get the title of the page Set to empty string if no title parameter was givenString titles[] = reqgetParameterValues(title)String title = if (titles = null)

if (titleslength gt 0) title = titles [0]

outprintln(lthtmlgt) outprintln(ltheadgt) outprintln(lttitlegt + title + lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=T00 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)

127

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src=dJavaWebS erver2 Opublic_htmlflower gi A gtlttdgt) out println(lttd width=3 O x td gt ) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyB ookStorecom ltigtlth2xstrongxtdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) out printl n ( lttd width=20gtlttdgt) out printl n( lttrgt) outprintln(lttablegt)

outflush()outclose()

128

17 TitleProcessjava

ltpgt TltleProcess This is the servlet that process the Tltle-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import j avax servlet import javaxservlethttp import javaio import j avasql

public class TitleProcess extends HttpServlet protected final String EXACT = exact protected final String OTFIERS = titleWords

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

129

String[] valuesString name =

values = reqgetParameterValues(title) if (values = null)

name = values [0]

String mode =values = reqgetParameterValues(title_mode) if (values = null)

mode = values [0]

String sqlStmt =if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where title=rdquo + name +else

sqlStmt = select from BOOK where title like rsquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString()

130

outprintln(lta href=servletDetailContent + isbn+

outprintln(rsgetObject(Title)toString() +ltagtltbgt)

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toString())

outprintln( +rsgetObject(Publisher)toString() + + rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +rsgetObject(Price)toString())

outprintln(ltbrxbrgt)i

if (count == 0) outprintln(ltdtgt No matched data found)

ioutprintln(ltdlgt) II end Glossary List

catch (SQLException e) i create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

131

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=EEEECCgt)

outprintln(rdquolttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaW ebServer20public_htmlflowergifxtdgt) outprintln(lttd w idth=30xtdgt) outprintln(rdquolttd align=left valign=center width=300gt)

outprintln(ltstronggtlth2gtltigtTinyBookStorecomltixh2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(rdquolttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln( lttrgt)outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(rdquolta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(rdquoltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

132

out println( ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) outprintln( ltcentergt) outprin tln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disciaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) S y s te m out println( LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt )

outprintln(lttable width= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y- lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost 8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

133

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lt tab lex pgt )

ou t pri ntl n ( lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

134

18 checkouthtml

lthtmlgtltheadgt lttitlegtCustomer Informationlttitlegt ltheadgtltbodygt

lt hlgt ltcentergt ltbgt Customer Information ltbgt ltcentergt lt hlgt

ltform method=POST action=httplocalhost8080servletCustomerInfoProcessgt lttable border=0gt

lttrgtlttd align=rightgtFirst namelttdgtlttd colspan=2 align= leftx input type=text name=firstname size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtMiddle initiallttdgtlttd colspan=2 align= leftx input type-text name=middleinit s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtLast namelttdgtlttd colspan=2 align= leftx input type-text name=lastname size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtEmail addresslttdgtlttd colspan=2 align= leftx input type=text name=email s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgt Account pass word lttdgtlttd colspan=2 align= leftx input type=text name=password s ize= 40x tdgt

lttrgtlttrgt

lthrgtlttrgt

lttablegtltbrgt

ctable border=0gtlttrgt

lttd align=rightgtCredit card numberlttdgtlttd colspan=2 align= leftx input type=text name=creditcard s ize= 40x tdgt

lttrgtlttr valign=topgt

135

lttd align=rightgtCredit card typelttdgtlttd align=leftgtltinput type=radio name=cardtype value=visagtVisaltbrgtltinput type=radio name=cardtype value= mastercard gtMasterCardltbrgt lttdgtlttd align=leftgtltinput type=radio name=cardtype value=bluebirdgtBluebirdltbrgtltinput type=radio name=cardtype value=fishergtFisherltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtCredit card holderlttdgtlttd colspan=2 a lign= leftx input type=text name=cardholder s ize= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCredit card expire date (mmddyy)lttdgtlttd colspan=2 align= leftx inpu t type=text name=expiredate size= 40x tdgt

lttrgtlt trx trgtlt trx trgtlttr valign=topgt

lttd align=rightgtSelect shipping methodlttdgtlttd align=leftgtltinput type=radio name=shipping value=upsgtUPSltbrgtltinput type=radio name=shipping value=expressgtExpressltbrgtlttdgtlttd align=leftgtcinput type=radio name=shipping value=normalgtNormalltbrgtltinput type=radio name=shipping value=abnormalgtAbnormalltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtReceiver Namelttdgtlttd col span=2 a lign= leftx inpu t type=text name=receiver size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtAddresslttdgtlttd colspan=2 align= leftx input type=text name=address size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCitylttdgtlttd colspan=2 align= leftx inpu t type=text name=city size= 4 0 x td gt

lttrgtlttrgt

136

lttd align=rightgtStatelttdgtlttd colspan=2 align= leftx inpu t type=text name=state s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtZipcodelttdgtlttd colspan=2 align= leftx inpu t type=text name=zipcode size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtPhonelttdgtlttd colspan=2 align= leftx input type=text name=phone size= 40x tdgt

lttrgtlttablegtlt b rx b rgtcinput type=submit value=Process name=actiongt

ltformgt

ltbodygtlthtmlgt

137

APPENDIX C

Screen Display of the Test

138

mmm File Edit View Favorites T o d s Help

^ Jit j j ^ LJ U 3) ~ pound=J _Am Back - S top Refresh Home j Search Favorites History Mait Print Edit

Links gtgt Address |4S ] httDVIocalhost808QAvdcorne shtml

TinyBookStore com

Welcome to the TJnyBoakStoro com

F i v e H o t B o o k s

1 T h e C + + Programming LanguageU s u a l l y s h i p s i n 24 h o u r s

B j a r n e S t r o u s t r u p A d d i s o n - W e s l e y Pub Co 1997 Our P r i c e 31 47

2 - P r o g r a m m i n g V i s u a l C + +U s u a l l y s h i p s i n 24 h ou r I I

Local intranet

Search BooksHorne

Category

Author

Title

ISBNPublisherDate

3 iigt60

3 1 S earch T inybooksloiecom - Microsoft Internet Explorer

139

T inyB ookStorecom - Microsoft Internet Explorer

j File Edit View Favorites lo o k Help

q a a H 3 1 d B ack S top R efresh Home S earch Favorite History j M aJ Print

Links gtgt A ddress httpV localhost 308QoryleV PetailCorterV 020i8SC l4

MM

Edit

Search Books

Home

Category

Author

Title

ISBN

PublisherDate

TinyBookStore com

The C++ Programming Languageby B j a r n e S t r o u s t r u p

0

ISBN 0 2 0 1 8 8 9 5 4 4 A d d i s o n - W e s 1e y P ub Co 199 7

Reviews

P r i c e 31 47A v a i 1ab i 1i t y U s u a l 1 ys h i p s w i t h i n 24h o u r s

Aic t o c a r t

ijgJ Local intranet

140

^ | I myBook5torecom Shopping Cart - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

[v] I ^ -J JB ack - Stop R efresh Home S earch Favorites History lsquo Mail Print

Links A ddress 0 1 h ttp localhost8080servetA ddT oShoppingCart ~3 ltGdeg

Shopping Cart Item s Price

The C++ Programmi ng LanguageB j a r n e S t r o u s t r u p Q u a n t i 1 7 1

Price $ 3 1 4 7 Subtotal $ 3 1 4 7

d e l e t e

Total 31 47

Customer Information Microsoft Internet Explorer

File Edit View Favorites lo o ls Help bull _

bullgt 3i 4 n j j d a 31Back ~-j Stop- R efresh Home S earch Favorites History j Mail Print Edit

Link gtgt j Address ] j j h ttplocalhost SOSOcheekoot html

EMH1

~3

Customer Information

First name jFang

Middle initial |a

Last name Xiao

Email address fxiaomitecnet

Account password pooooc

0 1 Done

Credit card number 1234567891234567

Credit card type VisaC MasterCard

C Bluebir d C Fisher

Credit card holder jr ong Xiao

ard expire date (mmddyy) J010102

Select shipping method UPSO Express

O Normal C Abnormal

J |sect Local intranet

141

lt2] Order List - Microsoft Internet ExplorerFile |d i t View Fayotites lo o t Help

^ 3 ^ S i l S - j S tep R efresh Home Search Favorite History Mail Print h-

HFte-LLinks A ddress I g ] httplocalhost8030servletCustemeilrifoProcess 3 ^Go

Your order reads as followsE - M a i l A d d r e s s f x i a o

F a n g X i a o

ship to

T e l

11 e m s

pound] Pc

10821 W e s t e r n P l a z aOmahaME6 8 1 5 4

( 4 0 2 ) 4 9 6 - 7 5 7 0T i t l e T h e C++ P r o g r a m m i n g L a n g u a g e Q t y 1 P r i c e 31 47 S u b t o t a l 31 47

| a [ Local intianet rsquo

l i

T inyB ookSloiecom - Microsoft Internet Explorer

T 7 ~ J iii 4 a i t Vi 1+ a Si

5 E

P r i te i+ A d d ie r I ig l httplocalhot8080ervletReqCollectauthor

S e a r c h B o o k s

Horne

Ca t e g o r y

A u th o r

Title

ISBN

P ublishe r Date

jS 1 D one

TinyBookStore com

fc t i t e r l i t n o rYou can enter authors full name first name or last name

A u t h o r |sCOtt

O ExactName amp Last F irst Name (or Initial)

T itiv b o o k s to re c o m H o a e | C a te g o ry | A u th o r | T itle | ISBN | P u b lish e r D ate

C opyright and disclaim ercopy 1999-2001 F an g Xiao

T op o f P f

|sect g j Local intranet

142

linyBookStore^com- MiciosoFUnteinet ExplorerFite Edit View Favorites Tools Ftelp

IIl4 rsquojO IjjlI - 3 -Upraquo 8 a c k ltbullltbullbullltlaquo Stop R efresh Home S earch Favorites History Mail Print 1

| Links 1 Address j raquo 3 http7localhost8CI80servletAuthorProcess

l - i f l |x |

S e a r c h B o o k s

Home

C a t e g o r y

Ti t le

ISBN

P ublishe r D a te

D o n e-

TinyB o okStore com

1- Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

I G aleampory I A utho t | I jt te | ISBN | PubH shei^D atg

i t and disclaim erreg 1999-2001 F ang Xiao

Top of

l i Local intranet

j T iny8ookStorecom - M icrosoft Internet Explorer

Fite Edit View Favorites Tools Help

4- 5 ni M m ~ltpound C r =gt 2f|L i p | | | | | iAdiiill|^Thttp7localhost8080seivletD etailContent0201924889

U 3

S e a r c h B o o k s

H ome

C a t e g o r y

A u th o r

Title

ISBN

P u b lish e r P a te

TinyB o okStore com

Effective C++b y Scott Meyers

ISBN 0201924889 Addison-Wesley Pub Co 1995

R eviews

This is the review of Effective C++

R eader Comments

Price 3795 Availability U sually ships within 24 hours

Add to iosil

IIH LdcSiiihttahdt

143

l inyBookStorecom Shopping Cart - Microsoft Internet Explorer

4- -- _ t lS M JJ ltpound I 7 r mdash2--I or- Stop R efiesh Home S ea rch Favorites History Wait PrintBach

Links Y 1^ddtessj-^1 httDvVlocalliostiBOBOyservletMddToShoppinqCart 73 ^

0

Shopping Cart Item s

Effective C + +Scott Meyers Quantity 1

0 1 Done

delete

Price

Price $ 3 7 9 5 Su b to ta l $ 3 7 9 5

Total 3 7 9 5

IB~ht Locai intranet

bull 3 TinyBooKGIoFooom M icrosoft Internet Cxplorcr

Fite Edit View Favorites Tools Help

4- -4gt Lfl 4 r amp J J lt$ i icirsquo s J ~lAB ack Ti(^poundprV aTdV iS^Stop-T SfSjefre^ptr I i - M t s s j r y rvlih- i JPopSnr -JE

i i i l l l P I I I ^ I i l l ] httplocalhost8080servletR eqC ollectauthor

G3SJ

7 ^ Go

S e a r c h B o o k s

H om e

C a t e g o ry

A u th o r

Title

ISBN

Eytoiisiier Date

101 D one

T i n y B o o k S t o r e c o m

E n te r AuthorYou can enter authors full name first narne or last name

A u t h o r jCraig Larmen

E Exact N ante O Last F irst N ame (or Initial)

Search Now 1 Clear Form

I C ategory | A u th o r | j j t l s | ISBN |

C opyright and ctiiclali[er copy 1999-2001 F an g Xiao

T o p o fP ag e

^tDpcafihttangfe-

144

gj TinyBbokSlorecom - Microsoft Internet ExplorerFile Edit View F a v o n te s - Pools

4-1 4 gt_poundj Q Jl3S top R efresh Home S ea rch Favorites History Mail PrintCacl-

lsquo Unko A ddress j ig ] httplocalhostSOSCiservletAuthorProces 71

S e a r c h B o o k s

Home

C a t e o o r v

A u th o r

Tit le

ISBN

P ub l i she r D a t e

Titty Bo okStore com

1 Applying UM L and Pattern Usually ships in 24 hours Craig Larmen Prentice Hall 1997 Our Price 450

T im booksto re com Home | C ateg o ry | A u th o r | Title | I3BM | Publisher P a ts

C opyrigh t and disclaimer copy 1999-2001 F an g X iao IIg ] http7localhost 8080eopyright html Local intranet

7 j T inyBookStorecom - Microsoft Internet Explorer

^ 03 4 31 0 i -_r _j _T B ack ~j~ S top R efresh Hom e Search Favorites History Mail Print Edit

I Links Addiess AocalhcistiiiOciOserv-letCctailConfent0137488S07

u m m

S e a r c h B o o k s

HorneC a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r Date

Tiny Bo okStore com

Applying LOVIL and Patternby Craig Larmen

0 Price 450 Availability TJ sually ships within 24 hours

ISBN 013748880 Prentice Halil 997

R ev iew s

Tins is the review o f Applying UML and Pattern

R ea d er Com ments

Add to cart

01ll iPdSSIihirSdety

145

3 TinyBookStorecom Shopping Cart bull Microsoft internet ExplorerFile Edit View Favorites Tools Help

vJBeck

JStop Refresh

4Home

H Si - iS- -=dSearch Favorites History Mail Pnnt

Links rdquo Address jlti] httpVlocalhostBOSOservletAddToShoppingCart 3 ^ Gc

r o 1

Shopping Cirt J toms Price

A pplying UML and PatternCraig Larmen Quantity 1 Effective C++Scott Meyers Quantity 1

l i l le t e

delete

Price $ 4 5 0 Subtotal $45 0

Price $ 3 7 9 5 Subtotal $ 3 7 9 5

Total 82 95

d f g a j Local intranet

146

lt3 TinyBookStoiecom - Microsoft Internet ExplorerFile Edit View Favorites Io o ls Help

gt j i 4 a - a i [j JB ack Forward Stop Refresh Home S earch Favorites Histeiy Mail Print Edit

Links Address ] pound ] hiipVonahost803CeerveirsquoReqColectlsquoauthor

0 1 i

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r D a te

Tiny Bo okStore com

You can enter authors full name first name or last name

A u t h o r jJeff

O Exact N ame Last First N ame (or Initial)

Search Now i Clear Form

T inybookstorecotti H oinf | Category | A trthor | Title j ISBN | Publisher Date

Copyright and disclaimer copy 1999-2001 Fang Xiao

Top of Page

M Local intraZl

m TinyBook Stote com - Microsoft Internet Explorer

Fife Edit View Favorites Joo ls Help

ISregBack Stop Refresh Home S earch Favorites History Marl Print c

Lirrks Address samp] httplocalhost8080servletAuthorProcess ~z ^ Gc

S e a r c h B o o k s

H ome

CategoryA u th o r

Title

ISBN

P u b lishe r D a te

i M

TinyBookStore com

1 Progi aimning Windows bullwith M FC Usually slaps in 24 hours JeffProsise Microsoft P ress 1999 Our Price 4799

jnybo-okstorscom Homo | Category | A u th or | Title | ISBN | Publisher P a h

C opyright and disclaijRief copy 1999-liOO1 FangX iao

Loccii intranet

147

148

m I myUookSlorecom - Microsoft Internet ExplorerFile- pound d it View Favorite T ools Help

^ J ] 4 U J j j =jgt Stop R efresh Home S e a rc h Favorites History i Mail Print EditBack

Links AddressilaquojigThttplocalhost5 i380ser4eM D etailContent157231 pound350

rfgKxi

ldquo3 gt6deg

S e a r c h B o o k s

HorneC a teg o ry

A u th o r

Ti tle

ISBN

P ub l i she r D a t e

TinyBookStorecom

Programming Windows with M FCby JeffProsise

0

ISB N 1572316950 Micro s oft Pre s s 19 9 9

Price 4799 Availability Usually ships within 24 hours

R e N ew s

This is the review of Programming Windows with MFC

R eader Comments

A dd to cart

D one i jh j Local intranet

lt 3 TjryBook S tore com Shop p in g Cart - M icrosoft Internet Exolorer

File Edit View f a nute T ools Help

r 1B ack

J 3 Q 0J amp poundlr - Jlilip isS h lA ld rS s httpy |ocalhost8U 80AervletA ddToShoppingCait TSIIlli

Shopping Cart Item s

Program m ing W indow s w ith M F CJeffProsise Quantity 1A pplying UML a n d PatternCraig Larmen Quantity 1 E ffective C++Scott Meyers Quantity 1

d e le te

d elete

d elete

Price

Price $ 4 7 9 9 S u b to ta l $ 4 7 9 9

P rice $ 4 5 0 S u b to ta l $ 4 5 0

Price $ 3 7 9 5 S u b to ta l $ 3 7 9 5

Total 1 3 0 9 4

^ h W h e iM

S s i Local intranet

149

File Edit View Favorites lo o ls Help n4- -0 iS - M L U

Back Stop Refresh Home Search FavoritesJ

History I3 H H H B H H H BMail Pm Edit

Links rdquo Addrecs |s] hHplocalhogt5t8080servletReqCollectcategorii ^_____ bulllt bullbull llilltllll

Search Books

Home

Category

Author

Title

ISBNPublisherDate

TinyBookStore com

P r o g r a m m in g

AI g o r i t Lins CampC++ D e l p h i J a v a MFC P e r l s o f t w a r e D e s i g n UML V i s u a l B a s i c M o r e

Done

Web D e v e lo p m e n t

ASP Commercem C y b e r c u l t u r e HTML J a v a S c r i p t S e c u r i t y Web D e s ig n XML more

G r a p h i c s amp S o f t w a r e

Asobe CAD D es k t op P u b l i s h i n g G r a p h i c s M i c r o s o f t More

I J J ig Local intranet

150

finvBookStorecom - Microsoil Internet Explorer - j g j x

j Fite Edit Jfiew Favorites lo o ts Help

bull j 5 a i B ack lsquolti S top Refresh Home S e a tc h Favorites History Mail Print Edit

Links 1 Address |ltg] hitpVocalhostl-i030seryletCateciofyPreceigtVc03 ^ | g

S e a r c h B o o k s

Home CategoQ

A u th o r

Title

ISBN

Publishe r D a te

TinyBookStore com

1 Core Ja v a 2 Usually ships in 24 hoursCay S Horstmaun Prentice Hall 1999 Our Price 2579

2 Ja v a S erv let Programm itig Usually ships in 24 hoursJason Hunter i O Reilly 1993 Our Price 1977

3 Ju st J a v a 2 Usually ships in 24 hoursPerter van der Linden Prentice Hall 1999 Our Price 3149

Tinybookstorecom Home | C ategory | A u th o r | T itle | IbBN | Publisher D ateloRoIEage

n g Local intranet

ta

151

41 Tinytfookbtorecom - Microsoft Internet ExplorerFile gdit y iew Favorites JLools Help

1 ^ hgt a a a amp a j ri i - 3 bull a Back Forward Stop Refresh Home S earch Favorites History Mart Print Edit

lisLinteslsii Address ji^]h ttp localhost8D 8o7serv letD etailC ontent0130319336

M i

3 f^Gc

S e a r c h B o o k s

Homec a t e g o r y

Tiny Bo okStore com

Core Java 2by Cay S Horstmaun

El

ISBN 0130819336 Prentice H alil999

Reviews

This is the review of Core Java

R eader Comments

Price 2579 Availability U sually ships within 24 hours

I Add to car

S ] Done S i Local intranet

TinyBookStorecom Shopping Cart - Microsoft Internet Explorerfel11 File Eefit View Favorite l o o k H e lp

tljH|V| 4 a 3 j 09 c T J

Stop Refresh Home S e a rc h Favorites History j Mail Print

jiiLihkIi87js ^ B ie s S ij^ ] http Z localhost8080servletiddT oShoppirigC art

B I B

3= i

Shopping Cart Item s

Core Java 2Cay S Horstmaun Quantity 1

Icopy

t i l

delete

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Total 2 5 7 9

sal Local intranet

152

a TinvBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites J o o lr Fjelp

NBack

amp Id b iStop Refresh Home

ISearch Favorifes History - Mail Print Edit

Links gty I Address [ jg l httplocalhost8080servletD etailContent156592391 x d

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

T i t le

IS B N

Publisher Date

ampJ Lrl e

Tiny Bo okStore com

J a v a S erv le t Piograitmmigby Jason Hunter

a Price 1977 Availability XT sually ships within 24 hours

ISBN 15659239 lx O Refflvl998

R e N ew s

In this brand-new third edition of Java Servlet Programming author Bjame Stroustrup the creator of Java presents the full specification for the Java language and standard library a spec that will soon become the joint ISOANSI Java standard

j ~2J Local intranetm

dH T iny8ook5torecom Shopping Cart - Microsoft Internet Explorer

File pound d t y iew Favorites Io o ls HelpB H

a $ a i a a -Stop Refresh Home S ea rch Favorites Hi lory Mjl

3- lsquonr I

| j | i | H | g i | i | i d ^ | | | | l Q httplocalhost80S0servletAddToShoppirigCart J P

m

Shopping Cart Item s

Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d e le te

d e le te

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Price $ 1 9 7 7 S y b to ta l $ 1 9 7 7

Total 4 5 5 6

I O I

aiil

153

Lustomer Information - Microsoft Internet Explorerpoundite pounddit View Favorites Xoo|s Help

v- _) _ l 4 J I VB ack - Stop R efresh Home Search Favorites History Mail

Links gty] A ddress ] j i l h ttD localhost8080checkouthtm l

F -iVj ~f

l l i l i i

C u sto m er In fo rm a tio n

First name jFang

Middle initial lA

Last name fXiao

Email address jfxiao m itecnet

Account password jxxxxx

Credit card number ]1234567B91234567

Credit card type C VisaC M asterCard

C Bluebird O Fisher

Credit card holder jFang Xiao

Credit card expire date (mmddyy) jo 10102

Select shipping method c u p sC Express

NormalAbnormal

0 ] D one Local intranet

poundpound Order List - Microsoft Internet Explorer

s

Back

Li il raquo

Yiew Favorites l o o h Help

bullV Y lJ j X I T- lty S to p Refresh H o m e

amp 1 3 J - jrS earch Favorite History lt Mail Print

fcesssaampl httplocalhost8080servletCustom erlnfoProcess

Y o u r ord er reads as fo llow sE-Mail Address 6daomitecnet

Fang Xiao

ship to

Tel

Items

12345 Western PlazaOmahaNE68154(402) 123-4567

Title C ore Java 2 Qty 1 Price2579 Subtotal 2579

Tide Java Servlet ProjammingQty 1 Pnce 1977Subtotal 1977 Total4556

ffl|b ] Done kl Local intranet

154

mammmm 1

File Edit View Favorites lo o ts tieip

E=cl i u F t l H -n e -i i rdquo F j-oiilsquoiBillHistory lsquo gt1 ll Print Edit

iiiiiiiiiiiiiiiiiirsquo Links Address j-copy] http localhust 8080servletReqCollectisbn J

TinyBookStore com

Search Books

Home ISBN

Author

Title

IS B N

S e a r c h Hew C le a r Form

PubnsheuDate

Top o f PageITnjrbooksj^ore^ com Horne I C a te g o rv | ^ i t h o r | T i t Ie I ISBN | Publisher Date

- g ] http locdlho-st SOSOwelcome shtrnl

TinvBookStorecom - Microsoft Internet Exploier

poundaj Local intranetId

| File Edit View Favorites Tools Help

i -e -e u u r5_ _ _ a u ^ 4 - a a j Back Forward S top Refresh Home S earch Favorites History Hail Print Edit

Links A d d re ss ^ hitp rsquoIdcanc-stEtnSOservlltlsquoF-aqZoll-~ntispn z raquo h

TinyB o okStore com

S e a r c h B o o k s

Horne

A utho r

T itle

ISBN

P u b lish e r P a t e

fcntar ISBN

I SB H 1565922840

|sectplli||pbw||l| IliM M pifiillj

T rgU onL cirrti -nr Kini- | Cgtgpound-gg | Agithor | Title | ISBN f uhhe-rt Pete

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top o f Pag e

aipoundbull] O o n e Local intranet

155

File Edit View Favorites Tools Help

HUTinyBookStorecom - MicrosoH InternetExplorer

B ad-J J A J d -2r =3

Stop R efresh Home S e a rc h Favorites History Mail Print

Links ygt A ddress j ^ ] httpVlocalhost8080servletrsquoISBM Process

S e a r c h B o o k s

Horne

C a t e g o r y

A u th o r

T itle

IS B N

Pub l i she r D a t e

TinyB o okStore com

1 Learning Perl Usually ships m 24 hours Randal L Schwartz O Reilly 1997 Our Price 1997

T in vh ooksto re c o m H orne | C at ego tv | A u th o r | Title | ISBM | Publisher D ate

C opy rig h t a n d d isclaim ercopy 1999-2001 F a n g X iao

0 ] Done

yen

ighj Local i

TinyB ookStoiecom - Microsoft Internet Explorer

Erie Edrt View Favorites- lo o ls Help

-s pound] 4 pound1 jLl icArdquo =pound 2 S top Refresh Home S earch Favorites History Marl Print Edit

iilHI

NpBack

httpyiocalhostSOBOservleMDetailContentAI 565922840 ~T] Cm

Tiny Bo okStore com

S e a r c h B o o k s

H o m e i

C a teg o ry

A u th o r

T itle

ISBN

Publishe r D a te

Learning Perlby Randal L Schwartz

I ^

ISBN 1565922840 O Reillvl997

Price 1997 Availability U sually ships within 24 hours

Reviews

This is the review of learning Perl

Reader Comments M0 ] Done lsquofR | Local intranet

156

IHHHHHI _ I f f i x |

File E d t yiew Favorites J o e ls H elp 11v- -__ l

Back ~ rc Stop R efresh Home S earch Favorites HistoryJ rMail

HH1111Pgtnt

Links A ddress | ] http7docalhost8030servleM AddToShoppingCart 3 tgt G o

O S III

Shopping Cart Item s

Learning PeriRandal L Schwartz Quantity 1

delete

Price

Price $ 1 9 9 7 Subtota l $ 1 9 9 7

Total 1 9 9 7

s

Done Local intranet

Eg W illi 1 lttMM41 i H H p n B n 1 0 1 x i

Fite Edit View Favorites Toots Help E H

1$3 L plusmn J8ack Forward Stop Refresh Home Search Favoutes

4History i

- i V -=JMail Print

-Edit

71 Address http7localhost8080lsquoservletFleqCollecVisbn I l f i l l l

TinyBookStore com

Search Books

Home

C ateao rv

Author

Title

ISBN

Publisher D a te

Enter ISSN

i s bit [l 565921496

Search Now I Clear Form

Tinybookstore o n Home | Category | A uthor | Titb | ISBN | Publisher Dte

Copyright arid disclaimer copy 1999-2001 Fang Xiao zl amp j Done Js J Local intranet I

157

H H H r f e i x i File Edit View Favorites Lools Help

- J j j j ] JBack Stop Fiefresh Home Search

J JFavorites-

-J i C rHistory Mail Print

111111811i n

r Links wj i Address |reg] http docalhost 8080servletIS8N Process

S ea rch B ooks

Home

Category-

rdquo A u th o r

T i t l e

IS B fi

P u b l i s h e r D a ta

Tiny Bo okStore com

1 Programtning Perl Usually ships in 24 hours Larry Wall O Reilly 1997 Our Price 2397

T o o k s t o r e c o m H P in e | C a t e g o r y | A u t h o r | Till | IS B N | P -ubtu-hai D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g X ia

T o p o f P a g e

zlamp2 Done Local intranet

158

lt3 l mytfookSlorecom - Microsoft Internet ExplorerF3e Edit View FavoMes lo o ts Help

Back3 U Si S rsquo IStop Refresh Home lt Search Favorites History Mail Print Edit

httplocalhost8080servletDetailContent15S5321496 j3

Search Books

Horns

Category

Author

Title

ISBN

Publisher Date

Done

TinyB o okStore com

Programming Perlby Larry Wall

0 Price 2397 Av ail ability U sually ships within 24 hours

ISBN 1565921496 O Reillyl997

Reviews

This is the review of Programming Perl

Reader Comments

Add to cart

l or=lM

159

Tm vBookSlorecom Shopping Cart - M icrosoft Internet Explorer

i Fite Edit View Favorites lo o k Help

^ Beck R efresh Home

ampS earch Favorites History j Mail Print

E Links I Address ] pound http localhost 8080servletA ddT oShoppingCart rsquo ] O rai

i O

Shopping Cart Jlems

Learning Peri Randal L Schwartz Quantity 1 Program m ing PeriLarry W all Quantity 1

delete

d e le te

Price

Price $ 1 9 9 7 S u b to ta l $ 1 9 9 7

Price $ 2 3 9 7 S u b to ta l $ 2 3 9 7

Total 4 3 9 4

3SJ Done j | s [ Local intranet

160

m m mmmHi mmmHHHHHi1 File Edit View Favorites Tools Help

^ - J J -ih Ji - j| B a d Forward Stop Refresh Home S earch FavoritesHIH ctuv Mjl Print

IHIlllliEd

B l

MbfeifcssfjP Address httplocalhost8080servletFleqCollectpLiblisher_date_ ___ ________ ___________ _ bull bull bull bull_________________ Zi T gt 6 o

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

Title

ISBN

Publishe r P a t e

S ] Done

TinyBo okStore com

T rsquov -

Publisher

sind IPpiIs1iclaquoifciori OsifiC

jAd cl i so n-VVe oI e y Fuo C o ~

P u b l i c a t i o n D a t e 1U97

Search Now Clear Form

T inybookstore com Home | C ategory j A u tho r j I itle | ISBN | Publisher Ds

C opyright and disclaimer copy 1999-2001 F an g Xiao

T op o f Page

g a l Local intranet

161

lt|j TinyBookStoiecom - Microsoft Internet Explorerlsquo Erie Edit View Favorites lo o ls Help

v-1 Q rij - 3 rsquo- a u -=pound Ci Back s lsquoi i 1 Stop Refresh Home S earch Favorites History Mail Print i

jL inks i A ddress 0 1 http7localhost8Q80servletPublisherDateProcess

EMM

3

S e a r c h B o o k s

Home

C a t e g o r y

Author Title

ISBN

Publisher D a te

TinyBookStore com

1- Algorithm s in C Usually ships in 24 hoursRobert Sedgewick Addison-Wesley Pub Co 1997 Our Price 4495

2 The C++ P rogr amming L anguage Usually ships in 24 hourBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

3 Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

4- U M L D istilled Usually ships in 24 horn sMartin Fowler Addison-Wesley Pub Co 1997 Our Price 2995

Done | s j L ocalm

TinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorites l o o k Help

Backamp 3 $ -Q 3 3 AJStop Refresh Home S earch Favorites History Mail Print Edit

Lipikkigt7i Ajddr$esjhttpv7localhost8080-servletDetailCoriterit0201314525

m

3 rgtGc

S earch B ooks

Horne

A uthor

Title

ISBN

Publisher D a te

Tiny BookStore com

Algorithms in Cby Robert Sedgewick

S

ISBN 0201314525 Addison-Wesley Pub Co 1995

Reviews

This is the review of Algorithms in C

Reader Comments

Price 4495 Availability U sually ships within 24 hours

Add to cart

0I reg S a i t^ s a l intranet

162

File Edit View Favorites lo o ls Help

2 ^ iVi ^ ^ t j j B ack gt Stop Refresh Home S ea rch Favorites History ||

- i -Mail Print

WB0BUBSSSI B ifl

Links ygt Addrese |isect ] httpvVlocalhostSOSChservletAddToShoppingCart

Shopping Cart Item s

A lgontfim s in CRobert Sedgewick Quantity 1

0 1 D one

delete-

Price

Price $ 4 4 9 5 Subtota l $ 4 4 9 5

Total 4 4 9 5

Local intranet

163

^ l inyBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

ls31

3 bullrsquo -I- _J _jj - j i_ 3 - j rdquo -= $ ABack Forward Stop Refresh Home Search Favorites History Mail Print Edit

Links rdquo Address 6 J http Vlocalhost SOSOAervletR eqCollectpublisher_date j ^G

Search B o o k s

Home

categoryAutho r

Title

IS B N

Publi sher D a te

TinyBookStore com

liter Publisher and Publication Date

P u b l i s h e r Wrox Press Inc

P u b l i c a t i o n D a t e ]1

Search Now j Clear Form

T invbookstor ecotnHomg | Category | A uthor | Title | ISBN | Pu b lish e rP a t

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top of Page

zD one Local infra

m TinyB ookStoiecom - Microsoft Internet Explorer

R e Edit View Favorites Tools Help

- -i 13 4 St 2J amp t r - JHB-1

fff ij if P S | Address |sjpound~| httpVlocalhost8030servletPublisherDateProcess

S e a r c h B o o k s

Home

C a t e g o r y

A utho r

T itle

ISBN

Publisher D a te

0 ] Done

TinyBookStore com

1 Beginning Visual Basic 6 Database Programming Usually ships in 24 hour John Connell W rox Press Inc 1998 Our Price 3199

2 Befmiung Visual Basic 6 Usually ships in 24 hours Peter Wright Wrox Press Inc 1998 Our Price 3199

T inybookstore com H orae | C ategory | A u thor | Title | ISBN | Publisher Date

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top o f Fas

Local intranet

64

| File Edit Yiew Favorites T ook Help

i A - + - - a S 3 rsquo reg - pound J -3 Back ldquo d Stop Refresh Home Search Favorites History

- vMail Print

i

Edit

IllplBlllll________ g - M

isisfcinbsijp Addre s | g ) httplocalhost8080servletDetailCoritent1861001061 3 Gdeg

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

T itle

ISBN

Publishe r D a te

TinyBookStore com

Beginning Visual Basic 6 Database Programmingby John Connell

a Price 3199 Availability U sually ships within 24 hours

ISBN 1861001061 Wrox Press Inc 1998

Reviews

This is the review of beginning Visual Basic 6 Database Programming

Reader Comments

A d d to c a n

S] pone Local intranet

m u i

lillllEHl ^ bdquo A 3 2tl 4 t M liJ i

Back Forward Stop Refresh Home Search Favorites3

History 4 _ r

M j 1J

Print EditiSillilillllS

httplocalhost8080servletReqCollecttitle

S e a r c h B o o k s

Home

C a t e g o r y

Author

Title

ISBN

Publisher Date

TinyB o okStore com

Enter TicleYou can enter the exact title or part of title

T i t l e C++

O Exact Title Title Words

Search Now Clear Form

Example

bull Entering Java Servlet Programming in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title are related to Java _li

165

lt5 TinyBookStorecom - Microsoft Internet ExplorerFite Edit View Favorites lo o ts Help

Back Stop Refresh Home S earch Favorites History Mail Print

Links gty Addiess http-localhost8080servlet7TitleProcess

i|p1

I

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

Publi sher IS a t e

TinyBookStore com

1 The C++ Programming L anguage Usually ships in 24 hoursBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

2 Effective C+-F Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

3 Programttung Visual C-H- Usually ships in 24 hours David J Kmglinski Microsoft Press 1998 Our Price 3999

T m y h o o k s to e co m H o m e | C a te g o ry | A u th o r | T itle | ISBH | P u b lish er D ate

http iocalhost SOSOservletFleqCollectcategary

T op of P age

~hj Local intranet

bull a TlnjpBflOkStOfecom - Microsoft Internet Explorer

File Edit View Favorite Pools Help

0 3 4 S l i 3 O - J J i t of Stop Refresh Home S earch Favorites History - Mart Print Edit

HBack

i i i i lS i lB i I i f f id i l f f lH Q http Vlocalhost 8080AervletD etailContent1572318570

EEEI

J

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b lis h e r D a f t

TinyBookStore com

Programming Visual C++by David J KrngHnski

[Hj

ISBN 1572318570Microsoft Press 1998

Price 3999 Availability Usually ships within 24 hours

R e v ie w s

This is the review o f Programming Visual1

Reader Comments

Add to cart

if Local intranet

166

mm| File pounddtt View Favorites Jo o ls Help

c J J j j mdash JB ack - J Stop Refresh Home S earch Favorites History

- _ i -M u

J tPrint

t e t a f e w P A ddress | ^ ] httplocalhost8080servletAddToShoppingCart zl -lt1gtSo

Shopping Cart Item s

Programmeng Visual C + +David J Kmgbnski Quantity 1

delete-

Price

Price $ 3 0 9 0 Sub to ta l $ 3 9 9 9

Total 3 0 9 9

D one ^aj Local intranet

TinyBookStorecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

vHBack-

-J a 4 -a si fi- 3 aStop R efresh Home S earch Favorites History j Mail Print- Edit

Links gty A d d re s sL ^ ] hrtpWlocalhostSOSOservleVFIeqCollectAitle

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

ISBN

Pub l i she r Date

TinyBookStore com

Enter TitleYou can enter the exact title or part of title

Title Distil I nrfExact T itle V T itle W o rd s

Search Now | Cle ar Fo rm

Examples

rpound] Done

bull Entering Java Servlet Programming11 in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title arei date 11 j Java JZJ

167

a TlnyBA5kSioiecom - Microsoft Internet Explorergt 0e Edit ifiew Favorites Jock Jd lp

a a amp -a tii j k i Back s - Stop Refresh Home Search Favorites History Mail Print

liilP raquo httpiVlocalhostSOSOservletTitleProcess

E M 3

ldquo3 rgt-

S ea rch B ook s

Horne

C a t e d o r v

A utho r

TiUgt~ ISSN

Publi sher D a te

Tiny BookStore com

1- TJML D istilled Usually ships in 24 nowsMartin Fowler Addis on-Wesley Pub Co 1997 Our Price 2995

| C s rg g o ty | A u th o r | T itle | IStBH I P u b lis h e r D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g Xiao

-jg Local intranetS3

m n ^ i l a i i x l

File Edd View Favorites Joels- Help M Mi r J lt 3 L h f 4 - 0 lt 3

Back i t Stop Refresh Home S earch Favorites History Mail9

PrintM

Edit

Links raquo A ddress j | i ] http do ca lh o d 1030N m letDetailContenr0201325632 Mimas

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

Title

IS B N

Publisher Date

Tiny BookStore com

TJML Distilledby Martin Fowler

0

ISBN 0201325632 Addison-Weslev Pub Co 1997

Reviews

Tins is the review of The UML Distilled

Reader Comments

Price 2995 Avail abilityTJs u ally ships within 24 hours

Add to c a r t

0 3S i] Done |g^iLnealiihfrregei

TinyBookStorecom Shopping Cart Microsoft Internet ExplorerFile Edit View Favorites Jo o ls HetP

IBiiiBlll l l lHBlSglSlllllilMH MlllBliriilllgllSlIlBack - f - i - S top Refresh Home

a J i l ^ j 3 Search Favorites History 1 Mail Print liiii

3 Links ( A ddress j ig j hrtplocalhost803DservletAddToShoppingCart

Shopping Cart Herns Price

UML D istilledMartin Fowler Quantity 1Program m ing Visual C + +David J Kraglinski Quantity 1

Price $ 2 9 9 5 Subtota l $ 2 9 9 5

delete

Price $ 3 9 9 9 Subtota l $ 3 9 9 9d elete

Total 6 9 9 4

  • Electronic Commerce on Business Application
    • Recommended Citation
      • tmp1499779448pdf2JOpQ

Electronic Commerce on Business Application

A Thesis

Presented to the

Department of Computer Science

and the

Faculty of the Graduate College

University of Nebraska

In Partial Fulfillment

of the Requirements for the Degree of

Master of Science

University of Nebraska at Omaha

By

Fang Xiao

Novermber 1999

UMI Number EP73453

All rights reserved

INFORMATION TO ALL USERS The quality of this reproduction is dependent upon the quality of the copy submitted

In the unlikely event that the author did not send a complete manuscript and there are missing pages these will be noted Also if material had to be removed

a note will indicate the deletion

D issertation RyblisMrtg

UMI EP73453

Published by ProQuest LLC (2015) Copyright in the Dissertation held by the Author

Microform Edition copy ProQuest LLCAll rights reserved This work is protected against

unauthorized copying under Title 17 United States Code

ProQuest LLC789 East Eisenhower Parkway

PO Box 1346 Ann Arbor Ml 48106 - 1346

THESIS ACCEPTANCE

Acceptance for the faculty of the Graduate College

University of Nevraska in partial fulfillment of the

Requirements for the degree of Master of Science

University of Nebraska at Omaha

Committee

DepartmentSchoolName

Chairperson_

Date rdquo l l - l l - i m

Acknowledgements

I would like to express my sincere appreciation to my thesis advisor Professor Peter A

NG for his kind guidance time and support I would also like to say thank you to my

supervisory committee Dr Qiuming Zhu Dr Bin Chen for their suggestions help and

cooperation

Abstract

For some time now Whole size business enterprises have used electronic commerce

to conduct their business activities The On-Line store is one of a number of popular

web applications This thesis focuses on one of the emerging On-Line store

technologies which is known as Server-Side Java Application

In early 1960 private networks were dedicated for the use of electronic data

interchange (EDI) and electronic funds transfer (EFT) in banking business Recently

however with the increased awareness and popularity of the Internet electronic

commerce has come to encompass individual consumers as well as businesses of all

size For most people electronic commerce is defined as the buying and selling of

products and services over the Internet but there are many more aspects We will

discuss different definitions of electronic commerce in this paper

The most popular Web applications are the On-Line Stores Most of such applications

involve functions as searching for product information ordering products paying for

goods and services and for providing online customer service A Web server running

continuously accepts userrsquos connection gets user requests and forward requests to

business procedure retrieves data (answers to user requests) from business procedure

and sends it back to the user

An on-line store system is different from a traditional web publishing It needs a

customerrsquos interactive communication and frequent data update The traditional

HTML page does not satisfy the customerrsquos needs because all it does is simply

publish static contents More complex technologies are required in order to produce

dynamic contents

There are a few technologies that can be used for implementing the on-line stores

Common Gateway Interface (CGI) Microsoft Active Server Page (ASP) and Server-

side Java application are the most popular technologies Introducing the Server-Side

Java application is one of the latest and most exciting trends in Java programming

The Server-side Java application has many advantages over the other technologies

Table of Contents

Chapter 1 Introduction 1

Chapter 2 Electronic Commerce 2

21 What Is Electronic Commerce2

22 The Importance of Electronic Commerce3

23 Types of Electronic Commerce3

24 Why Most Internet Based Electronic Commerce Is In

The Business-To-Consumer W orld 6

25 Current State of Business-To-Consumer E-Commerce7

26 The Structure of The On-Line Store8

Chapter 3 Technologies For On-Line Store System11

31 Traditional Web Application - Common Gateway Interface(CGI) 11

32 Active Server Page 12

33 Server-Side Java Application 14

Chapter 4 Design of On-Line Bookstore Using Java Servlets

A Practical Verification18

41 The Design of Home Page of Tiny Book Store18

42 Design of Search by Different Requests27

43 Servlets Chaining To Process Requests In Different Levels28

44 Database Connectivity and Search from Database29

45 Session Tracking 35

46 Check O ut42

47 Customer Information Processing 43

Chapter 5 Future Work50

51 Connection Pooling50

52 More Object-Oriented - Better Encapsulation51

Chapter 6 Conclusion 53

Appendix A Bibliography54

Appendix B The Source Code of An On-Line Store System -

Tiny Book Store57

Appendix C Screen Display of the Test 135

List of Figure

Figure 261 The Structure of An Online Store 10

Figure 321 Handle Requests Flow Chart 13

Figure 331 HttpService of The Java Web Server Using Servlets 15

Figure 411 The Home Page of Tiny Book Store 22

Figure 412 One of The Searching by Author Pages26

Figure 441 One of The Outputs of Servlet AuthorProces 34

Figure 451 A Page Show All Information About A Book 39

Figure 452 A Page Show Items In The Shopping Cart After A User

Added Books To The Shopping Cart 40

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A

Book From The Shopping Cart42

Figure 461 A Check Out Page 43

Figure 471 An Invoice Page48

1

Chapter 1

Introduction

As we step in the year 2000 we can no longer look to the past as the guide for the

future A combination of business social and technical possibilities drives the rapid

progress in electronic commerce

Electronic commerce can offer a company both short-term and long-term benefits

Not only can it open new markets enabling a business firm to reach new customers

but it can also make it easier and faster for the firm to do business with their existing

customer base Moving business practices such as ordering invoicing and customer

support to network-based systems can also reduce the paperwork involved in

business-to-business transactions When more of the information is digitized it

allows that business firm to focus on meeting their customerrsquos needs Tracking

customer feedbacks and presenting customer solutions for their clientele are just

some of the opportunities that can stem from electronic commerce

2

Chapter 2

Electronic- Commerce

21 What Is Electronic Commerce

For some time now large business enterprises have used electronic commerce to conduct

their business-to-business transactions In early 1960 private networks were dedicated

for the use of electronic data interchange (EDI) and electronic funds transfer (EFT) in the

banking industry Recently however with the increased awareness and popularity of the

Internet electronic commerce has come to encompass individual consumers as well as

businesses of all size

To many electronic commerce is defined as the buying and selling of products and

service over the Internet But there are many other aspects Depending on whom you ask

electronic commerce has different definitions

From a communications perspective electronic commerce is the delivery of information

productsservices or payments via telephone lines computer networks or any other

means From a business process perspective electronic commerce is the application of

technology toward the automation of business transactions and workflow From a service

perspective electronic commerce is a tool that addresses the desire of firms consumers

and management to cut service costs while improving the quality of goods and increasing

3

the speed of service delivery From an online perspective electronic commerce provides

the capability of buying and selling products and information on the Internet and other

online services [16]

These definitions are valid with their perspectives It is a matter of which lens is used to

view the electronic commerce landscape Broadly speaking electronic commerce

emphasizes the generation and exploitation of new business opportunities by ldquogenerating

business valuerdquo or ldquodoing more with lessrdquo

22 The Importance of Electronic Commerce

As we approach the year 2000 we can no longer look to the past as guide to the future In

the face of strong market forces created by electronic commerce and mounting

competition corporations can no longer plod along historical tracks or seek the

preservation of the status quo Companies are discovering that old solutions do not work

with new problems The business parameters have changed and so have the risks and

payoffs

23 Types of Electronic Commerce

From a broad view there are three distinct general classes of electronic commerce

applications Inter-organizational (business-to-business) intra-organizational (within

business) and customer-to-business application [16]

4

231 Inter-Organizational Electronic Commerce

Inter-organizational electronic commerce makes business more convenient on the

following aspects

Firstly e-commerce can improve supplier management since electronic applications can

reduce the processing costs and cycle times for each purchase order and it can reduce the

number of people who work on purchase orders

Secondly e-commerce can improve inventory management since electronic applications

make the business partners can fast exchange information and easy track their documents

to ensure that they were received This not only can eliminate out-of-stock occurrences

but also can reduce inventory and improve inventory turn

Thirdly e-commerce can improve distribution management since electronic applications

can make the business partners receive the shipping documents as soon as possible and

enable better resource management by ensuring that the documents contain more accurate

data

Fourthly e-commerce can improve channel management since electronic application can

let the business partner post the information to electronic bulletin boards This can

eliminate repeated telephone calls and countless labor hours

Fifthly e-commerce can improve payment management since the business partner are

linked by network so the payments can be sent and received electronically Electronic

payment is more accurate and fast than traditional payment

232 Intra-Organizational Electronic Commerce

5

Intra-organizational electronic commerce facilities the following business applications

Workgroup communications Electronic applications enable manager to

communicate with employees using electronic mail videoconferencing and

bulletin boards

Electronic publishing Electronic applications enable companies to publish

information by using tools such as the World Wide Web On-line publishing can

show information immediately and clearly and reduce costs for printing and

distributing documentation

Sales promotion Electronic application improve the flow of information between

the production and sales forces and between the firms and customers This can

make companies have greater access to market and competitor information

Today Intranets are primarily set up to publish and access vital corporate information

Some of the most common types of information are Human Resources information

employee communications product development and project management data internal

catalogs sales support data equipment and shipment tracking and accessing corporate

database

233 Consumer-To-Business Electronic Commerce

In consumer-to-business transactions customers learn about products through electronic

publishing buy products with electronic cash and other secure payment systems and

even have information goods delivered over the network

6

From the consumerrsquos perspective there are three transactions

1 Electronic applications enable consumers to communicate with each other through

electronic mail videoconferencing and news groups

2 Electronic applications enable consumers to manage investments and personal finances

using online banking tools

3 Electronic application enable consumers to find online information about existing and

new products services

Consumers consistently demand greater convenience and lower prices Electronic

commerce provides consumers with convenient shopping methods from online catalog

ordering to phone banking both of which eliminate the costs of expensive retail

branches Electronic commerce facilitates factory orders by eliminating many

intermediary steps thereby reducing manufacturersrsquo inventory and distribution costs and

indirectly providing consumers with lower prices

24 Why Most Internet Based Electronic Commerce Is In The Business-To-

Consumer World

For the Business-to-Business e-commerce the lack of well-accepted standards is

hindering the success in promoting Business-to-Business electronic commerce

solutions[5] VAN (Value-Added Networks) EDI (Electronic Data Interchange) based

solutions are only accessible to large organizations due to the cost factor Corporate

buyers and suppliers large and small are looking for Internet based solutions to

streamline the procurement procedures and to reduce the cost of establishing trading

relationship and the trading transactions Such demands put forward some fundamental

challenge on issue like trust infrastructure on the Internet standards and inter-operability

etc

25 Current State of Business-To-Consumer E-Commerce

Business activity on the Internet is currently limited to publicizing the business

opportunity and to catalog based sales but it will rapidly expand to include the

negotiations conducted to settle the price of the goods or commodities being traded

These negotiations are currently conducted by human intermediaries through various

forms of auctions bidding systems for awarding contracts and brokerages The role of

the intermediaries can now be performed by Internet trading applications at a fraction of

the cost[4] Trading on the Internet allows a business to reach a large number of potential

customers and suppliers in a shorter time and a lower cost than possible by other modes

of communication and to settle business transaction with lower cost overhead in a shorter

time

Auctioned or brokered sales are the norm in business world for negotiating trades of large

monetary value But consumer sales and small-scale purchases have used the fixed price

mode perhaps because of the high overhead cost of using the auction or brokerage

method The new economics of the Internet will make auctions popular in consumer and

small business transactions also

Auctions are just one form of business negotiations Other examples are competitive bids

for procurement brokeragesexchangescartels and two party negotiations

Nowadays the free-market economy of software agents is in the embryonic stage But in

the near future the software agents will populate the Internet and provide trade and use

a rich variety of information goods and services in an open free-market economy In a

free-market economy of software agents information is produced traded and consumed

by vast numbers of autonomous self-motivated agents An essential task in such an

economy is the retailing or brokering of information gathering it from the right

producers and distributing it to the right consumers[10] The overall research goal is to

characterize and understand the dynamic behavior of information economies very large

open economies of automated information agents that are likely to come into existence in

the Internet

26 The Structure of The On-Line Store

9

Nowadays there are thousands of on-line stores running on the Internet A few well-

known ones are amazoncom and bookpoolcom Most of such applications involve

common functions which are as following

Searching for product information

Ordering products

Paying for goods and services

Providing online customer service

So they have a similar structure as shown in Figure 261 The system contains the

following components

1 A web server running continuously accepts userrsquos connection gets user requests and

forward requests to business procedure retrieves data (answers to user requests) from

business procedure and send it back to user

2 Business procedure usually consists of a user identification procedure like credit card

check user request analysis procedure analyzing requests calculating discomposing (if

necessary) and dispatching request to different data source component Also in some

case business procedure is responsible to compose data obtained from different data

sources into user-readable format

3 Database is the place to hold relevant data These data not only serve as a data source

describing commercial goods and prices but can be used for data mining to improve

store service quality as well Database is updated and maintained by both customersrsquo

input and system applications A customerrsquos input usually includes order information

10

Figure 261 The Structure of An Online Store

(through browser)

Databas

(through browser)client

client

serverWeb

Systemapplication

Busines

procedu

4 System applications can include a search engine running all the time and searching

relevant information from the internet data mining application deals with mining and

analyzing customer and sale data for management use database maintaining application

handles update data when product information changes Varying from system size to

system size not every system has cleardistinct boundaries between these components

The system can be 3-tired or n-tired but these systems all operate in similar ways

11

Chapter 3

Technologies For On-Line Store System

An on-line store system is different from traditional web publishing It needs customerrsquos

interactive communications and frequent data update The traditional HTML page is

insufficient because all it does is provide static content publishing Other technologies

are required in order to implement the on-line store

Currently there are three mainstream technologies which are widely used Common

Gateway Interface (CGI) Microsoft Active Server Page (ASP) and Server-side Java

application We briefly explore these technologies here

31 Traditional Web Application - Common Gateway Interface (CGI)

The common Gateway Interface normally referred to as CGI is one of the first practical

techniques for creating dynamic content With CGI a web server passes certain requests

to an external program The output of this program is then sent to the client in place of a

static file The advent of CGI makes it possible to implement all sorts of new

functionality in web pages and CGI quickly become a defacto standard implemented on

dozens of web servers Even though a CGI program can be written in almost any

language the Perl programming language is the predominant choice However CGI have

some distinct disadvantages

Firstly CGI program is transient A request is made each time to a CGI program It must

be loaded and executed by the Web server When the CGI program is complete it is

removed from memory and the results are returned to the client All program

initialization (such as connecting to a database) must be repeated each time a CGI

program is used

Secondly when a server receives a request that accesses a CGI program it must create a

new process to run the CGI program and then pass to it via environment variables and

standard input Every bit of information might be necessary to generate a response

Creating a process for every such request requires time and significant server resources

which limits the number of requests a server can handle concurrently

Thirdly a CGI program cannot interact with the web server or take the advantage of the

serverrsquos abilities once it begins execution because it is running in a separate process

32 Active Server Page

As shown in figure 321 the following list walks you step-by-step through what

happens if the client requests the page xyzasp

The client requests the page xyzasp from the server The Web server checks the file

extension to see whether a special program (such as the Active server Pages engine)

13

must be invoked to process the request If therersquos a asp extension the Web server

determines that it should invoke ASP to process this page

Figure 321 Handle Requests Flow Chart

Request

Response

WEB SERVERComponents

Databas

ns

ASP File

CLIENT

Active X Data

VBScript

If this page has never been requested before or has been changed since the last

request it must be parsed and the syntax checked and then be compiled by the Web

server Otherwise the page might be read from a cache of recently processed pages

which aids in performance During the parsing process the HTML and scripting code

14

are separated IIS (Internet Information Server) determines which scripting engine is

responsible for which part of the script and delegates the work of syntax checking and

compiling to the proper scripting engine (such as VB Script)

Now the code is executed by the scripting engine using resources from IIS which is

hosting the scripting engines All objects that the language engine cannot handle are

requested by the IIS which is also responsible for handling inputs and outputs for the

external ActiveX objects that are created and used inside the script If it is not able to

supply the object an error is generated

Script output and static HTML code in the ASP file are merged

The final HTML is sent back to the user in an HTTP response

The important point about ASP is that the Script runs entirely in a server to protect the

intellectual property by shielding it from browser which are different from the account

for when writing client-side code The entire server-side code is processed and only plain

HTML - or whatever kind of content you chose to generate - is sent to the client

33 Server-Side Java Application

The rise of server-side Java applications is one of the latest and most exciting trends in

Java programming A Servlet can be thought of as a server-side applet Servlets are

loaded and executed by a Web server in the same manner that applets are loaded and

executed by a Web browser

15

As shown in Figure 331 a servlet accepts requests from a client (via the Web server)

performs some task and returns the results

The client (mostly likely a Web browser) makes a request via HTTP The Web server

receives the request and forwards it to the servlet If the servlet has not yet been loaded

the Web server will load it into the Java virtual machine and execute it The servlet will

receive the HTTP request perform some type of process and return a response back to

the Web server The Web server will forward the response to the client

Figure 331 HttpService of The Java Web Server Using Servlets

RequestResponseRequestResponse

RequestResponse

Java Web Server

Administrative SERVLET

SERVLETHTTP

SERVLETWeb Proxy

Servlets have distinct advantages over CGI program

Servlets are persistent Servlets are loaded only once by the Web server and can

maintain services (such as a database connection) between requests

Servlets are fast since servlets only need to be loaded once

16

Servlets are platform independent Servlets are written in Java and conform to a well-

defined and widely accepted API They are highly portable across operating systems

and across server implementations A servlet can be developed on a Windows NT

machine running the Java Web Server and later can be deployed effortlessly on a

high-end Unix server running Apache

Servlet portability is not the stumbling block it so often is with applets There are two

reasons Firstly servlet portability is not mandatory Unlike applets which have to be

tested on all possible client platforms servlets have to work only in the server

machines that you are using for development and deployment Unless you are in the

business of selling your servlets you donrsquot have to worry about complete portability

Secondly servlets avoid the most error-prone and inconsistently implemented portion

of the Java language the Abstract Windowing toolkit (AWT) that forms the basis of

Java graphical user interfaces

Servlets are extendable Servlets that are written in Java brings all of the other

benefits of Java to servlet Java is a robust object-oriented programming language

which can be extended easily to suit our needs

Servlets are secure The only way to invoke a servlet from the outside world is

through a Web server This brings a high level of security especially if the Web

server is protected behind a firewall

Servlets can be used with a variety of clients

Servlets are tightly integrated with the server This integration allows a servlet to

cooperate with the server For example a servlet can use the server to translate file

paths to perform logging and to check authorization

Servlets are quite flexible An HTTP servlet can be used to generate a complete web

page it can be added to a static page using a ltSERVLETgt tag in whatrsquos know as a

server-side include and it can be used in cooperation with any number of other

servlets to filter content in something called a servlet chain

18

Chapter 4

Design of On-line Bookstore Using Java Servlets A Practical

Verification

Server-side Java application is one of the latest technologies used to implement an onshy

line store system Servlet is a set of classes that come up from Java language It is

designed to be used for server-side Java applications There are many techniques people

can use when they utilize servlet such as Server-Side Include (SSI) Servlet Chaining

Applet and Servlet communication etc We tried to use as many such techniques as

necessary in our implementation to demonstrate the advantages of servlets

The demonstration system module is same as the one we mentioned above Figure 331

We use this module to show how such system works

The system called Tiny Book Store emulates an on-line bookstore selling computer

books It has the full functionality of other on-line stores The only difference between

this system and the other on-line systems is the database size We donrsquot want to spend

much developing time for database maintaining part because this part is similar to

ordinary database maintaining and it is an independent subsystem The Tiny Book Store

mainly consists of three modules user interface business procedure and data access

19

41 The Design of Home Page of Tiny Book Store

The home page - welcome page - is designed using the Server-Side Include technique

That is embedding a servlet inside HTML file with a specific HTML tag ltSERVLETgt

In our case this servlet when invoked can run a query on database via data access

objects to retrieve most recent top 5 best-seller books and then returns the retrieved data

to the place within the page where the ltSERVLETgt tag was As long as the data in

database update timely it is guaranteed that customer will get the most recent data

The embedded servlet is invoked by Java Web Server before the page is sent back to

client Java Web Server processes any HTML file having shtml extension and invokes

the embedded servlet marked by ltSERVLETgt tags

Server-Side Includes are useful when a page is primarily static but contains a few distinct

dynamic portions One of the servlets produces the ldquo Five Hot Books ldquo which is shown in

the following example

Example 411 A Part of Code of welcomeshtml

lt P gt

lth3xstrongxf ont color= f f 6347 gtWelcome to theltigt

TinyBookStorecomltigtltfontgtltstronggtlth3 gt

20

ltstrongxbxh3gtltcentergtFive Hot

Booksltc e n t e r x h3gtltbgtltstronggt

ltbrgt

ltservlet code=EchoServletTaggt

ltservletgt

The servlet EchoServletTag searches database according to some business rule and gets

data from data access objects to produce the Five Hot Books The following example is

the sample code

Example 412 A Part of Code of The EchoServletTagjava

public void service(HttpServletRequest req

HttpServletResponse res)

throws ServletException IOException

res setContentType ( text Jhtml)

PrintWriter out = resgetWriter()

try

Statement stmt = concreateStatement()

21

ResultSet rs = stmtexecuteQuery(select from

book where

title like Programming)

int count = 1

outprintln(ltdlgt)

while (rsnext() ampamp count lt 6)

out print In ( ltdtxbgt + count + )

String isbn =

rsgetObj ect(ISBN) toString()

outprintln(lta

href=servletDetailContent + isbn +

outprintln(rsgetObj ect(Title) toString()

+ lt a x bgt )

out println ( ltddxnobrxfont color=990033gtUsuallY

ships in 24 hoursltBRxfontxnobrgt )

outprintIn(ltbrgt +

rsgetObject(Author) toString() )

outprintIn( +

r s getObject(Publisher)toString() + +

r s getObj ect(PublicationDate) toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

out println ltbrxbrgt )

22

count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()

The servelt EchoServletTag by the business mle that searching a specific table sends a

request query through data access object stmt and gets search result through another

data access object rs It then passes data to the page The content between ltservletgt and

ltservletgt tags in the HTML of home page is replaced by the search result at run time

The center part of the sample result page in Figure 411 is an example

23

Figure 411 The Home Page of Tiny Book Store

gj Search TinybookstGiecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

^ bullgt o a 4 i a a j ugt- a a Back lt7gtn Stop Refresh Home j Search Favorites History Mail Print Etfe

-Six

sfekinlfeSsI 3 Address |iS1 httpiVlocalhosLSOSCVwelcomeshtrnl Cj

f S M B l TinyBookStorecom

Search B o o k sW e l c o m e tc f l i e

HomeFive H ot Books 1 1

Category i-si

IA uthor

Title1 The C + + Programming L a n g u a g e B

Usually ships in 114 hoursISBN

k

IPublisher D a teBjame Stroustrup Addis on-Wesley Pub Co 1997Our Price 3147

m2 Programming Visual C+ +

Usually ships in 24 hours y

David J Krn^dinski Dlicrosoft Press 1998 c damp Local intranet

From this practice we know Server-Side Include not only can produce dynamic portion

of the page but also prevent from other people spy into your code Since Java servlet runs

entirely on a server thus protecting your intellectual property and shielding you from the

browser This means what the client sees can be totally different from what the server

does From the client side it is difficult to figure out how the server works

The left-hand menu items are implemented by using a characteristic of servlet - extra

path information or virtual path The extra path information can be used as a kind of

parameter passed to a servlet In general this extra path information is used to indicate a

24

file on the server that should use for something We use this feature here in an abnormal

way to manage customer requests and process these requests in a single place

Consider a traditional method When a menu item is selected by a customer it redirects

the customer to another page where it hyperlinks to If we have several ten items we

need to pre-create several ten pages This is the disadvantage of static HTML pages

However with servlet which can dynamically generate page content we can direct all the

customer requests to a central servlet and process the requests there according to some

condition (parameters) and then generate the page which customer need to see In this

way we only need one place to hold the code to save serverrsquos space And this place is

easy to maintain

The following is how it was doing for the Tiny Book Store

The Author item uses the following hyperlink

ltA

href = servlet ReqCo 11 ect author gtAuthorlt fontx AxTDgt

ltTRgt

The ReqCollect is the name of a servlet We pass the ldquoauthorrdquo in the hyperlink as a

parameter to ReqCollect When the Author item is selected ReqCollect is invoked by

lava Web Server ReqCollect generates a html page to let a user input author search

condition The ReqCollect code is listed below

25

Example 413 A part of Source Code of ReqCollectjava

public class ReqCollect extends HttpServlet

protected final String AUTHOR = author

public void service(HttpServletRequest req

HttpServletResponse res) throws ServletException

IOException

PrintWriter out = resgetWriter()

String path = reqgetPathlnfo ()

if (path == null)

error handling

else

Create standard header

CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

26

path = pathsubstring(1)

if (pathequalsIgnoreCase(CATEGORY))

Create category request collect

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

outprintln(ltfont color=CC66 0 0

face-verdana arial helvetica size = + lxbgtEnter

Authorltbgtltfontgt )

outprintln(ltbrgt You can enter

authors full name first name or last nameltpgt)

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess

id=forml name=formlgt)

outprintln(lttable border=0gt)

outprintln(lttrgt lttd valign=middle

align = lef txttgtltbgtAuthor ltbxttxtdgt )

outprintln(lttd valign=middle

align = lef txinput type = text name= author size = 40

value=x tdgt )

outprintln(lttrgt)

27

outprintln(lttrgt lttd colspan=2gt ltfont

size=-lgt)

outprintln(ltcentergt ltinput

type=radio name=author_mode value=exact

checkedgt Exact Name)

outprintln(ltinput type=radio

name=author_mode value=lastgtLast First Name (or

Initial) )

outprintln(ltcentergt)

outprintln(ltfontgt)

outprintln(lttdgt lttrgt)

outprintln(lttrgt lttd colspan=2gt ltpgt

ltbrgt lttdgt lttrgt)

outprintln(lttablegt)

outprintln(ltcentergt)

outprintln(ltinput type=submit

value=Search Now id=submitl name=submitlgt)

outprintln(cinput type=reset

value=Clear Form id=resetl name=resetlxpgt )

outprintln(ltcentergt ltformgt)

Create standard footer

28

CreateFooter(out)

outflush()

outclose()

The generated page looks like this

Figure 412 One of The Searching by Author PagesTinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorite l o o k H e lp

^ 3 4 s j ] S o zdStop Refresh Home Search Favorites History Mail Print EditBack bull

I t i h f e l f f httplocalhost8080servletReqCollectauthor

S ea rch Books

Home

C a t e g o r y

Author

Title

ISBN Publisher Date

poundj

TinyBookStore com

You can enter authors foil name first name or last name

A u t h o r jbjarne

C Exact N ame amp Last First N atne (or Initial)

Search Now | Clear Form

Taw boekstofeeoraH om e | Category | A uthor | Title | IS3M | Publisher Date

jpyright and disclaimer copy 1999-2001 F ang Xiao

ihtterteti

42 Design of Search by Different Requests

29

According to different requests the different pages should be produced There are many

common parts in the produced pages So we donrsquot need to code the common parts for

each page We can design the common parts into standard utility classes or static

functions You can simply call the standard classes or functions when you needed them

An example looks like this

CreateHeader(out)

CreateLeftMenu(out)

CreateFooter(out)

The three lines above invoke the standard functions CreateHeader() CreateFooter() and

CreateLeftMenu() which are developed in this thesis writing The CreateHeader()

function produces the top part of the pages The CreateLeftMenu() function produces the

left part of the pages The Createfooter() function produces the bottom part of the pages

You can find the source code in several servlets in Appendix

43 Servlet Chaining To Process Requests In Different Levels

A request can be handled by a sequence of servlets This system is designed to use the

first level servlets to handle the search requests If needed the first level servlets can

cooperates with the second level servlets by passing their processing result to the second

level servlets and let them to proceed the request until the final result is obtained The

final result is returned by the last servlet This is called servlet chaining The request

30

from the client browser is sent to the first servlet in the chain The response from the last

servlet in the chain is returned to the browser In between the output from each servlet is

passed as an input to the next servlet Each servlet in the chain has the option to change

or extend the content W e can see the example in the ReqCollect code

Example 431 A Part of Code of The ReqCollectjava

if (pathequalsIgnoreCase(AUTHOR))

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess id=forml

name=formlgt)

The ReqCollect servlet uses the getPathInfo() method to get the extra path information

This method returns the extra path information associated with request According to the

different extra path information the first level servlet invokes the different servlet of the

second level In this case ReqCollect invokes AuthorProcess servlet The final output

has been listed in Figure 412

31

44 Database Connectivity and Search from Database

The biggest advantage for servlets with regard to database connectivity is that the servlet

life cycle allows servlets to maintain open database connections An existing connection

can trim several seconds from a response time compared to a CGI program that has to

reestablish its connection for every invocation

Another advantage of the servlets over CGI and many other technologies is that JDBC is

database-independent JDBC is a SQL-level API - one that allows you to execute SQL

statements and retrieve the results if any The API itself is a set of interfaces and classes

designed to perform action against any database

An individual database system is accessed via a specific JDBC driver that implements the

javasqlDrivers interface Drivers exist for nearly all-popular RDBMS systems The

database connection used for Tiny Book Store uses a JDBC-ODBC bridge driver coming

along with the JDK 12 to allow access to standard ODBC data source such as the

Microsoft Access database

The first step in using a JDBC driver to get a database connection involves loading the

specific driver class into the applicationrsquos Java Virtual Machine This makes the driver

available later when we need it for opening the connection An easy way to load the

driver class is to use the ClassforNameQ method

32

ClassforName(sunj dbcodbcJdbcOdbcDriver)

When the driver is loaded into memory it registers itself with the javasqlDriverManager

class as an available database driver

The next step is to ask the DriverManager class to open a connection to a given database

where the database is specified by a specified formatted URL The method used to open

the connection is DriverManagergetConnection() It returns a class that implements the

javasqlConnection interface

Connection con =

DriverManagergetConnection(j dbcodbcsomedb

user passwd)

A JDBC URL identifies an individual database in a driver-specific manner Different

drivers may need different information in the URL to specify the host database

During the call to getConnection() the DriverManager object asks each registered driver

if it recognizes the URL If a driver says yes the driver manager uses that driver to create

the Connection object Here is an example

Example 441 A Part of Code of AuthorProcessjava

public void init() throws ServletException

try

ClassforNamesunj dbcodbcJdbcOdbcDriver)

con =

DriverManagergetConnection(j dbcodbcfxbookstore null

null)

catch (ClassNotFoundException e)

catch (SQLException e)

After we got the database connection we need to have some way to execute queries The

simplest way to execute a query is to use the javasqlStatement class Statement objects

are never instantiated directly instead a program calls the createStatement() method of

Connection to obtain a new Statement object

Statement stmt = concreateStatement()

34

A query that returns data can be executed using the executeQuery() method of Statement

This method executes the statement and returns a javasqlResultSet that encapsulates the

retrieved data

Example 442 A Part of Code of AuthorProcessjava

String sqlStmt =

if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where author= + name +II i n

else

sqlStmt = select from BOOK where author like +

name +

ResultSet rs = null

Statement stmt = concreateStatement()

rs = stmtexecuteQuery(sqlStmt)

35

A ResultSet object can be thought as a representation of the query result returned one row

at a time The next() method of ResultSet is used to move from row to row The

ResultSet interface also boasts a multitude of methods designed for retrieving data from

the current row The getStringO and getObject() methods can be used for retrieving

column values

Example 443 A Part of Code of AuthorProcessjava

while (rsnextO )

count++

outprintln(ltdtgtltbgt + count + )

String isbn = rsgetObject(ISBN)toString()

outprintln(lta href=servletDetailContent + isbn +

gt )

outprintln(rsgetObj ect(Title) toString() +

ltagtltbgt)

outprintln (ltnobrxfont color=990033gtUsually ships

in 24 hoursltBRgtltfontxnobrgt)

outprintln(ltddgt +

rsgetObj ect(Author) toString() )

36

outprintln( +

rs getOb j ect ( Publisher) toString () + +

rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

outprintln(ltbrgtltbrgt)

One of the outputs of servlet AuthorProcess is show in Figure 421 and Figure 441

Figure 441 One of The Outputs of Servlet AuthorProcess

37

File Edit View Favorites lo o k - Help M i

T 1 bdquo - 0 L Q 4 pound $ L L lBack r s Stop Refresh Home S earch Favorites History

A - Mail Print

Links rdquo Address | jyen j http7ocalhost808O$ervletAuthorProcess 3

Search B ooks

Home

CategoryA uthor

Title

ISBN

P u b l i sh e r D a te

Tiny Bookstore com

1 The C++ Prograitmuitg Language Usually ships in 24 hour Bjame Stroustrup Addison-Wesley Pub Co i 1997 Our Price 3147

T in yb o oks to re c om H ora e | Category | A uthor | Till | ISBN | Publisher P a t

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top of Page

gk j Local intranet

45 Session Tracking

Session Tracking is one of the most important techniques for any on-line store systems

This is because that HTTP protocol is a stateless protocol A HTTP server sees only a

series of requests and it by itself has no way to know exactly who is making the request

This means that when a customer puts a book in his shopping cart and then goes to other

pages to find more books next time when he puts another book in his shopping cart there

is no guarantee that he puts the book in the same cart It is very possible that he uses

another customerrsquos shopping cart at this time

38

To solve this problem session-tracking is introduced Traditional techniques used by

CGI include hidden form fields URL rewriting user authorization and persistent cookies

For server-side Java applications a built-in class supplied servlet can be used easily to

handle such tasks

When a user first accesses the site web server assigns a new HttpSession object and a

unique session ID to the user The session ID identifies the user and is used to match the

user with the HttpSession object in subsequent requests Usually the session ID is saved

on the client in a cookie or sent as part of a rewritten URL The Tiny Book Store uses this

technique

The Tiny Book Store is a classic shopping cart application A client can put items in his

virtual cart accumulating them until he checks out several page requests later How to

make sure a userrsquos shopping items will be put in his shopping cart or delete from his

shopping cart The Java Servlet API provide built in session tracking to handle this

problem Every user of a site is associated with a javaxservlethttpHttpSession object

that servlets can use to store or retrieve information about that user We can save any set

of arbitrary Java objects in a session object For example a userrsquos session object provides

a convenient location for a servlet to store the userrsquos shopping cart contents An example

shows below

Example 451 A Part of Code of AddToShoppingCartjava

39

1 Get current session object create one if necessary

2 HttpSession session = reqgetSession(true)

3 m_cart = (ShoppingCart)sessiongetValue(cart)

4 if (ra_cart == null) need new cart

5 create a shopping cart

6 m_cart = new ShoppingCart()

7 add to current session

8 sessionputValue(cart m_cart)

9

10

11 try

12 Statement stmt = m_concreateStatement()

13 ResultSet rs = stmtexecuteQuery(select from

book where ISBN= + isbn +)

14 if (rsnext())

15 book - new

BookDetails(rsgetObj ect(ISBN) toString()

16 rsgetObject(Title)toString()

rsgetObj ect(Authorrdquo) toString()

17 rsgetDouble(Price)

rsgetObj ect(PublicationDate) toString() )

18

40

1 9

2 0 catch (SQLException e)

21 e printStackTrace()

22

23 m_cartadd(bookgetlSBN() book)

The servlet uses its request objectrsquos getSession() method to retrieve the current

httpSession object

public HttpSession HttpServeltRequestgetSession (boolean create)

This method returns the current session associated with the user making the request If

the user has no current valid session this method creates one if create is true or return

null if create is false To ensure the session is properly maintained this method must be

called at least once before any output is written to the response Please look at the line 2

in the example 451

If you want to add data to an HttpSession object you can use the putValueQ method

public void HttpSessionputValue(String name Object value)

41

This method binds the specified object value under the specified name Any existing

binding with the same name is replaced This specifies at line 8 of the example 451

If you want to retrieve an object from a session you can use getValue() method

public Object HttpSessiongetValue(String name)

This method specified at line 3 of example 451 returns the object bound under the

specified name or null if there is no binding

From line 4 to line 9 the servlet checks whether the user already has a shopping cart If

the user didnrsquot have a shopping cart the servlet assigns a shopping cart to this user and

add the shopping cart to the current session to keep tracking The ShoppingCartjava class

is developed in this thesis writing code is provided in the appendix

From line 10 to line 21 the servlet knows the user already has a shopping cart m_con is

a data member of AddtoShoppingCart class Lines 12-13 have been discussed in the

previous section Lines 16-20 get some information of the book which the user selected

The information will be the data members of the ldquobookrdquo object that is an instance object

of BookDetailsjava class BookDetailsjava class is developed in this thesis writing the

source code is provided in the Appendix

Line 25 puts the book which is selected by the user into the shopping cart

42

Please see a set of pages are shown below

Figure 451 A Page Show All Information About A Book

TinjiRnfikStnre com - M inrnsnfl Interned Explnrpr

File Edit View Favorites Tools Help-

^ O 4 4 1 f i tStop Refresh Home I Search Favorites History Mail Print Edit

I Link gtgt Address [gl hgtplocalhos9l]IBrit-rvetDetailConetit-Ll20183l)544

S e a r c h B o o k s

Home-

C a t e g o r y

Author

Title

ISSNPublisher Pate

TinyBookStore com

The C++ Programming Languageby Bjarne Stroustrup

aISBN 0201889544 Addison-Wesley Pub Co 1997

Price 3147 Availability U sually ships within 24 hours

Add to cart

Done

R ev iew s

In tins brand-new third edition of The C + + Programming Language author Bjame Stroustrup the creator of C++ presents the full specification for the C++ language and standard library a spec that will soon become the joint ISOANSI C++ standard

g ig L o ca l in tranet

43

Figure 452 A Page Show Items In The Shopping Cart after A User Added Books To The Shopping Cart

H H I H I - I I

j File Edit View Favorites l o o k Help I f

| S ack Stop Refresh Home Search FavoritesJ V

History Wail Print

j Links Address |S1 http7localhost8O80servletAddToShoppingCart i i i i a i i i

( O ldquo ii

Shopping Cart Item s Price

An Introduction to fen e tic Algorithm sMelanie MteheU Quantity 1 Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

drle trgt

delete

delete

Price $ 2 2 0 Subtotal $ 2 2 0

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 6 7 5 6

|euro

rfuj Local intranet

44

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A Book From The Shopping Cart

^ A m a z o n c o m Shopping Cart - Microsoft Internet Explorer

- J A l 4Stop Refresh Home

gtH bdquo ] Back bdquo

httplocalhost8080servletDeleteFromShoppingCartitemgetltem()getlSBN()

Ji _J 3Search Favorites History

j - JMarl Print

~U ccdeg

Shopping Cart Item s

Core Java 2Cay S Horstrnaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d elete

delete

Price

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 4 5 5 6

rsquo0 1 Done gSsfLocat intranet

46 Check Out

This part is designed only using the HTML It collects all information from a user The

information will be written into the database

An important line in this HTML file is shown below

45

ltform method=POST

action=httplocalhost808 0servletCustomerlnfoProcessgt

This line will invoke the servlet CustomerlnfoProcess that will process all data collected

from the user This servlet will discuss in the next section The check out page shows in

Figure 461

Figure 461 A Check Out Page

M M iH M M M i M MmmrnfrnM File Edit View Favorites too ls Help

^ gt a 3 A hi -ltamp f V j HISllll mmB ack S lop R efresh H em e S earch 1 i l lie History M 1 Print Edit

^Links A ddrecs j ig ] h ltp localhostSO SO checkouth tm l i i i l a s

Custom er Information

First name (Fang

Middle initial |a

Last name [Xiao

Email address |fgtdaomitecnet

Account password Jxxxxx

C red it card num ber jl 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7

Credit card type ttV isa O BluebirdO MasterCard O Fisher

Credit card holder jFarig Xiao

Credit card expire date (tnmddyy) joi 0102 ~

Select shipping method t UPS 0 NormalO Express C Abnormal

| | ] Dorraquo raquo f j^ I o c a l intranet

47 Customer Information Processing

The customer information processing is handled by a servlet CustomerlnfoProces Its

source code is provided in the appendix

46

All information collected from the user should be written into the database therefore we

have to open a connection to a given database at first Example 461 is given for this

purpose

Example 471 A Part of Code of CustomerlnfoProcessjava

public void init() throws ServletException

try

ClassforName(sunjdbcodbcJdbcOdbcDriver)

m_con = riverManagergetConnection(jdbcodbcfxbookstore

null null)

catch (ClassNotFoundException e)

e printStackTrace()

catch (SQLException e)

e printStackTrace( )

There is a PO ST request in the check out page The servlet CustomerlnfoProcess will

handle the PO ST request by doPost function which is demonstrated in the following

example

47

Example 472 A Part of Source Code of CustomerlnfoProcessjava

public void doPost (HttpServletRequest req HttpServletResponse res)

throws ServletException IOException

ressetContentType(texthtml)

PrintWriter out = resgetWriter()

get information

String[] values = reqgetParameterValues(firstname)

if (values = null)

firstname = values[0]

values = reqgetParameterValues(middleinit)

if (values = null)

middleinit = values[0]

In the example the HttpServletRequest object res will get each data which was input by

the user by the getParameterValues() function

If the user is a returned user we donrsquot need open a new account again If the returned user

use the same credit card as previous we also donrsquot need to insert the credit card

48

information into the CREDITCARD table Otherwise we should insert all related

information into related table This is shown in the following example

Example 473 A Part of Source Code of CustomerlnfoProcessjava

Statement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where EmailAddress= +

email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext())

sql = insert into CUSTOMERACCOUNT (emailaddress password

firstname middleinit lastname) values ( + + email +

password + + firstname + + middleinit + lastname +

)

stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber= + creditcard

+

rs = stmtexecuteQuery (sql)

if (rsnext())

49

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype

HolderName ExpirationDate) values( + + creditcard + +

cardtype + + cardholder + 11 + expiredate + )

stmtexecute (sql)

All information related the books selected by the user can be obtained from the

shopping cart as shown in the following example

Example 474 A Part of Source Code of CustomerlnfoProcessjava

BookDetails book = null

ShoppingCartltern bookAndQuantity = null

Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getltems()

int aQuantity =0

String alSBN = null

while (itemshasMoreElements())

insert into Orderltems

bookAndQuantity = (ShoppingCartItem)itemsnextElement()

book = bookAndQuantitygetltem()

50

aQuantity = bookAndQuantitygetQuantity()

alSBN = book getISBN()

sql = insert into ORDERITEMS (shoppingCartID ISBN quantity)

values ( + + m_cartID + + aISBN + + aQuantity + )

stmtexecute (sql)

After all information inserted into related tables the servlet CustomerlnfoProcess will

produce invoice page The example page shows in Figure 471

51

Figure 471 An Invoice Page 3 Order List Microsoft Internet Explorer

is File Edit View Favorites Tools Help

J J J U r PS to p Refresh Hom e i -S earch Favorites History s Mai Print

Links Address iff 1 httpVlocalhostBOSOservletCustomerlnfoProcess 3

s5al Local intranet

Y ou r order reads as fo llow sE-MailAddress fiiiaomitecnet

ship to

Tel

Items

F ang Xiao12345 Western Plaza 23OmahaNE68154(402)123-4567

TitleCore Java 2Qtyl Price2579Subtotal2579

TitleJava Servlet PrograrnmingQtyl Price 1977 Sub total 1977 Total4556

i|51 D one

52

Chapter 5

Future Work

In this chapter we discuss two major problems for our future work They are the

Connection Pooling and Object-Oriented for better encapsulation

51 Connection Pooling

After we have used JDBC for a short time it will become evident that the major

performance bottleneck often comes right at the beginning when you are opening a

database connection This is because that opening a connection might involve a series of

low level communications between network protocols and database connection protocols

such as TCPIP ODBC etc

Servlet life cycle allows for extremely fast database access Servlet is loaded into Web

server only once Once it is loaded it can hold a connection to database all its life cycle

Every time it receives a request to read from or write data to database it can just use the

connection to do this

Here comes a problem however Suppose that a customer comes to the on-line store

During the period of selecting some items from the store he leaves his desktop and do

something else leaving this connection to database idling This will waste the precious

resource on the database From database port of view the connection to the database will

assign a space to hold corresponding status and to cache data For example Microsoft

SQL-Servertrade assigns about 36K bytes for each of its connection Resource on the

53

database is limited and idling connection causes such resource unable to be reused for

other users

To solve this problem we can use the technique called connection pooling Essentially a

connection pool is an object holding connections to backend database and managing the

number and status of connections For example if a connection in the pool idles over a

certain time of period the pool can terminate this connection if the requests are not the

same size of the connection pool the pool can dynamically shrink or expand the size of

itself A connection pool can run on a separate thread and is initialized when the server

starts or when a request to database is arrived

To implement a connection pool is pretty straight-forward Because of time constraint

however we did not do it in this paper and leave it as a possible future improvement

52 More Object-Oriented - Better Encapsulation

Another improvement might be done in the future is to create a HTML-related utility

class We have seen in this thesis that there are some duplicated code processing HTML

output such as ldquoout printIn ( lttbxtrgt lttrxtbgt)rdquo All these HTML-

related processes right now are used in a raw way That is they are not encapsulated A

better way to do this is to create a utility class or classes to deal with all HTML-related

processes and hide all HTML tags and format inside the class or classes For example

suppose that we create a Table class then we can use it in a way like

Table table = new Table()

54

table(somerow somecol contents)

table(somerow somecol some_image)

In this way we do not need to use HTML tags in our program and concentrate on the

programming logic The implementation is enriched with more object-oriented property

and therefore it is easy to maintain

55

Chapter 6

Conclusion

The increased awareness and popularity of the Internet make all kinds of electronic

commerce grow vigorously The most popular Web applications are the on-line stores

An on-line store system usually contains four components Web server business

procedure Database system application An on-line store system is different from web

publishing Currently there are three mainstream technologies which are widely used to

develop the on-line store systems CGI Microsoft ASP and Server-side Java application

Introducing the server-side Java application is one of the latest and most exciting trends

in Java programming We have discussed this technology in detail in this thesis The

server-side Java applications have many distinct advantages over CGI and other

technologies We present plenty of examples and figures to analysis the characteristics of

the server-side Java application

As a glance into the future electronic commerce will continue to grow driven by

purchases of home computers and other Web-enabled devices as well as new business

opportunities Electronic commerce is changing whole business procedures The future of

electronic commerce will be exciting and full of opportunities

56

APPENDIX A

Bibliography

57

[1] Karl Moss 1998 Java Servlets Mcgraw-Hill

[2] Jason Hunter William Crawford 1998 Java Servlet Programming O rsquoReilly

[3] Manoj Kumar Anand Rangachari Anant Jhingran Rakesh Mohan 1998 Sales Promitions on the Internet h ttpwwwibmcomiactech-paperhtml

[4] Manoj Kumar Stuart I Feldman 1998 Business Negotiations on the Internet httpwwwibmcomiactech-paperhtml

[5] Manoj Kumar Stuart I Feldman 1998 Internet Auction httpwwwibmcomiactech-paperhtml

[6] Shiwa Fu Jen-Yao Chung Walter Dietrich Vibby Gottemukkala Mitchell Cohen Shyhkwei Chen 1999 A Practical Approach to Web-Based Internet EDI httpwwwibmcomiacpapersicdcsws99indexhtml

[7] Zhong Tian Leo Y Liu Jing Li Jen-Yao Chung Vibby Guttemukkala 1999 Business-to-Business e-Commerce with Open Buying on the Internethttpw w w ibm comi acpapersobi -paperindex html

[8] Gerald J Tesauro Jeffrey O Kephart 1998 Foresight-Based Pricing Algorithms in an Economy os Software Agents http wwwi bm comi actech - paper html

[10] Jeffrey O Kephart James E Hanson Jakka Sairamesh 1998 Price and Niche Wars in a Free-Market Economy o f Software Agents httpwwwibmcomiactech-paperhtml

[11] Jeffrey O Kephart James E Hanson David W Levine Benjamin N Grosof Jakka Sairamesh Richard B Segal Steve R White 1998 Dynamics o f an Information-filtering Economy httpwwwibmcomiactech-paperhtml

[12] James E Hanson Jeffrey O Kephart 1998 Spontaneous Specialization in a Free-Market Economy os Agents httpwwwibmcomiactech-paperhtml

[13] Jakka Sairamesh Jeffrey O Kephart 1998 Price Dynamics o f Vertically differentiated Information Markets httpwwwibmcomiactech-paperhtml

[14] David Kosiur 1997 Understanding Electronic Commerce Microsoft Press

[15] Gunther Birznieks Selena Sol 1997 CGI fo r Commerce MampT Books - A Division of MIS Pres

58

[16] Ravi Kalakota Andrew B Whinston 1997 Electronic Commerce Addison Wesley

[17] Alex Fedorov Richard Harrison Dave Sussman Brian Francis Stephen Wood 1998 Profession Active Server Page 20 Wrox Press

[18] Calvin Austin Minica Pawlan 1999 Writing Advanced Application for the Java PlatformhttpVdeveloper iavasuncomdeveloperonlineTrainingProgrammin gJDCBooki ndexhtml

59

APPENDIX B

The Source Code of An On-Line Store System - Tiny Book Store

60

1 welcomeshtml

lthtmlgtltheadgtlttitlegtSearch Tinybookstorecomlttitlegtltheadgtltbodygt

lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=eeeeccgtlttrgtlttd rowspan=2 align=left valign=top width=15 cellspacing=0 cellpadding=0xIM G border=0 hspace=0 id=IMGl src=flowergif gtlttdgtlttd rowspan=2 align=left valign=centergtltstronggtlth2gtltigtTinyBookStorecomltigtlth2gtltstrongxtdgtlt trx tab legt

lttable border=0 width=100 cellspacing=0 cellpadding=0gtlttrgtlttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtltPgt

lttable width=100 cellspacing=0 cellpadding=5 border=0gtltTRgt ltTDgt ltTDgt ltTD colspan=2gt ltFONT FACE=verdanaarialhelvetica SIZE=-1 gtampnbsp ltFONTgt ltTDgt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD co lsp an = 2 x stro n g x fo n t face=verdanaarialhelvetica size=-lgtSearch B ooksltfontxstronggt ltTDgt ltTRgtltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt ltTD x f o n t face=verdanaarialhelvetica size=-l gt

lta href=w elcom eshtm lgtH om eltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt c T D x fo n t face=verdanaarialhelvetica size=-1 gt

lt A href= servletReqC ol 1 ec tc ategory gtC ate gory ltf o n tx A x T D gtltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollectauthorgtA uthorltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollecttitlengtTitleltorfo n tx A x T D gt ltTRgt

61

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectisbngtISBN ltA xfontxTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectpublisher_dategtPublisherD a telt A x fo n tx T D gtltTRgtlt tab lex p gtlttdgt

lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgtlttd valign=top align=leftgt

ltbr clear=allgtltPgtlt h 3 x s tro n g x fo n t color=ff6347gtWelcome to theltigt T in y B o o k S to rex o m lt ix fo n tx s tro n g x h 3 gt

ltbrgtlt s tro n g x b x h 3 x c e n te rgt F iv e Hot B o o k slt cen te rx h 3 x B x s tro n g gt

ltbrgtltservlet code=EchoServetTag myArgI=myValuel myArg2=myValue2gt ltparam name=myParm 1 value=Hellogtltparam name=myParml value=Worldgtltparam name=myParm2 value=myParmValue2gtltservletgt

lt td x trgt

lttablegt

ltTABLE width=100gtltTRgt ltTD width=50 valign=top align=Ieftgt ltTDgtltTD width=50 valign=top align=rightgtltfont size=-lgtltA href=topgtTop of P ag elt A x fo n tx T D gt ltTRgt

62

ltTABLEgt

ltcentergtltfont size=-lgtltA href=indexhtml gtTinybookstorecom HomeltAgt ampnbsplampnbsp ltA href=categoryhtml gtCategoryltAgt ampnbsplampnbspltA href= author html gtAuthorltAgt ampnbsplampnbspltA href= title html gtTitleltAgt ampnbsplampnbspltA href=7isbnhtml gtISBNltAgt ampnbsplampnbspltA href=publisherhtmrgtPublisher DateltAgtltpgtltfontgtltcentergt

ltPgtltcentergtlt b rx fo n t size=-lgtltA href=copyrighthtml gtCopyright and disclaimerltAgt copy 1999-2001 Fang Xiao ltfontgtltcentergt

ltbodygtlthtmlgt

63

2 AddToShoppingCartjava

ltpgt AddToShoppingCart is the servlet that process the action of adding item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javasql import javautil import javaxservlet import javaxservlethttp

public class AddToShoppingCart extends HttpServlet

protected Connection m_con = null protected ShoppingCart m_cart protected BookDetails book

public void initQ throws ServletException try

Class forName( sunj dbc odbc JdbcOdbcDriver)m_con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintstackTrace ()catch (SQLException e)

e prints tackT race ()

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

String[] params = reqgetParameterValues(isbn)

64

String isbn = get isbn from extra path infomationif (params = null)

isbn = params [0]

Get current session object create one if necessary HttpSession session = reqgetSession(true) m_cart = (ShoppingCart)sessiongetValue(cart)

if (m_cart == null) need new cart create a shopping cart m_cart = new ShoppingCart() add to current session sessionputValue(cart m_cart)

try Statement stmt = m_concreateStatement()ResultSet rs = stmtexecuteQuery(select from book where

ISBN=rsquo + isbn + rsquo)

if (rsnext()) book = new BookDetails(rsgetObject(ISBN)toString()

rsgetObject(TitIe)toStringOrsgetObject( Author) toStringO

rsgetDouble( Price) rs getObj ect( PublicationDate) toStringO)

catch (SQLException e)

eprintStackTrace()m_cartadd(bookgetISBN() book)

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lt h tm lxheadx titlegt T inyB ookS tore com S hopping

Cartlttitlexheadgt)outprintln(ltbody bgcolor=FFFFFF lmk=003399

alink=FF9933 vlink=996633 text=000000ngt)outprintln(lta nam e= topxmdashTop of Pagemdashx a gt )

65

outprin tln(ltpxa href=httplocalhost8080checkouthtmlximg src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=cccc99 gt)ou tp rin tln (lt tdxbrx tdgt )ou tp rin tln (lt tdxbrx tdgt )o u tp rin tln (lt tdxbrx tdgt )outprintln(lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=2xfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=left valign=topxfont

face=verdanaaria lhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=cccc99gt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lt td x b rx td gt ) outprintln(lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantityQ

outprintln(lttr bgcolor=FFFFFFgt) ou tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt )outprintln(ltbrgt + item getltem() get Author()) outprintln(ltbrgtQuantity + itemgetQuantityO) outprintln( ltbrgt) outprintln(lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=POST

action=7servletDeleteFromShoppingCartitemgetItem()getISBN()gt)

66

outprintln(ltpgt cinput type=hidden name=isbn value= + itemgetItem()getISBN())

outprintln(ltpgt ltinput type=submit name=ditemvalue=deletegt)

outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelve tica color=000000gt)

outprintln(ltNOBRgtltbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fon tx bx N O B R gt ltbrgt )

outprintln(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantity() + lt fo n tx b x N O B R x b rgt )

outprintln(ltfontgt) out println( lttdgt)

out printl n( lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)out println( lt fo n tx fo n tgt )outprintln(lttdxtrgt)outprintln(lttablegt)outprin tln(ltpxa href=httplocalhost8080checkouthtmlYximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)outprintln(ltbodygt lthtmlgt)

outflush()outclose()

67

3 AuthorProcessjava

bull ltpgt AuthorProcessbull This is the servlet that process the Author-search request and generatebull search resultbull Author Fang Xiao Purpose Thesis project Copyrightcopy Fang Xiao 1999-2001

import javaxservlet import jav ax servlet http import javaio import javasql

public class AuthorProcess extends HttpServlet protected final String EXACT = ldquoexactrdquo protected final String OTHERS = ldquolastrdquo

protected Connection con = null

public void init() throws ServletException try

ClassforName(ldquosunjdbcodbcJdbcOdbcDriverrdquo)con = DriverManagergetConnection(ldquojdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(ldquotexthtmlrdquo)PrintWriter out = resgetWriterQ

68

String[] valuesString name =

values = reqgetParameterValues(ldquoauthorrdquo) if (values = null)

name = values [0]

String mode = ldquordquovalues = reqgetParameterValues(ldquoauthor_moderdquo) if (values = null)

mode = values [0]

String sqlStmt = ldquordquo if (modeequalsIgnoreCase(EXACT))

sqlStmt = ldquoselect from BOOK where author=rsquordquo + name +else

sqlStmt = ldquoselect from BOOK where author like lsquordquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

ldquoYour Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ldquoltdlgtrdquo) 11 start Glossary List

while (rsnext()) count++outprintln(ldquolt d tx b gt rdquo + count + ldquo ldquo)String isbn = rsgetObject(ldquoISBNrdquo)toString()

69

outprintln(ldquolta href=servletDetailContentrdquo + isbn+

outprintln(rsgetObject(ldquoTitlerdquo)toString() +ldquolt a x b gt rdquo)

outprintln(ldquolt n o b rx fo n t color=990033gtUsually ships in 24 h o u rslt B R x fo n tx n o b rgt rdquo)

outprintln(ldquoltddgtrdquo +rsgetObject(ldquoAuthorrdquo)toString())

outprintln(ldquo ldquo +rsgetObject(ldquoPublisherrdquo)toString() + ldquo ldquo + rsgetObject(ldquoPublicationDaterdquo)toString())

outprintln(ldquoltbrgt Our Price ldquo +rsgetObject(ldquoPrice)toString())

outprintln(ldquolt b rx b rgt rdquo)

if (count == 0) outprintln(ldquoltdtgt No matched data foundrdquo)

outprintln(ldquoltdlgtrdquo) end Glossary List

catch (SQLException e) create footer here outprintln(ldquolttdgt lttrgtrdquo) outprintln(ldquolttablegtrdquo)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(ldquolthtmlgtrdquo) outprintln(ldquoltheadgtrdquo) outprintln(ldquolttitlegt TinyBookStorecom lttitlegtrdquo) outprintln(ldquoltheadgtrdquo)

outprintln(ldquoltbodygtrdquo)

70

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspacing=0 cellpadding=0 bgcolor=rdquoEEEECCYrsquogtrdquo)

outprintln(ldquolttrgtrdquo)outprintln(ldquolttd align=left valign=top width=90 gtrdquo) outprintln(ldquoltIMG border=0 hspace=0 id=IMGl

src=rdquodJavaWebServer20public_htmlflowergifrdquogtlttdgtrdquo) outprintln (ldquolttd width=30gtlttdgtrsquorsquo) outprintln(ldquolttd align=left valign=center width=300gtrdquo)

outprintln(ldquolt stro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x s tro n g x td gt rdquo) outprintln(ldquolttd align=right valign=centergtrdquo) outprintln(ldquolttdgtrdquo) outprintln(ldquolttd w id th= 20x tdgt rdquo) out pri ntln (ldquolttrgtrsquo rsquo) outprintln(ldquolttablegtrdquo)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ldquolttable width= 100gtrdquo)outprintln(ldquolttrgt lttd width=50 valign=top align=leftgt lttdgtrdquo) outprintln(ldquolttd width=50 valign=top align=rightgtrdquo) outprintln(ldquoltfont s iz e = - lx a href=rdquotoprdquogtTop of P agelt ax fon tgt rdquo) outprintln(ldquolttrgtrdquo) outprintln(ldquolttablegtrdquo)

outprintln(ldquoltcentergtrdquo) outprintln(ldquoltfont size=-lgtrdquo) outprintln(ldquolta

href=rdquohttplocalhost 8080welcomeshtmlrdquogtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080$ervletReqCollectcategoryrdquogtCategoryltagtampnbsplampnbsprdquo)

outprintln(ldquoltahref=Yhttplocalhost8080servletReqCollectauthorrdquogtAuthorltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_daterdquogtPublisheramp44Dateltagtrdquo)

outprintln(ldquoltpgtrdquo)

71

outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltpgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquolt b rx fo n t size=-lgtrdquo)outprintln(ldquoltA href=Y7copyrighthtmlrdquogtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiaordquo)outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltbodygtrdquo) outprintln(ldquolthtmlgtrdquo)

i

protected void CreateLeftMenu(PrintWriter out) System out println(ldquoLeftMenurdquo)

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspaeing=0 cellpadding=0gtrdquo)

outprintln(ldquolttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtrdquo)

outprintln(ldquoltpgtrdquo)

outprintln(ldquolttable width=rdquo 100rdquo cellspaeing=0 cellpadding=5border=0gtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquoltfont face=verdanaarialhelvetica SIZE=rdquo- l rdquogtampnbsp

ltfontgtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquolt strongxfon t face=verdanaarialhelvetica size=rdquo-

1 rdquogtSearch B ooksltfontxstronggtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd ldquo) outprintln(ldquoltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080welcomeshtmlYgt H o m elt fo n tx ax td gt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=rdquo-1rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080servletReqColIectcategoryrdquogt C ateg o ry lt fo n tx ax td gtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

72

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectauthorrdquogtAuthorltfontgtltagtlttdgtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width-2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l W rsquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltfontgtltagtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo-lYgtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_dateVrsquogtPublisher Dateltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolt tab lex p gt rdquo)

outprintln(lsquolsquolttdgtrdquo)outprintln(ldquolttd rowspan=4 width=5gtampnbspampnbspltbrgtlttdgtrdquo) outprintln(ldquolttd valign=top align=leftgtrdquo) outprintln(ldquoltbr clear=allgtrdquo)

73

4 BookTeatailsjava

ltpgt This is the class describing a book item in shopping cart

Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class BookDetails private String m_isbn = null private String m_title = null private String m_author = null private double m_price = 00 private String m_year = null

public BookDetails(String isbn String title String author double price String year)

thism_isbn = isbn thism_title = title thism_author = author thism_price = price thism_year = year

public String getISBN() return m_isbn

public String getTitle() return m_title

public String getAuthor() return m_author

public double getPrice() return m_price

ipublic String getYearQ

return m_year

75

5 CategoryProcessjava

ltpgt CategoryProcess This is the servlet that process the Category-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql import javautil

public class CategoryProcess extends FlttpServlet protected final String EXACT = exactprotected final String OTF1ERS = last

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

76

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentType( texthtml)Print Writer out = resgetWriterQ

String[] values String name = String sqlStmt =

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

else

path = pathsubstring(l) if (pathequalsIgnoreCase(cO 1))

sqlStmt = select from BOOK wherecategoryid=rsquo + cOl +

else if (pathequalsIgnoreCase(c02))sqlStmt = select from BOOK where

categoryid=rsquo + c02 +else if (pathequalsIgnoreCase(c03))

sqlStmt = select from BOOK wherecategoryid=rsquo + c03 +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftM enu(out)

Your Book Search Results try

77

if (con = null) Statement stmt = concreateStatement() rs = stmt executeQuery (sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn

+outprintln(rsgetObject(Title)toString() +

lt ax bgt )outprintln(ltnobrxfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltddgt +

rsgetObject( Author)toStringO)outprintln( +

rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)outprintln(ltbrgt Our Price +

rsgetObject( Price) toStringO) ltfont color=990000gtYou Save $1100

(20)ltfontgtoutprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

78

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)out println( lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20publicbdquohtmlflowergifgtlttdgt) outprintln(lttd width=3 0gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln( lt s tro n g x h 2 x igt T inyB ookS to re com lt ix h2x s tro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlngtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

79

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYrsquogtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln( ltfontgt)outprintln(ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rOwspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt)

outprintln(lttablewidth= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=Y2Ygt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y-1 Yrsquogtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2Yrsquogt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=Y-

lYrsquogtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=Y-lYgt)

80

outprintln(ltahref=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqColIectcategorygtCategoryltfontxagtlttdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(nltahref=httplocalhost8080servletReqCollectauthorVrsquogt A u th o rlt fo n tx ax td gtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httpIocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

6 CustomerlnfoProcessjava

ltpgt CustomerlnfoProcessThis servlet is responsible to process userrsquos information when heshe check out

Author Fang Xiao

Purpose Thesis projectCopyright (C) Fang Xiao 1999-2001

import javasql import javaio import j avau til import javaxservlet import javaxservlethttp

public class CustomerlnfoProcess extends HttpServlet protected Connection m_con = null protected HttpSession m_session = null protected static int m_cartID = 1 protected String firstname =protected String middleinit =protected String lastname =protected String email =protected String password =protected String creditcard =protected String cardtype =protected String cardholder =protected String expiredate =protected String shipping =protected String receiver =protected String address =protected String city =protected String state =protected String zipcode =protected String phone =

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)

82

m_con = DriverManagergetConnection(jdbcodbcfxbookstorenull null)

catch (ClassNotFoundException e)

eprintStackTrace()catch (SQLException e)

eprintStackTrace()i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

get informationString[] values = reqgetParameterValues(firstname) if (values = null)

firstname = values [0]

values = reqgetParameterValues(middleinit) if (values = null)

middleinit = values [0]

values = reqgetParameterValues(lastnameM) if (values = null)

lastname = values [0]

values = reqgetParameterValues(email) if (values = null)

email = values [0]

values = reqgetParameterValues(password) if (values = null)

password = values [0]

values = reqgetParameterValues(creditcard)

if (values = null) (creditcard = values [0]

values = reqgetParameterValues(cardtype) if (values = null)

cardtype = values [0]

values = reqgetParameterValues(cardholder) if (values = null) (

cardholder = values [0]

values = reqgetParameterValues(expiredate) if (values 1= null)

expiredate = values [0]

values = reqgetParameterValues(shippingrdquo) if (values = null)

shipping = values [0]

values = reqgetParameter Values (receiver) if (values = null)

receiver = values [0]

values = reqgetParameterValues(address) if (values = null)

address = values [0]

values = reqgetParameterValues(city) if (values = null) (

city = values [0])

values = reqgetParameterValues(state) if (values = null) (

state = values [0]

84

values = reqgetParameterValues(zipcode) if (values = null) (

zipcode = values [0]

values = reqgetParameterValues(phone) if (values = null)

phone = values[0]i

get session object m_session = reqgetSessionQ

try update databaseStatement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where Email Address=rsquo + email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext()) Systemoutprintln(insert customeraccount)

sql = insert into CUSTOMERACCOUNT (emailaddress password firstname middleinit lastname) values ( +

+ email + + password + + firstname +V + middleinit + + lastname + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber=rsquo +creditcard +

rs = stmtexecuteQuery (sql)

if (rsnext()) Systemoutprintln(insert creditcart)

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype HolderName ExpirationDate) values( +

+ creditcard + + cardtype + +cardholder + + expiredate + rdquo)

Systemoutprintln(sql)stmtexecute (sql)

i

85

sql = insert into SHOPPINGCART (ShoppingCartIDEmail Address CreditCardNumber ShippingType ReceiverName ReceiverAddress ReceiverCity ReceiverState ReceiverZipcode ReceiverPhone) values ( + m_cartID + V + email + Vrdquo +

creditcard + V + shipping + + receiver ++ address + V +

city + V + state + V + zipcode + V + phone +gt gt

Systemoutprintln(sql)stmtexecute (sql)

BookDetails book = nullShoppingCartltem bookAndQuantity = null Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

int aQuantity =0 String alSBN = null

while (itemshasMoreElementsO) insert into Orderltems bookAndQuantity =

(ShoppingCartItem)itemsnextElement()book = bookAndQuantitygetItem()

aQuantity = bookAndQuantitygetQuantity() alSBN - book getISBN()

Systemoutprintln(insert Orderltems)sql = insert into ORDERITEMS (shoppingCartED ISBN

quantity) values ( + m_cartID + +alSBN + + aQuantity + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

im_cartID++ must increase by one

86

catch (SQLException e) eprintS tackTrace()

printOrder(out)

public void printOrder(PrintWriter out) outprintln( lthtmlgt ltheadgt lttitlegt Order List lttitlegt ltheadgt) outprintln( ltbodygt)outprintln(lthlgt Your order reads as follows lthlgt)outprintln(lttablegt)outprintln( lttrgt)outprintln( lttdgtE-Mail Addres s lttdgt) outprintln(lttdgt+ em ail+lttdxtrgt) outprintln(lttrgt) outprintln(lttdgtship tolttdgt) outprintln(lttdgt+ receiver +ltbrgt) outprintln(address +ltbrgt) outprintln(city +ltbrgt) outprintln(state +ltbrgt) outprintln(zipcode + lt b rx td x trgt ) outprintln(lttrgt) outprintln( lttdgtTel lttdgt) outprintln(lttdgt+ phone +lttdxtrgt) outprintln(lttrgt) outprintln( lttdgtItems lttdgt)

BookDetails book = nullShoppingCartltem bookAndQuantity = nullEnumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

double total = 00

while (itemshasMoreElements()) bookAndQuantity = (ShoppingCartItem)itemsnextElement()

total += bookAndQuantitygetItem()getPrice() bookAndQuantitygetQuantityO

book = bookAndQuantitygetltem()

87

outprintln(lttdgtTitle+ bookgetTitle() + Qty + bookAndQuantitygetQuantity() + ltbrgt)

outprintln(Price + bookgetPrice() + Subtotal + bookAndQuantitygetQuantityO bookgetPrice() +ltbrgt)

outprintln(Total + total )outprintln(lttdxtrgt)outprintln(lttablegt)outflush()outclose()

7 DeleteFromShoppingCartjava

ltpgt DeleteFromShoppingCart is the servlet that process the action of deleting item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javautil import javaxservlet imp ort j avax servlet http

public class DeleteFromShoppingCart extends HttpServlet

protected ShoppingCart m_cart protected BookDetails book

public void doPost(HttpServletRequest req FIttpServletResponse res) throws ServletException IOException res setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String[] params = reqgetParameterValues(isbnrsquo) String isbn = get isbn hidden fieldif (params = null)

isbn = params [0]

Systemoutprintlnfisbn = + isbn)

Get current session objectHttpSession session = reqgetSession()m_cart = (ShoppingCart)sessiongetValue(carf)

m_cartremove(isbn)

89

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lthtm lgtltheadxtitlegtAm azoncom Shopping

C artlt titlexheadgt)out pri ntln ( ltb ody bgcolor=FFFFFF link=003399

alink=FF9933 vlink=Yrsquo996633Y text=rdquo000000rdquogtrdquo)outprintln(lta nam e= top xmdashTop of Pagemdashx a gt ) ou tp rin tln (lt pxa href=httplocalhost8080checkouthtmlximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=Yrsquocccc99Yrsquo gt)ou tp rin tln (lt tdxbrx tdgt )out pri ntln ( lt td x b r x td gt )outprintln( lt td x b r x td gt )out println (rsquo1 lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=Y2Yxfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=YleftY valign=YtopYxfont

face=verdanaarialhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=Ycccc99Yrsquogt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantity()

outprintln(lttr bgcolor=FFFFFFgt) o u tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt)outprintln(ltbrgt + itemgetItem()getAuthor())

90

outprintln(ltbrgtQuantity + itemgetQuantityO)outprintln(ltbrgt)outprintln( lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=VPOST

action=7servletDeleteFromShoppingCartVgt)outprintln(ltpgt ltinput type=hidden name=isbn value= +

itemgetItem()getISBN())outprintln(ltpgt cinput type=submit name=ditem

value=Y rsquo deletegt rsquo rsquo)outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelvetica color=000000gt)

outprintln(ltNOBRxbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fo n tx b x N O B R x b rgt )

outprintin(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantityO + lt fo n tx b x N O B R x b rgt )

outprintln( ltfontgt) outprintln( lttdgt)

i

outprintln(lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)outprintln(ltfontxfontgt)outprintln( lt td x trgt ) outprintln(lttablegt)ou tp rin tln (lt pxa href=Yhttplocalhost8080checkouthtmlYximg

src=YdYJavaWebServer20servletsimageproceed-to-checkoutgifYxagt)outprintln(ltbodygt lthtmlgt)

outflushOoutcloseQ

91

8 Detailcontentjava

ltpgt DetailContent is the servlet responsible for generating detailed information page for a book The book is identified by its ISBN Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaio import javasql import jav ax servlet import javaxservlethttp

public class DetailContent extends FIttpServlet protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String isbn = reqgetPathInfo()isbn = isbnsubstring(l) skip over rsquo rsquo

92

try String sql = select from book where ISBN=rsquo + isbn +

Statement stmt = concreateStatement()ResultSet rs = stmtexecuteQuery(sql)

create header here CreateHeader(out)

create left menu here CreateLeftMenu(out)

outprintlnfctd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintlnfctd valign=top align=leftgt)

cellpadding=0gt)

outprintln(ltbrgt)

create detailcontent here while (rsnext())

String strlSBN = rsgetObject(ISBN)toString() outprintln(lttable width=100 border=0 cellspacing=0

+ltbgtlttdxtrgt)

+ lt tdx trgt)

outprintln(lttrgt lttd colspan=3 align=leftxbgt) outprintln( rsgetObject(Title)toString()

outprin tln(lt trxtd colspan=3 align= leftxbgt by ltbgt) out println( rs getObj ec t( Author) toS tringQ

cellpadding=0gt)

outprin tln(lt trx td x i m g src=xtdgt) outprintln( lttd valign=topgt) outprintln( lttable border=0 cellspacing=0

outprintln( lt t r x td valign=topxbgtPrice )outprintln(

rsgetObject(Price)toString() + lt b x td x trgt ) outprintln(

lt trx td x b gt A v ailab ility lt b gt U su a lly lt td x trx b rgt )outprintln( lt t r x td vlign=topgtships within 24

hou rs lt td x trgt )outprintln( lt tab lextdgt)

93

outprintln( lttd align=rightgt) outprintln( lttable border=0 cellspacing=0

cellpadding=0gt)outprintln( lt trx td gt )outprintln( ltform

method=POST action=httplocalhost8080servletAddToShoppingCartgt)outprintln( ltinput

type=hidden name=isbn value= + strlSBN +outprintln( cinput

type=submit value=Add to cart )outprintln( lt tdx trgt )

outprintln( lt tab lex tdgt ) outprintln(rdquolttrgt)outprintln(lttrgt lttd clospan=3 align=leftgt ISBN ) outprintln( strlSBN +lttdxtrgt)outprintln(lttrgt lttd clospan=3 align=leftgt) outprintln( rsgetObject(Publisher)toString()

+rsgetObject(PublicationDate)toString() + lt tdx trgt )outprintln(lttablegt)outprintln(ltbrgt)outprintln(ltbrgt)

output reviewString review = rsgetObject(BookReview)toString() if (review = null)

review =DJavaWebServer20servletsreview + review

outprintln(ltbgtReviewsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(review))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprin tin (thisLine) ou t println( ltpgt)

)

icatch (IOException e)

need do something here eprintstackTrace ()

94

outprintln(ltbrgt)String comment =

rsgetObject(BookComment)toString()if (comment = null) comment = DJavaWebServer20servletscomment +

commentoutprintln(ltbgtReader Commentsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(comment))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprintln(thisLine) outprintln(ltpgt)

catch (IOException e)

need do something here eprintstackTrace ()

ou t pri ntln ( ltb rgt)

catch (SQLException e)

need to do something here

add table end tab outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt)

95

ou t pri ntln ( lthe adgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=YTOO cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d J avaW eb S erver 2 Opublic_htmlflo wer gif gtlttdgt) outprintln(lttd width=30gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyBookStorecomltigtlth2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln( lttd width=20gtlttdgt) out pri ntln ( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-1 gt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

96

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsptampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out prin tin ( ltcen tergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

eellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=Yhttplocalhost8080Avelcom eshtm lgtHom eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-1gt)

97

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=http7localhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref-httpIocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lVgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

98

9 EchoServlettagjava

import javaio import j avasql import javaxservlet import javaxservlethttp

public class EchoServletTag extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintStackTrace ()catch (SQLException e)

eprintStackTrace()

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

try Statement stmt = concreateStatementQResultSet rs = stmtexecuteQuery(select from book where title

like rsquoProgrammingrsquo)int count = 1outprintln(ltdlgt)while (rsnext() ampamp count lt 6)

outprintln(ltdtxbgt + count + )

99

String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn + outprintln(rsgetObject(Title)toString() + lt ax bgt ) outprintln(ltddxnobrgtltfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltbrgt + rs getObject( Author) toStringO) outprintln( + rsgetObject(Publisher)toStringO +

+ rsgetObject(PublicationDate)toStringO)outprintIn(ltbrgt Our Price +

rsgetObject(Price)-toStringO)

out println( lt b rx b rgt ) count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()outprintln(lttdgt lttrgt) outprintln(lttablegt) outflush() outcloseO

ii

100

10 ISBNProcessjava

ltpgt ISBNProcess This is the servlet that process the ISBN-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javax servlet import javaxservlethttp import javaio import j a vasql

public class ISBNProcess extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forN ame( sun j dbc odbc J dbcOdbcDri ver)con = DriverManagergetConnection(j dbc odbc fxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s s e tC on te n tTy pe ( tex th tm l)PrintWriter out = resgetWriter()

String[] values

String alSBN =

values = reqgetParameterValues(isbn) if (values = null)

alSBN = values [0]

String sqlStmt = select from BOOK where ISBN= + alSBN

ResultSet rs = null int count = 0

create header here bullCreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject( IS BN) toStringO

outprintln(lta href=servletDetailContent + isbn+ gt)

outprintln(rsgetObject(Title)toStringO +lt ax bgt )

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toStringO)

outprintln( +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

102

outprintln(ltbrgt Our Price +rsgetObject(rdquoPrice) toStringO)

outprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width= 100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d Uava WebS erver2 Opubhc_htmlflo wer gif gtlttdgt) outprintln(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS tore com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt)

103

out println( lttdgt) outprintln(lttd w id th= 20x tdgt ) out pri ntln( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)out pri ntln (lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) out pri ntln ( lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsp1ampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out println( ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

104

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 eellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Books lt fontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocaihost8080servletReqCollectcategorygtCategoryltfontxaxtdgt lttr gt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

105

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lttablegtltpgt)

o u t println( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

ii

106

11 PublisherDataProcessjava

ltpgt AuthorProcess This is the servlet that process the PublisherampDate-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql

public class PublisherDateProcess extends FIttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbc odbc JdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentT ype ( texthtml)PrintWriter out = resgetWriterQ

String[] valuesString namel =

107

values = reqgetParameterValues(publisher) if (values = null)

nam el = values [0]

String name2 =values = reqgetParameterValues(rdquopublication_date) if (values = null)

name2 = values [0]

String sqlStmt =sqlStmt = select from BOOK where publisher=rsquo + namel + rsquoand

publicationdate=rsquo +name2

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprin tln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toStringO outprintln(lta href=servletDetailContent + isbn

+ gt)outprintln(rsgetObject(Title)toString() + (

lt ax bgt )

108

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rs getObj ect( Author) toS tring())

outprintln(V +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

outprintln(ltbrgt Our Price +rsgetObject( Price) toStringO)

outprintln( lt b rx b rgt )

if (count == 0) (outprintln(ltdtgt No matched data found)

outprintln(rdquoltdlgt) end Glossary List

catch (SQLException e) ( create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 celipadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt)

109

outprintln(ltIMG border=0 hspace=0 id=IM Gl src=dJavaW ebServer20public_htmlflowergifxtdgt)

outprintln(lttd width=3 0 x td gt ) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS to re com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ctable w idths 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt) outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) ou t println( ltcentergt)

no

outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaim er^A gt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) out pri ntln ( lthtml gt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-1 gtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=V-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-1gt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

I l l

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitleYrsquogt T itle lt fo n tx a x td gt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(nltahref=Yhttplocalhost8080servletReqCollectisbnY gtISBNltaxfontxtdgt lttrgt)

outprindn(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdana arial helvetica size=Y -1 gt)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYgtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

1 12

12 ReqCollectjava

ltpgt This is a servlet responsible for generating search request collection page It read extra path information from URL and then according to the extra path information it generates corresponding page format Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001import javaxservlet import javaxservlethttp import javautil import javaio

public class ReqCollect extends HttpServlet

protected final String CATEGORY = categoryrdquo protected final String AUTHOR = author protected final String TITLE = titlerdquo protected final String ISBN = isbnprotected final String PUBLISHER_DATE = publisher_date

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentType( texthtml)PrintWriter out = resgetWriter()

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

)else

Create standard header CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

path = pathsubstring(l) if (pathequalsIgnoreCase(CATEGORY))

I I Create category request collect

outprintln(ltpgt)outprintln(lth3xstronggtProgrammingltstronggtlth3gt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc01gtAlgorithmsltagt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc02gtCampC++ltagt)outprintln( Delphi) outprintln(lta

href=httplocalhost8080servletCategoryProcessc03gtJavaltagt)outprintln( MFC Perl)

outprintln(software Design UML Visual Basic More)

outprintln(lth3xstronggtW eb Developm entltstrongxh3gt) outprintln(ASP Commercem Cyberculture HTML

JavaScript)

outprintln(Security Web Design XML more)

outprintln(lth3xstronggtGraphics amp Softwareltstrongxh3gt) outprintln(Asobe CAD Desktop Publishing Graphics)

outprintln(Microsoft More)

outprintln(lth3xstronggtNetW orking amp O Sltstrongxh3gt) outprintln(Linux Macs Oracle PCs SAp R3 SQL)

outprintln(TCPIP Unix WindowsampDOS W indowsNT)

out println( More)

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

1 14

outprintln(ltfont color-CC6600 face=verdana arial helvetic a size=+1 gtltbgtEnter Authorltbgtltfontgt)

outprintln(ltbrgt You can enter authorrsquos full name firstname or last nameltpgt)

outprintln(ltform method=POST action=httplocalhost 8080servletAuthorProcessY id=form 1 name=form 1 gt)

outprintln( lttable border=0gt) outprintln(lttrgt lttd valign=middle

ahgn= leftx ttx b gt A u th o rlt b gt lt ttx td gt )outprintln(lttd valign=middle align= leftx input

type=YtextY name=author size=40 value=YYxtdgt)outprintln(lttrgt)outprintln(lttrgt lttd colspan=2gt ltfont size=-lgt) outprintln(ltcentergt ltinput type=radio

name=Yauthor_modeY value=YexactY checkedgt Exact Name)outprintln(ltinput type=radio name=author_mode

value=lastgtLast First Name (or Initial))outprintln(ltcentergt) outprintln(ltfontgt) outprintln(lttdgt lttrgt)outprintln(lttrgt lttd colspan=2gt ltpgt ltbrgt lttdgt lttrgt)outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search NowY

id=submitl name=submitlgt)outprintln(cinput type=reset value=YClear Form

id=resetl nam e= rese tlxpgt )outprintln(ltcentergt ltformgt)

else if (pathequalsIgnoreCase(TITLE))

Create title request collect

outprintln(ltfont color=CC6600 face=verdanaarialhelvetica s ize= + lxbgt E n ter T itlelt bxfontgt)lsquo

outprintln(ltbrgtYou can enter the exact title or part oftitleltPgt)

outprintln(ltform method=YPOSTY action=Yhttplocalhost8080servletTitleProcessY id=form l name=formlgt)

outprintln(lttable border=0gt) outprintln(lt trxtd valign=middle

a lig n = le ftx ttx b gt T itle lt b x t tx td gt )

115

outprintln(lttd valign=middle align= leftx input type=text name=title size=40 value=xtdgt)

outprintln(lttrgt) outprintln(lttrgt) outprintln( lttd colspan=2gt) outprintln( ltfont size=-lgt) outprintln( ltcentergt)outprintln( ltinput type=radio name=title-mode

outprintln(value=exact checkedgt) outprintln( Exact Title)outprintln( ltinput type=radio name=title-mode

outprintln( value=titlewords gt ) outprintln( Title Words )outprintln(ltcentergt ltfontgt lttdgt lttrgt)outprin tln(lt trxtd c o ls p a n = 2 x p x b r x td x tr gt ) outprintln(lttablegt)

outprintln(ltcentergt)outprintln( ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln( ltinput type=reset value=Clear Form

id=resetl nam e= resetlxP gt )outprintln(ltcentergt) ou t println ( ltformgt)

outprintln(lthr noshade size=lgt)

outprintln(ltBgtExamplesltBgt)outprintln(ltULgt)outprintln(ltLIgtEntering ltbgtampquotJava Servlet

Programmingampquotltbgt in the title field )outprintln(and choosing ltemgtExact Titleltemgt finds the

book without also finding the many books)

outprintln(ltLIgtEntering ltbgtampquotJavaampquotltbgt in the Title field and choosing ltemgtTitle Wordsltemgt)

outprintln( finds all books whose title are related toltigtJavaltigt)

outprintln(ltULgt)

out printl n( lttdgtlttrgt) outprintln(lttablegt)

ielse if (pathequalsIgnoreCase(ISBN))

Create isbn request collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n ter ISBN ltbxfontgt)outprintln(ltbrgt) outprintln(ltform method=POSTY

action=httplocalhost8080servletISBNProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

a lig n = le ftx ttx b gt IS B N lt b x t tx td gt ) outprintln(lttd valign=middle a lign= leftx input

type=text name=isbn size=40 value=xtdgt)outprintln(lttrgt)

outprin tln(lt trxtd c o ls p a n = 2 x p x b rx td x trgt ) outprintln(lttablegt)

out println( ltcentergt)outprintln(ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln(ltinput type=reset value=Clear

FormV id=resetl nam e= resetlxP gt )outprintln(ltcentergt)outprintln(ltformgt)

outprintln(lthr noshade size=lgt)

outpiintln(ltULgtrdquo)outprintln(lttdxtrgt)outprintln(lttablegt)

else if (pathequalsIgnoreCase(PUBLISHER_DATE))

Create publisher date collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n te r Publisher and Publication D ate ltb gtltfontgt)

1 17

outprintln( ltbrgt) outprintln(ltform method=POST

action=httplocalhost8080servletPublisherDateProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

align=leftgtlt ttxbgt P ub lisher lt b x t t x t d gt )outprintln(lttd valign=middle align= leftx input

type=text name=publisher size=40 value=xtdgt)outprintln(lttrgt) outprintln(lttrgt lttd valign=middle

a lign= leftx ttxbgt P ub lica tion D a te lt b x ttx td gt )outprintln(lttd valign=middle align= leftx input

type=text name=publication_date size=40 value=xtdgt)outprintln(lttrgt)outprintln( c t r x td c o l s p a n = 2 x p x b r x td x t r gt )outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search Now

id=submitl name=submitlgt)outprintln(ltinput type=reset value=VClear FormYrsquo

id=resetl nam e= resetlxpgt )outprintln(ltcentergt) outprintln(ltformgt) outprintln(lthr noshade size=lgt)

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush()outclose()

)

protected void CreateHeader(PrintWriter out) outprintln(lthtmigt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding bgcolor=EEEECCgt)

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20pubiic_htmlflowergifgtlttdgt) outprindn(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(lt s tro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x stro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt)outprintln(lttd w idth=20xtdgt) ou t println ( rsquo lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

out pri ntln ( ltfon tgt) outpri ntln( ltcentergt ) out pri ntln ( ltpgt) outprintln(ltcentergt) outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)out pri ntln ( ltf on tgt) outprintln(irltcentergt) out println ( ltbodygt) out pri ntln( lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

cellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=YT00 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE= -lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

1 gtS earch B ookslt fontx stronggt)outprintln(lttdgt lttrgt)out pri ntln (lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=l-lgt)

outpri ntln(ltahref=httplocalhost8080servletReqCoilectauthorgtA uthorltfontxaxtdgtlttrgt)

120

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprindn(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=V-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln(lttablexpgt)outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

121

13 ShoppingCartjava

ltpgt This is the definition for ShoppingCart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import Javautil

public class ShoppingCart Hashtable items = null int numberOfltems = 0

public ShoppingCart() items = new Hashtable()

add BookDetails to cart param bookID isbn param book book need to be added to cart copyreturn void

public void add(String bookld BookDetails book) if(itemscontainsKey(bookId))

ShoppingCartltem scitem = (ShoppingCartltem)itemsget(bookld) scitemincrementQuantity ()

else ShoppingCartltem newltem = new ShoppingCartltem(book) itemsput(bookId newltem)

numberOftems++

param bookld isbn

public void remove(String bookld) if(itemscontainsKey(bookd))

items remove (bookld) numberOfltems - -

public Enumeration getltems() return itemselements()

protected void finalize() throws Throwable items clear()

public int getNumberOfItems() return numberOfltems

public void clear() items clear() numberOfltems = 0

123

14 ShoppingCartltemjava

ltpgt This is the definition for the shoppingcart item Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class ShoppingCartltem BookDetails item int quantity

public ShoppingCartItem(BookDetails anltem) this item = anltem this quantity = 1

public void decrementQuantity() if (quantity gt 0)

quantitymdash

public void incrementQuantity() thisquantity++

i

public BookDetails getltem() return thisitem

public int getQuantity() ( return thisquantity

i

124

15 StandardFooterjava

package servlets

import j avax servlet

ltpgt This is a server side include servlet that will format the TinyBookStore HTML footer

public class StandardFooter extends GenericServlet

ltpgtPerform the servlet service

param req The request from the client param res The response from the servlet public void service (ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the response javaioPrintW riter out = new

javaioPrintWriter(resgetOutputStream())

Format the standard footeroutprintln(ctable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(rdquoltfont s iz e = - lx a href=topgtTop of

P agelt ax fon tgt )outprintln(lttrgt) out println( lttablegt) outprintln(ltcentergt) outprintln(rsquoltfont size=-lgt)outprintln(lta href=7welcomeshtmlYgtTinybookstorecom

Homeltagt ampnbsplampnbsp)outprintln(lta href=categoryhtmlgtCategoryltagt

ampnbsplampnbsp)outprintln(lta href-authorhtmlgtAuthorltagt

ampnbsplampnbsp)outprintln(lta href=titlehtmlrdquogtTitleltagt ampnbsplampnbsp)

125

outprintln(lta href=isbnhtmlgtISBNltagt ampnbsplampnbsp) outprintln(lta href=7publisherhtmlgtPublisheramp44

Dateltagt)outprintln(ltpgt)outprintln(ltfontgt)ou t println ( ltcen tergt)outprintln(ltpgt)out println (ltcentergt )outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and

disclaim er^A gt ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln( ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

outflush()outclose()

126

16 StandardHeaderjava

package servlets

import javaxservlet

ltpgt This is a server side include servlet that will format the standard TinyBookStore HTML header The Title of the page will be set to the value of the title property

public class StandardHeader extends Generic Servlet

ltpgt Performs the servlet service param req The request from the client param res The response from the servlet

public void service(ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the responsejavaioPrintWriter out = new javaioPrintWriter(resgetOutputStream())

Get the title of the page Set to empty string if no title parameter was givenString titles[] = reqgetParameterValues(title)String title = if (titles = null)

if (titleslength gt 0) title = titles [0]

outprintln(lthtmlgt) outprintln(ltheadgt) outprintln(lttitlegt + title + lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=T00 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)

127

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src=dJavaWebS erver2 Opublic_htmlflower gi A gtlttdgt) out println(lttd width=3 O x td gt ) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyB ookStorecom ltigtlth2xstrongxtdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) out printl n ( lttd width=20gtlttdgt) out printl n( lttrgt) outprintln(lttablegt)

outflush()outclose()

128

17 TitleProcessjava

ltpgt TltleProcess This is the servlet that process the Tltle-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import j avax servlet import javaxservlethttp import javaio import j avasql

public class TitleProcess extends HttpServlet protected final String EXACT = exact protected final String OTFIERS = titleWords

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

129

String[] valuesString name =

values = reqgetParameterValues(title) if (values = null)

name = values [0]

String mode =values = reqgetParameterValues(title_mode) if (values = null)

mode = values [0]

String sqlStmt =if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where title=rdquo + name +else

sqlStmt = select from BOOK where title like rsquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString()

130

outprintln(lta href=servletDetailContent + isbn+

outprintln(rsgetObject(Title)toString() +ltagtltbgt)

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toString())

outprintln( +rsgetObject(Publisher)toString() + + rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +rsgetObject(Price)toString())

outprintln(ltbrxbrgt)i

if (count == 0) outprintln(ltdtgt No matched data found)

ioutprintln(ltdlgt) II end Glossary List

catch (SQLException e) i create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

131

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=EEEECCgt)

outprintln(rdquolttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaW ebServer20public_htmlflowergifxtdgt) outprintln(lttd w idth=30xtdgt) outprintln(rdquolttd align=left valign=center width=300gt)

outprintln(ltstronggtlth2gtltigtTinyBookStorecomltixh2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(rdquolttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln( lttrgt)outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(rdquolta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(rdquoltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

132

out println( ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) outprintln( ltcentergt) outprin tln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disciaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) S y s te m out println( LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt )

outprintln(lttable width= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y- lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost 8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

133

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lt tab lex pgt )

ou t pri ntl n ( lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

134

18 checkouthtml

lthtmlgtltheadgt lttitlegtCustomer Informationlttitlegt ltheadgtltbodygt

lt hlgt ltcentergt ltbgt Customer Information ltbgt ltcentergt lt hlgt

ltform method=POST action=httplocalhost8080servletCustomerInfoProcessgt lttable border=0gt

lttrgtlttd align=rightgtFirst namelttdgtlttd colspan=2 align= leftx input type=text name=firstname size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtMiddle initiallttdgtlttd colspan=2 align= leftx input type-text name=middleinit s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtLast namelttdgtlttd colspan=2 align= leftx input type-text name=lastname size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtEmail addresslttdgtlttd colspan=2 align= leftx input type=text name=email s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgt Account pass word lttdgtlttd colspan=2 align= leftx input type=text name=password s ize= 40x tdgt

lttrgtlttrgt

lthrgtlttrgt

lttablegtltbrgt

ctable border=0gtlttrgt

lttd align=rightgtCredit card numberlttdgtlttd colspan=2 align= leftx input type=text name=creditcard s ize= 40x tdgt

lttrgtlttr valign=topgt

135

lttd align=rightgtCredit card typelttdgtlttd align=leftgtltinput type=radio name=cardtype value=visagtVisaltbrgtltinput type=radio name=cardtype value= mastercard gtMasterCardltbrgt lttdgtlttd align=leftgtltinput type=radio name=cardtype value=bluebirdgtBluebirdltbrgtltinput type=radio name=cardtype value=fishergtFisherltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtCredit card holderlttdgtlttd colspan=2 a lign= leftx input type=text name=cardholder s ize= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCredit card expire date (mmddyy)lttdgtlttd colspan=2 align= leftx inpu t type=text name=expiredate size= 40x tdgt

lttrgtlt trx trgtlt trx trgtlttr valign=topgt

lttd align=rightgtSelect shipping methodlttdgtlttd align=leftgtltinput type=radio name=shipping value=upsgtUPSltbrgtltinput type=radio name=shipping value=expressgtExpressltbrgtlttdgtlttd align=leftgtcinput type=radio name=shipping value=normalgtNormalltbrgtltinput type=radio name=shipping value=abnormalgtAbnormalltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtReceiver Namelttdgtlttd col span=2 a lign= leftx inpu t type=text name=receiver size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtAddresslttdgtlttd colspan=2 align= leftx input type=text name=address size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCitylttdgtlttd colspan=2 align= leftx inpu t type=text name=city size= 4 0 x td gt

lttrgtlttrgt

136

lttd align=rightgtStatelttdgtlttd colspan=2 align= leftx inpu t type=text name=state s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtZipcodelttdgtlttd colspan=2 align= leftx inpu t type=text name=zipcode size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtPhonelttdgtlttd colspan=2 align= leftx input type=text name=phone size= 40x tdgt

lttrgtlttablegtlt b rx b rgtcinput type=submit value=Process name=actiongt

ltformgt

ltbodygtlthtmlgt

137

APPENDIX C

Screen Display of the Test

138

mmm File Edit View Favorites T o d s Help

^ Jit j j ^ LJ U 3) ~ pound=J _Am Back - S top Refresh Home j Search Favorites History Mait Print Edit

Links gtgt Address |4S ] httDVIocalhost808QAvdcorne shtml

TinyBookStore com

Welcome to the TJnyBoakStoro com

F i v e H o t B o o k s

1 T h e C + + Programming LanguageU s u a l l y s h i p s i n 24 h o u r s

B j a r n e S t r o u s t r u p A d d i s o n - W e s l e y Pub Co 1997 Our P r i c e 31 47

2 - P r o g r a m m i n g V i s u a l C + +U s u a l l y s h i p s i n 24 h ou r I I

Local intranet

Search BooksHorne

Category

Author

Title

ISBNPublisherDate

3 iigt60

3 1 S earch T inybooksloiecom - Microsoft Internet Explorer

139

T inyB ookStorecom - Microsoft Internet Explorer

j File Edit View Favorites lo o k Help

q a a H 3 1 d B ack S top R efresh Home S earch Favorite History j M aJ Print

Links gtgt A ddress httpV localhost 308QoryleV PetailCorterV 020i8SC l4

MM

Edit

Search Books

Home

Category

Author

Title

ISBN

PublisherDate

TinyBookStore com

The C++ Programming Languageby B j a r n e S t r o u s t r u p

0

ISBN 0 2 0 1 8 8 9 5 4 4 A d d i s o n - W e s 1e y P ub Co 199 7

Reviews

P r i c e 31 47A v a i 1ab i 1i t y U s u a l 1 ys h i p s w i t h i n 24h o u r s

Aic t o c a r t

ijgJ Local intranet

140

^ | I myBook5torecom Shopping Cart - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

[v] I ^ -J JB ack - Stop R efresh Home S earch Favorites History lsquo Mail Print

Links A ddress 0 1 h ttp localhost8080servetA ddT oShoppingCart ~3 ltGdeg

Shopping Cart Item s Price

The C++ Programmi ng LanguageB j a r n e S t r o u s t r u p Q u a n t i 1 7 1

Price $ 3 1 4 7 Subtotal $ 3 1 4 7

d e l e t e

Total 31 47

Customer Information Microsoft Internet Explorer

File Edit View Favorites lo o ls Help bull _

bullgt 3i 4 n j j d a 31Back ~-j Stop- R efresh Home S earch Favorites History j Mail Print Edit

Link gtgt j Address ] j j h ttplocalhost SOSOcheekoot html

EMH1

~3

Customer Information

First name jFang

Middle initial |a

Last name Xiao

Email address fxiaomitecnet

Account password pooooc

0 1 Done

Credit card number 1234567891234567

Credit card type VisaC MasterCard

C Bluebir d C Fisher

Credit card holder jr ong Xiao

ard expire date (mmddyy) J010102

Select shipping method UPSO Express

O Normal C Abnormal

J |sect Local intranet

141

lt2] Order List - Microsoft Internet ExplorerFile |d i t View Fayotites lo o t Help

^ 3 ^ S i l S - j S tep R efresh Home Search Favorite History Mail Print h-

HFte-LLinks A ddress I g ] httplocalhost8030servletCustemeilrifoProcess 3 ^Go

Your order reads as followsE - M a i l A d d r e s s f x i a o

F a n g X i a o

ship to

T e l

11 e m s

pound] Pc

10821 W e s t e r n P l a z aOmahaME6 8 1 5 4

( 4 0 2 ) 4 9 6 - 7 5 7 0T i t l e T h e C++ P r o g r a m m i n g L a n g u a g e Q t y 1 P r i c e 31 47 S u b t o t a l 31 47

| a [ Local intianet rsquo

l i

T inyB ookSloiecom - Microsoft Internet Explorer

T 7 ~ J iii 4 a i t Vi 1+ a Si

5 E

P r i te i+ A d d ie r I ig l httplocalhot8080ervletReqCollectauthor

S e a r c h B o o k s

Horne

Ca t e g o r y

A u th o r

Title

ISBN

P ublishe r Date

jS 1 D one

TinyBookStore com

fc t i t e r l i t n o rYou can enter authors full name first name or last name

A u t h o r |sCOtt

O ExactName amp Last F irst Name (or Initial)

T itiv b o o k s to re c o m H o a e | C a te g o ry | A u th o r | T itle | ISBN | P u b lish e r D ate

C opyright and disclaim ercopy 1999-2001 F an g Xiao

T op o f P f

|sect g j Local intranet

142

linyBookStore^com- MiciosoFUnteinet ExplorerFite Edit View Favorites Tools Ftelp

IIl4 rsquojO IjjlI - 3 -Upraquo 8 a c k ltbullltbullbullltlaquo Stop R efresh Home S earch Favorites History Mail Print 1

| Links 1 Address j raquo 3 http7localhost8CI80servletAuthorProcess

l - i f l |x |

S e a r c h B o o k s

Home

C a t e g o r y

Ti t le

ISBN

P ublishe r D a te

D o n e-

TinyB o okStore com

1- Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

I G aleampory I A utho t | I jt te | ISBN | PubH shei^D atg

i t and disclaim erreg 1999-2001 F ang Xiao

Top of

l i Local intranet

j T iny8ookStorecom - M icrosoft Internet Explorer

Fite Edit View Favorites Tools Help

4- 5 ni M m ~ltpound C r =gt 2f|L i p | | | | | iAdiiill|^Thttp7localhost8080seivletD etailContent0201924889

U 3

S e a r c h B o o k s

H ome

C a t e g o r y

A u th o r

Title

ISBN

P u b lish e r P a te

TinyB o okStore com

Effective C++b y Scott Meyers

ISBN 0201924889 Addison-Wesley Pub Co 1995

R eviews

This is the review of Effective C++

R eader Comments

Price 3795 Availability U sually ships within 24 hours

Add to iosil

IIH LdcSiiihttahdt

143

l inyBookStorecom Shopping Cart - Microsoft Internet Explorer

4- -- _ t lS M JJ ltpound I 7 r mdash2--I or- Stop R efiesh Home S ea rch Favorites History Wait PrintBach

Links Y 1^ddtessj-^1 httDvVlocalliostiBOBOyservletMddToShoppinqCart 73 ^

0

Shopping Cart Item s

Effective C + +Scott Meyers Quantity 1

0 1 Done

delete

Price

Price $ 3 7 9 5 Su b to ta l $ 3 7 9 5

Total 3 7 9 5

IB~ht Locai intranet

bull 3 TinyBooKGIoFooom M icrosoft Internet Cxplorcr

Fite Edit View Favorites Tools Help

4- -4gt Lfl 4 r amp J J lt$ i icirsquo s J ~lAB ack Ti(^poundprV aTdV iS^Stop-T SfSjefre^ptr I i - M t s s j r y rvlih- i JPopSnr -JE

i i i l l l P I I I ^ I i l l ] httplocalhost8080servletR eqC ollectauthor

G3SJ

7 ^ Go

S e a r c h B o o k s

H om e

C a t e g o ry

A u th o r

Title

ISBN

Eytoiisiier Date

101 D one

T i n y B o o k S t o r e c o m

E n te r AuthorYou can enter authors full name first narne or last name

A u t h o r jCraig Larmen

E Exact N ante O Last F irst N ame (or Initial)

Search Now 1 Clear Form

I C ategory | A u th o r | j j t l s | ISBN |

C opyright and ctiiclali[er copy 1999-2001 F an g Xiao

T o p o fP ag e

^tDpcafihttangfe-

144

gj TinyBbokSlorecom - Microsoft Internet ExplorerFile Edit View F a v o n te s - Pools

4-1 4 gt_poundj Q Jl3S top R efresh Home S ea rch Favorites History Mail PrintCacl-

lsquo Unko A ddress j ig ] httplocalhostSOSCiservletAuthorProces 71

S e a r c h B o o k s

Home

C a t e o o r v

A u th o r

Tit le

ISBN

P ub l i she r D a t e

Titty Bo okStore com

1 Applying UM L and Pattern Usually ships in 24 hours Craig Larmen Prentice Hall 1997 Our Price 450

T im booksto re com Home | C ateg o ry | A u th o r | Title | I3BM | Publisher P a ts

C opyrigh t and disclaimer copy 1999-2001 F an g X iao IIg ] http7localhost 8080eopyright html Local intranet

7 j T inyBookStorecom - Microsoft Internet Explorer

^ 03 4 31 0 i -_r _j _T B ack ~j~ S top R efresh Hom e Search Favorites History Mail Print Edit

I Links Addiess AocalhcistiiiOciOserv-letCctailConfent0137488S07

u m m

S e a r c h B o o k s

HorneC a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r Date

Tiny Bo okStore com

Applying LOVIL and Patternby Craig Larmen

0 Price 450 Availability TJ sually ships within 24 hours

ISBN 013748880 Prentice Halil 997

R ev iew s

Tins is the review o f Applying UML and Pattern

R ea d er Com ments

Add to cart

01ll iPdSSIihirSdety

145

3 TinyBookStorecom Shopping Cart bull Microsoft internet ExplorerFile Edit View Favorites Tools Help

vJBeck

JStop Refresh

4Home

H Si - iS- -=dSearch Favorites History Mail Pnnt

Links rdquo Address jlti] httpVlocalhostBOSOservletAddToShoppingCart 3 ^ Gc

r o 1

Shopping Cirt J toms Price

A pplying UML and PatternCraig Larmen Quantity 1 Effective C++Scott Meyers Quantity 1

l i l le t e

delete

Price $ 4 5 0 Subtotal $45 0

Price $ 3 7 9 5 Subtotal $ 3 7 9 5

Total 82 95

d f g a j Local intranet

146

lt3 TinyBookStoiecom - Microsoft Internet ExplorerFile Edit View Favorites Io o ls Help

gt j i 4 a - a i [j JB ack Forward Stop Refresh Home S earch Favorites Histeiy Mail Print Edit

Links Address ] pound ] hiipVonahost803CeerveirsquoReqColectlsquoauthor

0 1 i

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r D a te

Tiny Bo okStore com

You can enter authors full name first name or last name

A u t h o r jJeff

O Exact N ame Last First N ame (or Initial)

Search Now i Clear Form

T inybookstorecotti H oinf | Category | A trthor | Title j ISBN | Publisher Date

Copyright and disclaimer copy 1999-2001 Fang Xiao

Top of Page

M Local intraZl

m TinyBook Stote com - Microsoft Internet Explorer

Fife Edit View Favorites Joo ls Help

ISregBack Stop Refresh Home S earch Favorites History Marl Print c

Lirrks Address samp] httplocalhost8080servletAuthorProcess ~z ^ Gc

S e a r c h B o o k s

H ome

CategoryA u th o r

Title

ISBN

P u b lishe r D a te

i M

TinyBookStore com

1 Progi aimning Windows bullwith M FC Usually slaps in 24 hours JeffProsise Microsoft P ress 1999 Our Price 4799

jnybo-okstorscom Homo | Category | A u th or | Title | ISBN | Publisher P a h

C opyright and disclaijRief copy 1999-liOO1 FangX iao

Loccii intranet

147

148

m I myUookSlorecom - Microsoft Internet ExplorerFile- pound d it View Favorite T ools Help

^ J ] 4 U J j j =jgt Stop R efresh Home S e a rc h Favorites History i Mail Print EditBack

Links AddressilaquojigThttplocalhost5 i380ser4eM D etailContent157231 pound350

rfgKxi

ldquo3 gt6deg

S e a r c h B o o k s

HorneC a teg o ry

A u th o r

Ti tle

ISBN

P ub l i she r D a t e

TinyBookStorecom

Programming Windows with M FCby JeffProsise

0

ISB N 1572316950 Micro s oft Pre s s 19 9 9

Price 4799 Availability Usually ships within 24 hours

R e N ew s

This is the review of Programming Windows with MFC

R eader Comments

A dd to cart

D one i jh j Local intranet

lt 3 TjryBook S tore com Shop p in g Cart - M icrosoft Internet Exolorer

File Edit View f a nute T ools Help

r 1B ack

J 3 Q 0J amp poundlr - Jlilip isS h lA ld rS s httpy |ocalhost8U 80AervletA ddToShoppingCait TSIIlli

Shopping Cart Item s

Program m ing W indow s w ith M F CJeffProsise Quantity 1A pplying UML a n d PatternCraig Larmen Quantity 1 E ffective C++Scott Meyers Quantity 1

d e le te

d elete

d elete

Price

Price $ 4 7 9 9 S u b to ta l $ 4 7 9 9

P rice $ 4 5 0 S u b to ta l $ 4 5 0

Price $ 3 7 9 5 S u b to ta l $ 3 7 9 5

Total 1 3 0 9 4

^ h W h e iM

S s i Local intranet

149

File Edit View Favorites lo o ls Help n4- -0 iS - M L U

Back Stop Refresh Home Search FavoritesJ

History I3 H H H B H H H BMail Pm Edit

Links rdquo Addrecs |s] hHplocalhogt5t8080servletReqCollectcategorii ^_____ bulllt bullbull llilltllll

Search Books

Home

Category

Author

Title

ISBNPublisherDate

TinyBookStore com

P r o g r a m m in g

AI g o r i t Lins CampC++ D e l p h i J a v a MFC P e r l s o f t w a r e D e s i g n UML V i s u a l B a s i c M o r e

Done

Web D e v e lo p m e n t

ASP Commercem C y b e r c u l t u r e HTML J a v a S c r i p t S e c u r i t y Web D e s ig n XML more

G r a p h i c s amp S o f t w a r e

Asobe CAD D es k t op P u b l i s h i n g G r a p h i c s M i c r o s o f t More

I J J ig Local intranet

150

finvBookStorecom - Microsoil Internet Explorer - j g j x

j Fite Edit Jfiew Favorites lo o ts Help

bull j 5 a i B ack lsquolti S top Refresh Home S e a tc h Favorites History Mail Print Edit

Links 1 Address |ltg] hitpVocalhostl-i030seryletCateciofyPreceigtVc03 ^ | g

S e a r c h B o o k s

Home CategoQ

A u th o r

Title

ISBN

Publishe r D a te

TinyBookStore com

1 Core Ja v a 2 Usually ships in 24 hoursCay S Horstmaun Prentice Hall 1999 Our Price 2579

2 Ja v a S erv let Programm itig Usually ships in 24 hoursJason Hunter i O Reilly 1993 Our Price 1977

3 Ju st J a v a 2 Usually ships in 24 hoursPerter van der Linden Prentice Hall 1999 Our Price 3149

Tinybookstorecom Home | C ategory | A u th o r | T itle | IbBN | Publisher D ateloRoIEage

n g Local intranet

ta

151

41 Tinytfookbtorecom - Microsoft Internet ExplorerFile gdit y iew Favorites JLools Help

1 ^ hgt a a a amp a j ri i - 3 bull a Back Forward Stop Refresh Home S earch Favorites History Mart Print Edit

lisLinteslsii Address ji^]h ttp localhost8D 8o7serv letD etailC ontent0130319336

M i

3 f^Gc

S e a r c h B o o k s

Homec a t e g o r y

Tiny Bo okStore com

Core Java 2by Cay S Horstmaun

El

ISBN 0130819336 Prentice H alil999

Reviews

This is the review of Core Java

R eader Comments

Price 2579 Availability U sually ships within 24 hours

I Add to car

S ] Done S i Local intranet

TinyBookStorecom Shopping Cart - Microsoft Internet Explorerfel11 File Eefit View Favorite l o o k H e lp

tljH|V| 4 a 3 j 09 c T J

Stop Refresh Home S e a rc h Favorites History j Mail Print

jiiLihkIi87js ^ B ie s S ij^ ] http Z localhost8080servletiddT oShoppirigC art

B I B

3= i

Shopping Cart Item s

Core Java 2Cay S Horstmaun Quantity 1

Icopy

t i l

delete

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Total 2 5 7 9

sal Local intranet

152

a TinvBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites J o o lr Fjelp

NBack

amp Id b iStop Refresh Home

ISearch Favorifes History - Mail Print Edit

Links gty I Address [ jg l httplocalhost8080servletD etailContent156592391 x d

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

T i t le

IS B N

Publisher Date

ampJ Lrl e

Tiny Bo okStore com

J a v a S erv le t Piograitmmigby Jason Hunter

a Price 1977 Availability XT sually ships within 24 hours

ISBN 15659239 lx O Refflvl998

R e N ew s

In this brand-new third edition of Java Servlet Programming author Bjame Stroustrup the creator of Java presents the full specification for the Java language and standard library a spec that will soon become the joint ISOANSI Java standard

j ~2J Local intranetm

dH T iny8ook5torecom Shopping Cart - Microsoft Internet Explorer

File pound d t y iew Favorites Io o ls HelpB H

a $ a i a a -Stop Refresh Home S ea rch Favorites Hi lory Mjl

3- lsquonr I

| j | i | H | g i | i | i d ^ | | | | l Q httplocalhost80S0servletAddToShoppirigCart J P

m

Shopping Cart Item s

Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d e le te

d e le te

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Price $ 1 9 7 7 S y b to ta l $ 1 9 7 7

Total 4 5 5 6

I O I

aiil

153

Lustomer Information - Microsoft Internet Explorerpoundite pounddit View Favorites Xoo|s Help

v- _) _ l 4 J I VB ack - Stop R efresh Home Search Favorites History Mail

Links gty] A ddress ] j i l h ttD localhost8080checkouthtm l

F -iVj ~f

l l i l i i

C u sto m er In fo rm a tio n

First name jFang

Middle initial lA

Last name fXiao

Email address jfxiao m itecnet

Account password jxxxxx

Credit card number ]1234567B91234567

Credit card type C VisaC M asterCard

C Bluebird O Fisher

Credit card holder jFang Xiao

Credit card expire date (mmddyy) jo 10102

Select shipping method c u p sC Express

NormalAbnormal

0 ] D one Local intranet

poundpound Order List - Microsoft Internet Explorer

s

Back

Li il raquo

Yiew Favorites l o o h Help

bullV Y lJ j X I T- lty S to p Refresh H o m e

amp 1 3 J - jrS earch Favorite History lt Mail Print

fcesssaampl httplocalhost8080servletCustom erlnfoProcess

Y o u r ord er reads as fo llow sE-Mail Address 6daomitecnet

Fang Xiao

ship to

Tel

Items

12345 Western PlazaOmahaNE68154(402) 123-4567

Title C ore Java 2 Qty 1 Price2579 Subtotal 2579

Tide Java Servlet ProjammingQty 1 Pnce 1977Subtotal 1977 Total4556

ffl|b ] Done kl Local intranet

154

mammmm 1

File Edit View Favorites lo o ts tieip

E=cl i u F t l H -n e -i i rdquo F j-oiilsquoiBillHistory lsquo gt1 ll Print Edit

iiiiiiiiiiiiiiiiiirsquo Links Address j-copy] http localhust 8080servletReqCollectisbn J

TinyBookStore com

Search Books

Home ISBN

Author

Title

IS B N

S e a r c h Hew C le a r Form

PubnsheuDate

Top o f PageITnjrbooksj^ore^ com Horne I C a te g o rv | ^ i t h o r | T i t Ie I ISBN | Publisher Date

- g ] http locdlho-st SOSOwelcome shtrnl

TinvBookStorecom - Microsoft Internet Exploier

poundaj Local intranetId

| File Edit View Favorites Tools Help

i -e -e u u r5_ _ _ a u ^ 4 - a a j Back Forward S top Refresh Home S earch Favorites History Hail Print Edit

Links A d d re ss ^ hitp rsquoIdcanc-stEtnSOservlltlsquoF-aqZoll-~ntispn z raquo h

TinyB o okStore com

S e a r c h B o o k s

Horne

A utho r

T itle

ISBN

P u b lish e r P a t e

fcntar ISBN

I SB H 1565922840

|sectplli||pbw||l| IliM M pifiillj

T rgU onL cirrti -nr Kini- | Cgtgpound-gg | Agithor | Title | ISBN f uhhe-rt Pete

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top o f Pag e

aipoundbull] O o n e Local intranet

155

File Edit View Favorites Tools Help

HUTinyBookStorecom - MicrosoH InternetExplorer

B ad-J J A J d -2r =3

Stop R efresh Home S e a rc h Favorites History Mail Print

Links ygt A ddress j ^ ] httpVlocalhost8080servletrsquoISBM Process

S e a r c h B o o k s

Horne

C a t e g o r y

A u th o r

T itle

IS B N

Pub l i she r D a t e

TinyB o okStore com

1 Learning Perl Usually ships m 24 hours Randal L Schwartz O Reilly 1997 Our Price 1997

T in vh ooksto re c o m H orne | C at ego tv | A u th o r | Title | ISBM | Publisher D ate

C opy rig h t a n d d isclaim ercopy 1999-2001 F a n g X iao

0 ] Done

yen

ighj Local i

TinyB ookStoiecom - Microsoft Internet Explorer

Erie Edrt View Favorites- lo o ls Help

-s pound] 4 pound1 jLl icArdquo =pound 2 S top Refresh Home S earch Favorites History Marl Print Edit

iilHI

NpBack

httpyiocalhostSOBOservleMDetailContentAI 565922840 ~T] Cm

Tiny Bo okStore com

S e a r c h B o o k s

H o m e i

C a teg o ry

A u th o r

T itle

ISBN

Publishe r D a te

Learning Perlby Randal L Schwartz

I ^

ISBN 1565922840 O Reillvl997

Price 1997 Availability U sually ships within 24 hours

Reviews

This is the review of learning Perl

Reader Comments M0 ] Done lsquofR | Local intranet

156

IHHHHHI _ I f f i x |

File E d t yiew Favorites J o e ls H elp 11v- -__ l

Back ~ rc Stop R efresh Home S earch Favorites HistoryJ rMail

HH1111Pgtnt

Links A ddress | ] http7docalhost8030servleM AddToShoppingCart 3 tgt G o

O S III

Shopping Cart Item s

Learning PeriRandal L Schwartz Quantity 1

delete

Price

Price $ 1 9 9 7 Subtota l $ 1 9 9 7

Total 1 9 9 7

s

Done Local intranet

Eg W illi 1 lttMM41 i H H p n B n 1 0 1 x i

Fite Edit View Favorites Toots Help E H

1$3 L plusmn J8ack Forward Stop Refresh Home Search Favoutes

4History i

- i V -=JMail Print

-Edit

71 Address http7localhost8080lsquoservletFleqCollecVisbn I l f i l l l

TinyBookStore com

Search Books

Home

C ateao rv

Author

Title

ISBN

Publisher D a te

Enter ISSN

i s bit [l 565921496

Search Now I Clear Form

Tinybookstore o n Home | Category | A uthor | Titb | ISBN | Publisher Dte

Copyright arid disclaimer copy 1999-2001 Fang Xiao zl amp j Done Js J Local intranet I

157

H H H r f e i x i File Edit View Favorites Lools Help

- J j j j ] JBack Stop Fiefresh Home Search

J JFavorites-

-J i C rHistory Mail Print

111111811i n

r Links wj i Address |reg] http docalhost 8080servletIS8N Process

S ea rch B ooks

Home

Category-

rdquo A u th o r

T i t l e

IS B fi

P u b l i s h e r D a ta

Tiny Bo okStore com

1 Programtning Perl Usually ships in 24 hours Larry Wall O Reilly 1997 Our Price 2397

T o o k s t o r e c o m H P in e | C a t e g o r y | A u t h o r | Till | IS B N | P -ubtu-hai D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g X ia

T o p o f P a g e

zlamp2 Done Local intranet

158

lt3 l mytfookSlorecom - Microsoft Internet ExplorerF3e Edit View FavoMes lo o ts Help

Back3 U Si S rsquo IStop Refresh Home lt Search Favorites History Mail Print Edit

httplocalhost8080servletDetailContent15S5321496 j3

Search Books

Horns

Category

Author

Title

ISBN

Publisher Date

Done

TinyB o okStore com

Programming Perlby Larry Wall

0 Price 2397 Av ail ability U sually ships within 24 hours

ISBN 1565921496 O Reillyl997

Reviews

This is the review of Programming Perl

Reader Comments

Add to cart

l or=lM

159

Tm vBookSlorecom Shopping Cart - M icrosoft Internet Explorer

i Fite Edit View Favorites lo o k Help

^ Beck R efresh Home

ampS earch Favorites History j Mail Print

E Links I Address ] pound http localhost 8080servletA ddT oShoppingCart rsquo ] O rai

i O

Shopping Cart Jlems

Learning Peri Randal L Schwartz Quantity 1 Program m ing PeriLarry W all Quantity 1

delete

d e le te

Price

Price $ 1 9 9 7 S u b to ta l $ 1 9 9 7

Price $ 2 3 9 7 S u b to ta l $ 2 3 9 7

Total 4 3 9 4

3SJ Done j | s [ Local intranet

160

m m mmmHi mmmHHHHHi1 File Edit View Favorites Tools Help

^ - J J -ih Ji - j| B a d Forward Stop Refresh Home S earch FavoritesHIH ctuv Mjl Print

IHIlllliEd

B l

MbfeifcssfjP Address httplocalhost8080servletFleqCollectpLiblisher_date_ ___ ________ ___________ _ bull bull bull bull_________________ Zi T gt 6 o

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

Title

ISBN

Publishe r P a t e

S ] Done

TinyBo okStore com

T rsquov -

Publisher

sind IPpiIs1iclaquoifciori OsifiC

jAd cl i so n-VVe oI e y Fuo C o ~

P u b l i c a t i o n D a t e 1U97

Search Now Clear Form

T inybookstore com Home | C ategory j A u tho r j I itle | ISBN | Publisher Ds

C opyright and disclaimer copy 1999-2001 F an g Xiao

T op o f Page

g a l Local intranet

161

lt|j TinyBookStoiecom - Microsoft Internet Explorerlsquo Erie Edit View Favorites lo o ls Help

v-1 Q rij - 3 rsquo- a u -=pound Ci Back s lsquoi i 1 Stop Refresh Home S earch Favorites History Mail Print i

jL inks i A ddress 0 1 http7localhost8Q80servletPublisherDateProcess

EMM

3

S e a r c h B o o k s

Home

C a t e g o r y

Author Title

ISBN

Publisher D a te

TinyBookStore com

1- Algorithm s in C Usually ships in 24 hoursRobert Sedgewick Addison-Wesley Pub Co 1997 Our Price 4495

2 The C++ P rogr amming L anguage Usually ships in 24 hourBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

3 Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

4- U M L D istilled Usually ships in 24 horn sMartin Fowler Addison-Wesley Pub Co 1997 Our Price 2995

Done | s j L ocalm

TinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorites l o o k Help

Backamp 3 $ -Q 3 3 AJStop Refresh Home S earch Favorites History Mail Print Edit

Lipikkigt7i Ajddr$esjhttpv7localhost8080-servletDetailCoriterit0201314525

m

3 rgtGc

S earch B ooks

Horne

A uthor

Title

ISBN

Publisher D a te

Tiny BookStore com

Algorithms in Cby Robert Sedgewick

S

ISBN 0201314525 Addison-Wesley Pub Co 1995

Reviews

This is the review of Algorithms in C

Reader Comments

Price 4495 Availability U sually ships within 24 hours

Add to cart

0I reg S a i t^ s a l intranet

162

File Edit View Favorites lo o ls Help

2 ^ iVi ^ ^ t j j B ack gt Stop Refresh Home S ea rch Favorites History ||

- i -Mail Print

WB0BUBSSSI B ifl

Links ygt Addrese |isect ] httpvVlocalhostSOSChservletAddToShoppingCart

Shopping Cart Item s

A lgontfim s in CRobert Sedgewick Quantity 1

0 1 D one

delete-

Price

Price $ 4 4 9 5 Subtota l $ 4 4 9 5

Total 4 4 9 5

Local intranet

163

^ l inyBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

ls31

3 bullrsquo -I- _J _jj - j i_ 3 - j rdquo -= $ ABack Forward Stop Refresh Home Search Favorites History Mail Print Edit

Links rdquo Address 6 J http Vlocalhost SOSOAervletR eqCollectpublisher_date j ^G

Search B o o k s

Home

categoryAutho r

Title

IS B N

Publi sher D a te

TinyBookStore com

liter Publisher and Publication Date

P u b l i s h e r Wrox Press Inc

P u b l i c a t i o n D a t e ]1

Search Now j Clear Form

T invbookstor ecotnHomg | Category | A uthor | Title | ISBN | Pu b lish e rP a t

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top of Page

zD one Local infra

m TinyB ookStoiecom - Microsoft Internet Explorer

R e Edit View Favorites Tools Help

- -i 13 4 St 2J amp t r - JHB-1

fff ij if P S | Address |sjpound~| httpVlocalhost8030servletPublisherDateProcess

S e a r c h B o o k s

Home

C a t e g o r y

A utho r

T itle

ISBN

Publisher D a te

0 ] Done

TinyBookStore com

1 Beginning Visual Basic 6 Database Programming Usually ships in 24 hour John Connell W rox Press Inc 1998 Our Price 3199

2 Befmiung Visual Basic 6 Usually ships in 24 hours Peter Wright Wrox Press Inc 1998 Our Price 3199

T inybookstore com H orae | C ategory | A u thor | Title | ISBN | Publisher Date

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top o f Fas

Local intranet

64

| File Edit Yiew Favorites T ook Help

i A - + - - a S 3 rsquo reg - pound J -3 Back ldquo d Stop Refresh Home Search Favorites History

- vMail Print

i

Edit

IllplBlllll________ g - M

isisfcinbsijp Addre s | g ) httplocalhost8080servletDetailCoritent1861001061 3 Gdeg

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

T itle

ISBN

Publishe r D a te

TinyBookStore com

Beginning Visual Basic 6 Database Programmingby John Connell

a Price 3199 Availability U sually ships within 24 hours

ISBN 1861001061 Wrox Press Inc 1998

Reviews

This is the review of beginning Visual Basic 6 Database Programming

Reader Comments

A d d to c a n

S] pone Local intranet

m u i

lillllEHl ^ bdquo A 3 2tl 4 t M liJ i

Back Forward Stop Refresh Home Search Favorites3

History 4 _ r

M j 1J

Print EditiSillilillllS

httplocalhost8080servletReqCollecttitle

S e a r c h B o o k s

Home

C a t e g o r y

Author

Title

ISBN

Publisher Date

TinyB o okStore com

Enter TicleYou can enter the exact title or part of title

T i t l e C++

O Exact Title Title Words

Search Now Clear Form

Example

bull Entering Java Servlet Programming in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title are related to Java _li

165

lt5 TinyBookStorecom - Microsoft Internet ExplorerFite Edit View Favorites lo o ts Help

Back Stop Refresh Home S earch Favorites History Mail Print

Links gty Addiess http-localhost8080servlet7TitleProcess

i|p1

I

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

Publi sher IS a t e

TinyBookStore com

1 The C++ Programming L anguage Usually ships in 24 hoursBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

2 Effective C+-F Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

3 Programttung Visual C-H- Usually ships in 24 hours David J Kmglinski Microsoft Press 1998 Our Price 3999

T m y h o o k s to e co m H o m e | C a te g o ry | A u th o r | T itle | ISBH | P u b lish er D ate

http iocalhost SOSOservletFleqCollectcategary

T op of P age

~hj Local intranet

bull a TlnjpBflOkStOfecom - Microsoft Internet Explorer

File Edit View Favorite Pools Help

0 3 4 S l i 3 O - J J i t of Stop Refresh Home S earch Favorites History - Mart Print Edit

HBack

i i i i lS i lB i I i f f id i l f f lH Q http Vlocalhost 8080AervletD etailContent1572318570

EEEI

J

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b lis h e r D a f t

TinyBookStore com

Programming Visual C++by David J KrngHnski

[Hj

ISBN 1572318570Microsoft Press 1998

Price 3999 Availability Usually ships within 24 hours

R e v ie w s

This is the review o f Programming Visual1

Reader Comments

Add to cart

if Local intranet

166

mm| File pounddtt View Favorites Jo o ls Help

c J J j j mdash JB ack - J Stop Refresh Home S earch Favorites History

- _ i -M u

J tPrint

t e t a f e w P A ddress | ^ ] httplocalhost8080servletAddToShoppingCart zl -lt1gtSo

Shopping Cart Item s

Programmeng Visual C + +David J Kmgbnski Quantity 1

delete-

Price

Price $ 3 0 9 0 Sub to ta l $ 3 9 9 9

Total 3 0 9 9

D one ^aj Local intranet

TinyBookStorecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

vHBack-

-J a 4 -a si fi- 3 aStop R efresh Home S earch Favorites History j Mail Print- Edit

Links gty A d d re s sL ^ ] hrtpWlocalhostSOSOservleVFIeqCollectAitle

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

ISBN

Pub l i she r Date

TinyBookStore com

Enter TitleYou can enter the exact title or part of title

Title Distil I nrfExact T itle V T itle W o rd s

Search Now | Cle ar Fo rm

Examples

rpound] Done

bull Entering Java Servlet Programming11 in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title arei date 11 j Java JZJ

167

a TlnyBA5kSioiecom - Microsoft Internet Explorergt 0e Edit ifiew Favorites Jock Jd lp

a a amp -a tii j k i Back s - Stop Refresh Home Search Favorites History Mail Print

liilP raquo httpiVlocalhostSOSOservletTitleProcess

E M 3

ldquo3 rgt-

S ea rch B ook s

Horne

C a t e d o r v

A utho r

TiUgt~ ISSN

Publi sher D a te

Tiny BookStore com

1- TJML D istilled Usually ships in 24 nowsMartin Fowler Addis on-Wesley Pub Co 1997 Our Price 2995

| C s rg g o ty | A u th o r | T itle | IStBH I P u b lis h e r D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g Xiao

-jg Local intranetS3

m n ^ i l a i i x l

File Edd View Favorites Joels- Help M Mi r J lt 3 L h f 4 - 0 lt 3

Back i t Stop Refresh Home S earch Favorites History Mail9

PrintM

Edit

Links raquo A ddress j | i ] http do ca lh o d 1030N m letDetailContenr0201325632 Mimas

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

Title

IS B N

Publisher Date

Tiny BookStore com

TJML Distilledby Martin Fowler

0

ISBN 0201325632 Addison-Weslev Pub Co 1997

Reviews

Tins is the review of The UML Distilled

Reader Comments

Price 2995 Avail abilityTJs u ally ships within 24 hours

Add to c a r t

0 3S i] Done |g^iLnealiihfrregei

TinyBookStorecom Shopping Cart Microsoft Internet ExplorerFile Edit View Favorites Jo o ls HetP

IBiiiBlll l l lHBlSglSlllllilMH MlllBliriilllgllSlIlBack - f - i - S top Refresh Home

a J i l ^ j 3 Search Favorites History 1 Mail Print liiii

3 Links ( A ddress j ig j hrtplocalhost803DservletAddToShoppingCart

Shopping Cart Herns Price

UML D istilledMartin Fowler Quantity 1Program m ing Visual C + +David J Kraglinski Quantity 1

Price $ 2 9 9 5 Subtota l $ 2 9 9 5

delete

Price $ 3 9 9 9 Subtota l $ 3 9 9 9d elete

Total 6 9 9 4

  • Electronic Commerce on Business Application
    • Recommended Citation
      • tmp1499779448pdf2JOpQ

UMI Number EP73453

All rights reserved

INFORMATION TO ALL USERS The quality of this reproduction is dependent upon the quality of the copy submitted

In the unlikely event that the author did not send a complete manuscript and there are missing pages these will be noted Also if material had to be removed

a note will indicate the deletion

D issertation RyblisMrtg

UMI EP73453

Published by ProQuest LLC (2015) Copyright in the Dissertation held by the Author

Microform Edition copy ProQuest LLCAll rights reserved This work is protected against

unauthorized copying under Title 17 United States Code

ProQuest LLC789 East Eisenhower Parkway

PO Box 1346 Ann Arbor Ml 48106 - 1346

THESIS ACCEPTANCE

Acceptance for the faculty of the Graduate College

University of Nevraska in partial fulfillment of the

Requirements for the degree of Master of Science

University of Nebraska at Omaha

Committee

DepartmentSchoolName

Chairperson_

Date rdquo l l - l l - i m

Acknowledgements

I would like to express my sincere appreciation to my thesis advisor Professor Peter A

NG for his kind guidance time and support I would also like to say thank you to my

supervisory committee Dr Qiuming Zhu Dr Bin Chen for their suggestions help and

cooperation

Abstract

For some time now Whole size business enterprises have used electronic commerce

to conduct their business activities The On-Line store is one of a number of popular

web applications This thesis focuses on one of the emerging On-Line store

technologies which is known as Server-Side Java Application

In early 1960 private networks were dedicated for the use of electronic data

interchange (EDI) and electronic funds transfer (EFT) in banking business Recently

however with the increased awareness and popularity of the Internet electronic

commerce has come to encompass individual consumers as well as businesses of all

size For most people electronic commerce is defined as the buying and selling of

products and services over the Internet but there are many more aspects We will

discuss different definitions of electronic commerce in this paper

The most popular Web applications are the On-Line Stores Most of such applications

involve functions as searching for product information ordering products paying for

goods and services and for providing online customer service A Web server running

continuously accepts userrsquos connection gets user requests and forward requests to

business procedure retrieves data (answers to user requests) from business procedure

and sends it back to the user

An on-line store system is different from a traditional web publishing It needs a

customerrsquos interactive communication and frequent data update The traditional

HTML page does not satisfy the customerrsquos needs because all it does is simply

publish static contents More complex technologies are required in order to produce

dynamic contents

There are a few technologies that can be used for implementing the on-line stores

Common Gateway Interface (CGI) Microsoft Active Server Page (ASP) and Server-

side Java application are the most popular technologies Introducing the Server-Side

Java application is one of the latest and most exciting trends in Java programming

The Server-side Java application has many advantages over the other technologies

Table of Contents

Chapter 1 Introduction 1

Chapter 2 Electronic Commerce 2

21 What Is Electronic Commerce2

22 The Importance of Electronic Commerce3

23 Types of Electronic Commerce3

24 Why Most Internet Based Electronic Commerce Is In

The Business-To-Consumer W orld 6

25 Current State of Business-To-Consumer E-Commerce7

26 The Structure of The On-Line Store8

Chapter 3 Technologies For On-Line Store System11

31 Traditional Web Application - Common Gateway Interface(CGI) 11

32 Active Server Page 12

33 Server-Side Java Application 14

Chapter 4 Design of On-Line Bookstore Using Java Servlets

A Practical Verification18

41 The Design of Home Page of Tiny Book Store18

42 Design of Search by Different Requests27

43 Servlets Chaining To Process Requests In Different Levels28

44 Database Connectivity and Search from Database29

45 Session Tracking 35

46 Check O ut42

47 Customer Information Processing 43

Chapter 5 Future Work50

51 Connection Pooling50

52 More Object-Oriented - Better Encapsulation51

Chapter 6 Conclusion 53

Appendix A Bibliography54

Appendix B The Source Code of An On-Line Store System -

Tiny Book Store57

Appendix C Screen Display of the Test 135

List of Figure

Figure 261 The Structure of An Online Store 10

Figure 321 Handle Requests Flow Chart 13

Figure 331 HttpService of The Java Web Server Using Servlets 15

Figure 411 The Home Page of Tiny Book Store 22

Figure 412 One of The Searching by Author Pages26

Figure 441 One of The Outputs of Servlet AuthorProces 34

Figure 451 A Page Show All Information About A Book 39

Figure 452 A Page Show Items In The Shopping Cart After A User

Added Books To The Shopping Cart 40

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A

Book From The Shopping Cart42

Figure 461 A Check Out Page 43

Figure 471 An Invoice Page48

1

Chapter 1

Introduction

As we step in the year 2000 we can no longer look to the past as the guide for the

future A combination of business social and technical possibilities drives the rapid

progress in electronic commerce

Electronic commerce can offer a company both short-term and long-term benefits

Not only can it open new markets enabling a business firm to reach new customers

but it can also make it easier and faster for the firm to do business with their existing

customer base Moving business practices such as ordering invoicing and customer

support to network-based systems can also reduce the paperwork involved in

business-to-business transactions When more of the information is digitized it

allows that business firm to focus on meeting their customerrsquos needs Tracking

customer feedbacks and presenting customer solutions for their clientele are just

some of the opportunities that can stem from electronic commerce

2

Chapter 2

Electronic- Commerce

21 What Is Electronic Commerce

For some time now large business enterprises have used electronic commerce to conduct

their business-to-business transactions In early 1960 private networks were dedicated

for the use of electronic data interchange (EDI) and electronic funds transfer (EFT) in the

banking industry Recently however with the increased awareness and popularity of the

Internet electronic commerce has come to encompass individual consumers as well as

businesses of all size

To many electronic commerce is defined as the buying and selling of products and

service over the Internet But there are many other aspects Depending on whom you ask

electronic commerce has different definitions

From a communications perspective electronic commerce is the delivery of information

productsservices or payments via telephone lines computer networks or any other

means From a business process perspective electronic commerce is the application of

technology toward the automation of business transactions and workflow From a service

perspective electronic commerce is a tool that addresses the desire of firms consumers

and management to cut service costs while improving the quality of goods and increasing

3

the speed of service delivery From an online perspective electronic commerce provides

the capability of buying and selling products and information on the Internet and other

online services [16]

These definitions are valid with their perspectives It is a matter of which lens is used to

view the electronic commerce landscape Broadly speaking electronic commerce

emphasizes the generation and exploitation of new business opportunities by ldquogenerating

business valuerdquo or ldquodoing more with lessrdquo

22 The Importance of Electronic Commerce

As we approach the year 2000 we can no longer look to the past as guide to the future In

the face of strong market forces created by electronic commerce and mounting

competition corporations can no longer plod along historical tracks or seek the

preservation of the status quo Companies are discovering that old solutions do not work

with new problems The business parameters have changed and so have the risks and

payoffs

23 Types of Electronic Commerce

From a broad view there are three distinct general classes of electronic commerce

applications Inter-organizational (business-to-business) intra-organizational (within

business) and customer-to-business application [16]

4

231 Inter-Organizational Electronic Commerce

Inter-organizational electronic commerce makes business more convenient on the

following aspects

Firstly e-commerce can improve supplier management since electronic applications can

reduce the processing costs and cycle times for each purchase order and it can reduce the

number of people who work on purchase orders

Secondly e-commerce can improve inventory management since electronic applications

make the business partners can fast exchange information and easy track their documents

to ensure that they were received This not only can eliminate out-of-stock occurrences

but also can reduce inventory and improve inventory turn

Thirdly e-commerce can improve distribution management since electronic applications

can make the business partners receive the shipping documents as soon as possible and

enable better resource management by ensuring that the documents contain more accurate

data

Fourthly e-commerce can improve channel management since electronic application can

let the business partner post the information to electronic bulletin boards This can

eliminate repeated telephone calls and countless labor hours

Fifthly e-commerce can improve payment management since the business partner are

linked by network so the payments can be sent and received electronically Electronic

payment is more accurate and fast than traditional payment

232 Intra-Organizational Electronic Commerce

5

Intra-organizational electronic commerce facilities the following business applications

Workgroup communications Electronic applications enable manager to

communicate with employees using electronic mail videoconferencing and

bulletin boards

Electronic publishing Electronic applications enable companies to publish

information by using tools such as the World Wide Web On-line publishing can

show information immediately and clearly and reduce costs for printing and

distributing documentation

Sales promotion Electronic application improve the flow of information between

the production and sales forces and between the firms and customers This can

make companies have greater access to market and competitor information

Today Intranets are primarily set up to publish and access vital corporate information

Some of the most common types of information are Human Resources information

employee communications product development and project management data internal

catalogs sales support data equipment and shipment tracking and accessing corporate

database

233 Consumer-To-Business Electronic Commerce

In consumer-to-business transactions customers learn about products through electronic

publishing buy products with electronic cash and other secure payment systems and

even have information goods delivered over the network

6

From the consumerrsquos perspective there are three transactions

1 Electronic applications enable consumers to communicate with each other through

electronic mail videoconferencing and news groups

2 Electronic applications enable consumers to manage investments and personal finances

using online banking tools

3 Electronic application enable consumers to find online information about existing and

new products services

Consumers consistently demand greater convenience and lower prices Electronic

commerce provides consumers with convenient shopping methods from online catalog

ordering to phone banking both of which eliminate the costs of expensive retail

branches Electronic commerce facilitates factory orders by eliminating many

intermediary steps thereby reducing manufacturersrsquo inventory and distribution costs and

indirectly providing consumers with lower prices

24 Why Most Internet Based Electronic Commerce Is In The Business-To-

Consumer World

For the Business-to-Business e-commerce the lack of well-accepted standards is

hindering the success in promoting Business-to-Business electronic commerce

solutions[5] VAN (Value-Added Networks) EDI (Electronic Data Interchange) based

solutions are only accessible to large organizations due to the cost factor Corporate

buyers and suppliers large and small are looking for Internet based solutions to

streamline the procurement procedures and to reduce the cost of establishing trading

relationship and the trading transactions Such demands put forward some fundamental

challenge on issue like trust infrastructure on the Internet standards and inter-operability

etc

25 Current State of Business-To-Consumer E-Commerce

Business activity on the Internet is currently limited to publicizing the business

opportunity and to catalog based sales but it will rapidly expand to include the

negotiations conducted to settle the price of the goods or commodities being traded

These negotiations are currently conducted by human intermediaries through various

forms of auctions bidding systems for awarding contracts and brokerages The role of

the intermediaries can now be performed by Internet trading applications at a fraction of

the cost[4] Trading on the Internet allows a business to reach a large number of potential

customers and suppliers in a shorter time and a lower cost than possible by other modes

of communication and to settle business transaction with lower cost overhead in a shorter

time

Auctioned or brokered sales are the norm in business world for negotiating trades of large

monetary value But consumer sales and small-scale purchases have used the fixed price

mode perhaps because of the high overhead cost of using the auction or brokerage

method The new economics of the Internet will make auctions popular in consumer and

small business transactions also

Auctions are just one form of business negotiations Other examples are competitive bids

for procurement brokeragesexchangescartels and two party negotiations

Nowadays the free-market economy of software agents is in the embryonic stage But in

the near future the software agents will populate the Internet and provide trade and use

a rich variety of information goods and services in an open free-market economy In a

free-market economy of software agents information is produced traded and consumed

by vast numbers of autonomous self-motivated agents An essential task in such an

economy is the retailing or brokering of information gathering it from the right

producers and distributing it to the right consumers[10] The overall research goal is to

characterize and understand the dynamic behavior of information economies very large

open economies of automated information agents that are likely to come into existence in

the Internet

26 The Structure of The On-Line Store

9

Nowadays there are thousands of on-line stores running on the Internet A few well-

known ones are amazoncom and bookpoolcom Most of such applications involve

common functions which are as following

Searching for product information

Ordering products

Paying for goods and services

Providing online customer service

So they have a similar structure as shown in Figure 261 The system contains the

following components

1 A web server running continuously accepts userrsquos connection gets user requests and

forward requests to business procedure retrieves data (answers to user requests) from

business procedure and send it back to user

2 Business procedure usually consists of a user identification procedure like credit card

check user request analysis procedure analyzing requests calculating discomposing (if

necessary) and dispatching request to different data source component Also in some

case business procedure is responsible to compose data obtained from different data

sources into user-readable format

3 Database is the place to hold relevant data These data not only serve as a data source

describing commercial goods and prices but can be used for data mining to improve

store service quality as well Database is updated and maintained by both customersrsquo

input and system applications A customerrsquos input usually includes order information

10

Figure 261 The Structure of An Online Store

(through browser)

Databas

(through browser)client

client

serverWeb

Systemapplication

Busines

procedu

4 System applications can include a search engine running all the time and searching

relevant information from the internet data mining application deals with mining and

analyzing customer and sale data for management use database maintaining application

handles update data when product information changes Varying from system size to

system size not every system has cleardistinct boundaries between these components

The system can be 3-tired or n-tired but these systems all operate in similar ways

11

Chapter 3

Technologies For On-Line Store System

An on-line store system is different from traditional web publishing It needs customerrsquos

interactive communications and frequent data update The traditional HTML page is

insufficient because all it does is provide static content publishing Other technologies

are required in order to implement the on-line store

Currently there are three mainstream technologies which are widely used Common

Gateway Interface (CGI) Microsoft Active Server Page (ASP) and Server-side Java

application We briefly explore these technologies here

31 Traditional Web Application - Common Gateway Interface (CGI)

The common Gateway Interface normally referred to as CGI is one of the first practical

techniques for creating dynamic content With CGI a web server passes certain requests

to an external program The output of this program is then sent to the client in place of a

static file The advent of CGI makes it possible to implement all sorts of new

functionality in web pages and CGI quickly become a defacto standard implemented on

dozens of web servers Even though a CGI program can be written in almost any

language the Perl programming language is the predominant choice However CGI have

some distinct disadvantages

Firstly CGI program is transient A request is made each time to a CGI program It must

be loaded and executed by the Web server When the CGI program is complete it is

removed from memory and the results are returned to the client All program

initialization (such as connecting to a database) must be repeated each time a CGI

program is used

Secondly when a server receives a request that accesses a CGI program it must create a

new process to run the CGI program and then pass to it via environment variables and

standard input Every bit of information might be necessary to generate a response

Creating a process for every such request requires time and significant server resources

which limits the number of requests a server can handle concurrently

Thirdly a CGI program cannot interact with the web server or take the advantage of the

serverrsquos abilities once it begins execution because it is running in a separate process

32 Active Server Page

As shown in figure 321 the following list walks you step-by-step through what

happens if the client requests the page xyzasp

The client requests the page xyzasp from the server The Web server checks the file

extension to see whether a special program (such as the Active server Pages engine)

13

must be invoked to process the request If therersquos a asp extension the Web server

determines that it should invoke ASP to process this page

Figure 321 Handle Requests Flow Chart

Request

Response

WEB SERVERComponents

Databas

ns

ASP File

CLIENT

Active X Data

VBScript

If this page has never been requested before or has been changed since the last

request it must be parsed and the syntax checked and then be compiled by the Web

server Otherwise the page might be read from a cache of recently processed pages

which aids in performance During the parsing process the HTML and scripting code

14

are separated IIS (Internet Information Server) determines which scripting engine is

responsible for which part of the script and delegates the work of syntax checking and

compiling to the proper scripting engine (such as VB Script)

Now the code is executed by the scripting engine using resources from IIS which is

hosting the scripting engines All objects that the language engine cannot handle are

requested by the IIS which is also responsible for handling inputs and outputs for the

external ActiveX objects that are created and used inside the script If it is not able to

supply the object an error is generated

Script output and static HTML code in the ASP file are merged

The final HTML is sent back to the user in an HTTP response

The important point about ASP is that the Script runs entirely in a server to protect the

intellectual property by shielding it from browser which are different from the account

for when writing client-side code The entire server-side code is processed and only plain

HTML - or whatever kind of content you chose to generate - is sent to the client

33 Server-Side Java Application

The rise of server-side Java applications is one of the latest and most exciting trends in

Java programming A Servlet can be thought of as a server-side applet Servlets are

loaded and executed by a Web server in the same manner that applets are loaded and

executed by a Web browser

15

As shown in Figure 331 a servlet accepts requests from a client (via the Web server)

performs some task and returns the results

The client (mostly likely a Web browser) makes a request via HTTP The Web server

receives the request and forwards it to the servlet If the servlet has not yet been loaded

the Web server will load it into the Java virtual machine and execute it The servlet will

receive the HTTP request perform some type of process and return a response back to

the Web server The Web server will forward the response to the client

Figure 331 HttpService of The Java Web Server Using Servlets

RequestResponseRequestResponse

RequestResponse

Java Web Server

Administrative SERVLET

SERVLETHTTP

SERVLETWeb Proxy

Servlets have distinct advantages over CGI program

Servlets are persistent Servlets are loaded only once by the Web server and can

maintain services (such as a database connection) between requests

Servlets are fast since servlets only need to be loaded once

16

Servlets are platform independent Servlets are written in Java and conform to a well-

defined and widely accepted API They are highly portable across operating systems

and across server implementations A servlet can be developed on a Windows NT

machine running the Java Web Server and later can be deployed effortlessly on a

high-end Unix server running Apache

Servlet portability is not the stumbling block it so often is with applets There are two

reasons Firstly servlet portability is not mandatory Unlike applets which have to be

tested on all possible client platforms servlets have to work only in the server

machines that you are using for development and deployment Unless you are in the

business of selling your servlets you donrsquot have to worry about complete portability

Secondly servlets avoid the most error-prone and inconsistently implemented portion

of the Java language the Abstract Windowing toolkit (AWT) that forms the basis of

Java graphical user interfaces

Servlets are extendable Servlets that are written in Java brings all of the other

benefits of Java to servlet Java is a robust object-oriented programming language

which can be extended easily to suit our needs

Servlets are secure The only way to invoke a servlet from the outside world is

through a Web server This brings a high level of security especially if the Web

server is protected behind a firewall

Servlets can be used with a variety of clients

Servlets are tightly integrated with the server This integration allows a servlet to

cooperate with the server For example a servlet can use the server to translate file

paths to perform logging and to check authorization

Servlets are quite flexible An HTTP servlet can be used to generate a complete web

page it can be added to a static page using a ltSERVLETgt tag in whatrsquos know as a

server-side include and it can be used in cooperation with any number of other

servlets to filter content in something called a servlet chain

18

Chapter 4

Design of On-line Bookstore Using Java Servlets A Practical

Verification

Server-side Java application is one of the latest technologies used to implement an onshy

line store system Servlet is a set of classes that come up from Java language It is

designed to be used for server-side Java applications There are many techniques people

can use when they utilize servlet such as Server-Side Include (SSI) Servlet Chaining

Applet and Servlet communication etc We tried to use as many such techniques as

necessary in our implementation to demonstrate the advantages of servlets

The demonstration system module is same as the one we mentioned above Figure 331

We use this module to show how such system works

The system called Tiny Book Store emulates an on-line bookstore selling computer

books It has the full functionality of other on-line stores The only difference between

this system and the other on-line systems is the database size We donrsquot want to spend

much developing time for database maintaining part because this part is similar to

ordinary database maintaining and it is an independent subsystem The Tiny Book Store

mainly consists of three modules user interface business procedure and data access

19

41 The Design of Home Page of Tiny Book Store

The home page - welcome page - is designed using the Server-Side Include technique

That is embedding a servlet inside HTML file with a specific HTML tag ltSERVLETgt

In our case this servlet when invoked can run a query on database via data access

objects to retrieve most recent top 5 best-seller books and then returns the retrieved data

to the place within the page where the ltSERVLETgt tag was As long as the data in

database update timely it is guaranteed that customer will get the most recent data

The embedded servlet is invoked by Java Web Server before the page is sent back to

client Java Web Server processes any HTML file having shtml extension and invokes

the embedded servlet marked by ltSERVLETgt tags

Server-Side Includes are useful when a page is primarily static but contains a few distinct

dynamic portions One of the servlets produces the ldquo Five Hot Books ldquo which is shown in

the following example

Example 411 A Part of Code of welcomeshtml

lt P gt

lth3xstrongxf ont color= f f 6347 gtWelcome to theltigt

TinyBookStorecomltigtltfontgtltstronggtlth3 gt

20

ltstrongxbxh3gtltcentergtFive Hot

Booksltc e n t e r x h3gtltbgtltstronggt

ltbrgt

ltservlet code=EchoServletTaggt

ltservletgt

The servlet EchoServletTag searches database according to some business rule and gets

data from data access objects to produce the Five Hot Books The following example is

the sample code

Example 412 A Part of Code of The EchoServletTagjava

public void service(HttpServletRequest req

HttpServletResponse res)

throws ServletException IOException

res setContentType ( text Jhtml)

PrintWriter out = resgetWriter()

try

Statement stmt = concreateStatement()

21

ResultSet rs = stmtexecuteQuery(select from

book where

title like Programming)

int count = 1

outprintln(ltdlgt)

while (rsnext() ampamp count lt 6)

out print In ( ltdtxbgt + count + )

String isbn =

rsgetObj ect(ISBN) toString()

outprintln(lta

href=servletDetailContent + isbn +

outprintln(rsgetObj ect(Title) toString()

+ lt a x bgt )

out println ( ltddxnobrxfont color=990033gtUsuallY

ships in 24 hoursltBRxfontxnobrgt )

outprintIn(ltbrgt +

rsgetObject(Author) toString() )

outprintIn( +

r s getObject(Publisher)toString() + +

r s getObj ect(PublicationDate) toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

out println ltbrxbrgt )

22

count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()

The servelt EchoServletTag by the business mle that searching a specific table sends a

request query through data access object stmt and gets search result through another

data access object rs It then passes data to the page The content between ltservletgt and

ltservletgt tags in the HTML of home page is replaced by the search result at run time

The center part of the sample result page in Figure 411 is an example

23

Figure 411 The Home Page of Tiny Book Store

gj Search TinybookstGiecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

^ bullgt o a 4 i a a j ugt- a a Back lt7gtn Stop Refresh Home j Search Favorites History Mail Print Etfe

-Six

sfekinlfeSsI 3 Address |iS1 httpiVlocalhosLSOSCVwelcomeshtrnl Cj

f S M B l TinyBookStorecom

Search B o o k sW e l c o m e tc f l i e

HomeFive H ot Books 1 1

Category i-si

IA uthor

Title1 The C + + Programming L a n g u a g e B

Usually ships in 114 hoursISBN

k

IPublisher D a teBjame Stroustrup Addis on-Wesley Pub Co 1997Our Price 3147

m2 Programming Visual C+ +

Usually ships in 24 hours y

David J Krn^dinski Dlicrosoft Press 1998 c damp Local intranet

From this practice we know Server-Side Include not only can produce dynamic portion

of the page but also prevent from other people spy into your code Since Java servlet runs

entirely on a server thus protecting your intellectual property and shielding you from the

browser This means what the client sees can be totally different from what the server

does From the client side it is difficult to figure out how the server works

The left-hand menu items are implemented by using a characteristic of servlet - extra

path information or virtual path The extra path information can be used as a kind of

parameter passed to a servlet In general this extra path information is used to indicate a

24

file on the server that should use for something We use this feature here in an abnormal

way to manage customer requests and process these requests in a single place

Consider a traditional method When a menu item is selected by a customer it redirects

the customer to another page where it hyperlinks to If we have several ten items we

need to pre-create several ten pages This is the disadvantage of static HTML pages

However with servlet which can dynamically generate page content we can direct all the

customer requests to a central servlet and process the requests there according to some

condition (parameters) and then generate the page which customer need to see In this

way we only need one place to hold the code to save serverrsquos space And this place is

easy to maintain

The following is how it was doing for the Tiny Book Store

The Author item uses the following hyperlink

ltA

href = servlet ReqCo 11 ect author gtAuthorlt fontx AxTDgt

ltTRgt

The ReqCollect is the name of a servlet We pass the ldquoauthorrdquo in the hyperlink as a

parameter to ReqCollect When the Author item is selected ReqCollect is invoked by

lava Web Server ReqCollect generates a html page to let a user input author search

condition The ReqCollect code is listed below

25

Example 413 A part of Source Code of ReqCollectjava

public class ReqCollect extends HttpServlet

protected final String AUTHOR = author

public void service(HttpServletRequest req

HttpServletResponse res) throws ServletException

IOException

PrintWriter out = resgetWriter()

String path = reqgetPathlnfo ()

if (path == null)

error handling

else

Create standard header

CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

26

path = pathsubstring(1)

if (pathequalsIgnoreCase(CATEGORY))

Create category request collect

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

outprintln(ltfont color=CC66 0 0

face-verdana arial helvetica size = + lxbgtEnter

Authorltbgtltfontgt )

outprintln(ltbrgt You can enter

authors full name first name or last nameltpgt)

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess

id=forml name=formlgt)

outprintln(lttable border=0gt)

outprintln(lttrgt lttd valign=middle

align = lef txttgtltbgtAuthor ltbxttxtdgt )

outprintln(lttd valign=middle

align = lef txinput type = text name= author size = 40

value=x tdgt )

outprintln(lttrgt)

27

outprintln(lttrgt lttd colspan=2gt ltfont

size=-lgt)

outprintln(ltcentergt ltinput

type=radio name=author_mode value=exact

checkedgt Exact Name)

outprintln(ltinput type=radio

name=author_mode value=lastgtLast First Name (or

Initial) )

outprintln(ltcentergt)

outprintln(ltfontgt)

outprintln(lttdgt lttrgt)

outprintln(lttrgt lttd colspan=2gt ltpgt

ltbrgt lttdgt lttrgt)

outprintln(lttablegt)

outprintln(ltcentergt)

outprintln(ltinput type=submit

value=Search Now id=submitl name=submitlgt)

outprintln(cinput type=reset

value=Clear Form id=resetl name=resetlxpgt )

outprintln(ltcentergt ltformgt)

Create standard footer

28

CreateFooter(out)

outflush()

outclose()

The generated page looks like this

Figure 412 One of The Searching by Author PagesTinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorite l o o k H e lp

^ 3 4 s j ] S o zdStop Refresh Home Search Favorites History Mail Print EditBack bull

I t i h f e l f f httplocalhost8080servletReqCollectauthor

S ea rch Books

Home

C a t e g o r y

Author

Title

ISBN Publisher Date

poundj

TinyBookStore com

You can enter authors foil name first name or last name

A u t h o r jbjarne

C Exact N ame amp Last First N atne (or Initial)

Search Now | Clear Form

Taw boekstofeeoraH om e | Category | A uthor | Title | IS3M | Publisher Date

jpyright and disclaimer copy 1999-2001 F ang Xiao

ihtterteti

42 Design of Search by Different Requests

29

According to different requests the different pages should be produced There are many

common parts in the produced pages So we donrsquot need to code the common parts for

each page We can design the common parts into standard utility classes or static

functions You can simply call the standard classes or functions when you needed them

An example looks like this

CreateHeader(out)

CreateLeftMenu(out)

CreateFooter(out)

The three lines above invoke the standard functions CreateHeader() CreateFooter() and

CreateLeftMenu() which are developed in this thesis writing The CreateHeader()

function produces the top part of the pages The CreateLeftMenu() function produces the

left part of the pages The Createfooter() function produces the bottom part of the pages

You can find the source code in several servlets in Appendix

43 Servlet Chaining To Process Requests In Different Levels

A request can be handled by a sequence of servlets This system is designed to use the

first level servlets to handle the search requests If needed the first level servlets can

cooperates with the second level servlets by passing their processing result to the second

level servlets and let them to proceed the request until the final result is obtained The

final result is returned by the last servlet This is called servlet chaining The request

30

from the client browser is sent to the first servlet in the chain The response from the last

servlet in the chain is returned to the browser In between the output from each servlet is

passed as an input to the next servlet Each servlet in the chain has the option to change

or extend the content W e can see the example in the ReqCollect code

Example 431 A Part of Code of The ReqCollectjava

if (pathequalsIgnoreCase(AUTHOR))

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess id=forml

name=formlgt)

The ReqCollect servlet uses the getPathInfo() method to get the extra path information

This method returns the extra path information associated with request According to the

different extra path information the first level servlet invokes the different servlet of the

second level In this case ReqCollect invokes AuthorProcess servlet The final output

has been listed in Figure 412

31

44 Database Connectivity and Search from Database

The biggest advantage for servlets with regard to database connectivity is that the servlet

life cycle allows servlets to maintain open database connections An existing connection

can trim several seconds from a response time compared to a CGI program that has to

reestablish its connection for every invocation

Another advantage of the servlets over CGI and many other technologies is that JDBC is

database-independent JDBC is a SQL-level API - one that allows you to execute SQL

statements and retrieve the results if any The API itself is a set of interfaces and classes

designed to perform action against any database

An individual database system is accessed via a specific JDBC driver that implements the

javasqlDrivers interface Drivers exist for nearly all-popular RDBMS systems The

database connection used for Tiny Book Store uses a JDBC-ODBC bridge driver coming

along with the JDK 12 to allow access to standard ODBC data source such as the

Microsoft Access database

The first step in using a JDBC driver to get a database connection involves loading the

specific driver class into the applicationrsquos Java Virtual Machine This makes the driver

available later when we need it for opening the connection An easy way to load the

driver class is to use the ClassforNameQ method

32

ClassforName(sunj dbcodbcJdbcOdbcDriver)

When the driver is loaded into memory it registers itself with the javasqlDriverManager

class as an available database driver

The next step is to ask the DriverManager class to open a connection to a given database

where the database is specified by a specified formatted URL The method used to open

the connection is DriverManagergetConnection() It returns a class that implements the

javasqlConnection interface

Connection con =

DriverManagergetConnection(j dbcodbcsomedb

user passwd)

A JDBC URL identifies an individual database in a driver-specific manner Different

drivers may need different information in the URL to specify the host database

During the call to getConnection() the DriverManager object asks each registered driver

if it recognizes the URL If a driver says yes the driver manager uses that driver to create

the Connection object Here is an example

Example 441 A Part of Code of AuthorProcessjava

public void init() throws ServletException

try

ClassforNamesunj dbcodbcJdbcOdbcDriver)

con =

DriverManagergetConnection(j dbcodbcfxbookstore null

null)

catch (ClassNotFoundException e)

catch (SQLException e)

After we got the database connection we need to have some way to execute queries The

simplest way to execute a query is to use the javasqlStatement class Statement objects

are never instantiated directly instead a program calls the createStatement() method of

Connection to obtain a new Statement object

Statement stmt = concreateStatement()

34

A query that returns data can be executed using the executeQuery() method of Statement

This method executes the statement and returns a javasqlResultSet that encapsulates the

retrieved data

Example 442 A Part of Code of AuthorProcessjava

String sqlStmt =

if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where author= + name +II i n

else

sqlStmt = select from BOOK where author like +

name +

ResultSet rs = null

Statement stmt = concreateStatement()

rs = stmtexecuteQuery(sqlStmt)

35

A ResultSet object can be thought as a representation of the query result returned one row

at a time The next() method of ResultSet is used to move from row to row The

ResultSet interface also boasts a multitude of methods designed for retrieving data from

the current row The getStringO and getObject() methods can be used for retrieving

column values

Example 443 A Part of Code of AuthorProcessjava

while (rsnextO )

count++

outprintln(ltdtgtltbgt + count + )

String isbn = rsgetObject(ISBN)toString()

outprintln(lta href=servletDetailContent + isbn +

gt )

outprintln(rsgetObj ect(Title) toString() +

ltagtltbgt)

outprintln (ltnobrxfont color=990033gtUsually ships

in 24 hoursltBRgtltfontxnobrgt)

outprintln(ltddgt +

rsgetObj ect(Author) toString() )

36

outprintln( +

rs getOb j ect ( Publisher) toString () + +

rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

outprintln(ltbrgtltbrgt)

One of the outputs of servlet AuthorProcess is show in Figure 421 and Figure 441

Figure 441 One of The Outputs of Servlet AuthorProcess

37

File Edit View Favorites lo o k - Help M i

T 1 bdquo - 0 L Q 4 pound $ L L lBack r s Stop Refresh Home S earch Favorites History

A - Mail Print

Links rdquo Address | jyen j http7ocalhost808O$ervletAuthorProcess 3

Search B ooks

Home

CategoryA uthor

Title

ISBN

P u b l i sh e r D a te

Tiny Bookstore com

1 The C++ Prograitmuitg Language Usually ships in 24 hour Bjame Stroustrup Addison-Wesley Pub Co i 1997 Our Price 3147

T in yb o oks to re c om H ora e | Category | A uthor | Till | ISBN | Publisher P a t

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top of Page

gk j Local intranet

45 Session Tracking

Session Tracking is one of the most important techniques for any on-line store systems

This is because that HTTP protocol is a stateless protocol A HTTP server sees only a

series of requests and it by itself has no way to know exactly who is making the request

This means that when a customer puts a book in his shopping cart and then goes to other

pages to find more books next time when he puts another book in his shopping cart there

is no guarantee that he puts the book in the same cart It is very possible that he uses

another customerrsquos shopping cart at this time

38

To solve this problem session-tracking is introduced Traditional techniques used by

CGI include hidden form fields URL rewriting user authorization and persistent cookies

For server-side Java applications a built-in class supplied servlet can be used easily to

handle such tasks

When a user first accesses the site web server assigns a new HttpSession object and a

unique session ID to the user The session ID identifies the user and is used to match the

user with the HttpSession object in subsequent requests Usually the session ID is saved

on the client in a cookie or sent as part of a rewritten URL The Tiny Book Store uses this

technique

The Tiny Book Store is a classic shopping cart application A client can put items in his

virtual cart accumulating them until he checks out several page requests later How to

make sure a userrsquos shopping items will be put in his shopping cart or delete from his

shopping cart The Java Servlet API provide built in session tracking to handle this

problem Every user of a site is associated with a javaxservlethttpHttpSession object

that servlets can use to store or retrieve information about that user We can save any set

of arbitrary Java objects in a session object For example a userrsquos session object provides

a convenient location for a servlet to store the userrsquos shopping cart contents An example

shows below

Example 451 A Part of Code of AddToShoppingCartjava

39

1 Get current session object create one if necessary

2 HttpSession session = reqgetSession(true)

3 m_cart = (ShoppingCart)sessiongetValue(cart)

4 if (ra_cart == null) need new cart

5 create a shopping cart

6 m_cart = new ShoppingCart()

7 add to current session

8 sessionputValue(cart m_cart)

9

10

11 try

12 Statement stmt = m_concreateStatement()

13 ResultSet rs = stmtexecuteQuery(select from

book where ISBN= + isbn +)

14 if (rsnext())

15 book - new

BookDetails(rsgetObj ect(ISBN) toString()

16 rsgetObject(Title)toString()

rsgetObj ect(Authorrdquo) toString()

17 rsgetDouble(Price)

rsgetObj ect(PublicationDate) toString() )

18

40

1 9

2 0 catch (SQLException e)

21 e printStackTrace()

22

23 m_cartadd(bookgetlSBN() book)

The servlet uses its request objectrsquos getSession() method to retrieve the current

httpSession object

public HttpSession HttpServeltRequestgetSession (boolean create)

This method returns the current session associated with the user making the request If

the user has no current valid session this method creates one if create is true or return

null if create is false To ensure the session is properly maintained this method must be

called at least once before any output is written to the response Please look at the line 2

in the example 451

If you want to add data to an HttpSession object you can use the putValueQ method

public void HttpSessionputValue(String name Object value)

41

This method binds the specified object value under the specified name Any existing

binding with the same name is replaced This specifies at line 8 of the example 451

If you want to retrieve an object from a session you can use getValue() method

public Object HttpSessiongetValue(String name)

This method specified at line 3 of example 451 returns the object bound under the

specified name or null if there is no binding

From line 4 to line 9 the servlet checks whether the user already has a shopping cart If

the user didnrsquot have a shopping cart the servlet assigns a shopping cart to this user and

add the shopping cart to the current session to keep tracking The ShoppingCartjava class

is developed in this thesis writing code is provided in the appendix

From line 10 to line 21 the servlet knows the user already has a shopping cart m_con is

a data member of AddtoShoppingCart class Lines 12-13 have been discussed in the

previous section Lines 16-20 get some information of the book which the user selected

The information will be the data members of the ldquobookrdquo object that is an instance object

of BookDetailsjava class BookDetailsjava class is developed in this thesis writing the

source code is provided in the Appendix

Line 25 puts the book which is selected by the user into the shopping cart

42

Please see a set of pages are shown below

Figure 451 A Page Show All Information About A Book

TinjiRnfikStnre com - M inrnsnfl Interned Explnrpr

File Edit View Favorites Tools Help-

^ O 4 4 1 f i tStop Refresh Home I Search Favorites History Mail Print Edit

I Link gtgt Address [gl hgtplocalhos9l]IBrit-rvetDetailConetit-Ll20183l)544

S e a r c h B o o k s

Home-

C a t e g o r y

Author

Title

ISSNPublisher Pate

TinyBookStore com

The C++ Programming Languageby Bjarne Stroustrup

aISBN 0201889544 Addison-Wesley Pub Co 1997

Price 3147 Availability U sually ships within 24 hours

Add to cart

Done

R ev iew s

In tins brand-new third edition of The C + + Programming Language author Bjame Stroustrup the creator of C++ presents the full specification for the C++ language and standard library a spec that will soon become the joint ISOANSI C++ standard

g ig L o ca l in tranet

43

Figure 452 A Page Show Items In The Shopping Cart after A User Added Books To The Shopping Cart

H H I H I - I I

j File Edit View Favorites l o o k Help I f

| S ack Stop Refresh Home Search FavoritesJ V

History Wail Print

j Links Address |S1 http7localhost8O80servletAddToShoppingCart i i i i a i i i

( O ldquo ii

Shopping Cart Item s Price

An Introduction to fen e tic Algorithm sMelanie MteheU Quantity 1 Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

drle trgt

delete

delete

Price $ 2 2 0 Subtotal $ 2 2 0

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 6 7 5 6

|euro

rfuj Local intranet

44

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A Book From The Shopping Cart

^ A m a z o n c o m Shopping Cart - Microsoft Internet Explorer

- J A l 4Stop Refresh Home

gtH bdquo ] Back bdquo

httplocalhost8080servletDeleteFromShoppingCartitemgetltem()getlSBN()

Ji _J 3Search Favorites History

j - JMarl Print

~U ccdeg

Shopping Cart Item s

Core Java 2Cay S Horstrnaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d elete

delete

Price

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 4 5 5 6

rsquo0 1 Done gSsfLocat intranet

46 Check Out

This part is designed only using the HTML It collects all information from a user The

information will be written into the database

An important line in this HTML file is shown below

45

ltform method=POST

action=httplocalhost808 0servletCustomerlnfoProcessgt

This line will invoke the servlet CustomerlnfoProcess that will process all data collected

from the user This servlet will discuss in the next section The check out page shows in

Figure 461

Figure 461 A Check Out Page

M M iH M M M i M MmmrnfrnM File Edit View Favorites too ls Help

^ gt a 3 A hi -ltamp f V j HISllll mmB ack S lop R efresh H em e S earch 1 i l lie History M 1 Print Edit

^Links A ddrecs j ig ] h ltp localhostSO SO checkouth tm l i i i l a s

Custom er Information

First name (Fang

Middle initial |a

Last name [Xiao

Email address |fgtdaomitecnet

Account password Jxxxxx

C red it card num ber jl 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7

Credit card type ttV isa O BluebirdO MasterCard O Fisher

Credit card holder jFarig Xiao

Credit card expire date (tnmddyy) joi 0102 ~

Select shipping method t UPS 0 NormalO Express C Abnormal

| | ] Dorraquo raquo f j^ I o c a l intranet

47 Customer Information Processing

The customer information processing is handled by a servlet CustomerlnfoProces Its

source code is provided in the appendix

46

All information collected from the user should be written into the database therefore we

have to open a connection to a given database at first Example 461 is given for this

purpose

Example 471 A Part of Code of CustomerlnfoProcessjava

public void init() throws ServletException

try

ClassforName(sunjdbcodbcJdbcOdbcDriver)

m_con = riverManagergetConnection(jdbcodbcfxbookstore

null null)

catch (ClassNotFoundException e)

e printStackTrace()

catch (SQLException e)

e printStackTrace( )

There is a PO ST request in the check out page The servlet CustomerlnfoProcess will

handle the PO ST request by doPost function which is demonstrated in the following

example

47

Example 472 A Part of Source Code of CustomerlnfoProcessjava

public void doPost (HttpServletRequest req HttpServletResponse res)

throws ServletException IOException

ressetContentType(texthtml)

PrintWriter out = resgetWriter()

get information

String[] values = reqgetParameterValues(firstname)

if (values = null)

firstname = values[0]

values = reqgetParameterValues(middleinit)

if (values = null)

middleinit = values[0]

In the example the HttpServletRequest object res will get each data which was input by

the user by the getParameterValues() function

If the user is a returned user we donrsquot need open a new account again If the returned user

use the same credit card as previous we also donrsquot need to insert the credit card

48

information into the CREDITCARD table Otherwise we should insert all related

information into related table This is shown in the following example

Example 473 A Part of Source Code of CustomerlnfoProcessjava

Statement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where EmailAddress= +

email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext())

sql = insert into CUSTOMERACCOUNT (emailaddress password

firstname middleinit lastname) values ( + + email +

password + + firstname + + middleinit + lastname +

)

stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber= + creditcard

+

rs = stmtexecuteQuery (sql)

if (rsnext())

49

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype

HolderName ExpirationDate) values( + + creditcard + +

cardtype + + cardholder + 11 + expiredate + )

stmtexecute (sql)

All information related the books selected by the user can be obtained from the

shopping cart as shown in the following example

Example 474 A Part of Source Code of CustomerlnfoProcessjava

BookDetails book = null

ShoppingCartltern bookAndQuantity = null

Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getltems()

int aQuantity =0

String alSBN = null

while (itemshasMoreElements())

insert into Orderltems

bookAndQuantity = (ShoppingCartItem)itemsnextElement()

book = bookAndQuantitygetltem()

50

aQuantity = bookAndQuantitygetQuantity()

alSBN = book getISBN()

sql = insert into ORDERITEMS (shoppingCartID ISBN quantity)

values ( + + m_cartID + + aISBN + + aQuantity + )

stmtexecute (sql)

After all information inserted into related tables the servlet CustomerlnfoProcess will

produce invoice page The example page shows in Figure 471

51

Figure 471 An Invoice Page 3 Order List Microsoft Internet Explorer

is File Edit View Favorites Tools Help

J J J U r PS to p Refresh Hom e i -S earch Favorites History s Mai Print

Links Address iff 1 httpVlocalhostBOSOservletCustomerlnfoProcess 3

s5al Local intranet

Y ou r order reads as fo llow sE-MailAddress fiiiaomitecnet

ship to

Tel

Items

F ang Xiao12345 Western Plaza 23OmahaNE68154(402)123-4567

TitleCore Java 2Qtyl Price2579Subtotal2579

TitleJava Servlet PrograrnmingQtyl Price 1977 Sub total 1977 Total4556

i|51 D one

52

Chapter 5

Future Work

In this chapter we discuss two major problems for our future work They are the

Connection Pooling and Object-Oriented for better encapsulation

51 Connection Pooling

After we have used JDBC for a short time it will become evident that the major

performance bottleneck often comes right at the beginning when you are opening a

database connection This is because that opening a connection might involve a series of

low level communications between network protocols and database connection protocols

such as TCPIP ODBC etc

Servlet life cycle allows for extremely fast database access Servlet is loaded into Web

server only once Once it is loaded it can hold a connection to database all its life cycle

Every time it receives a request to read from or write data to database it can just use the

connection to do this

Here comes a problem however Suppose that a customer comes to the on-line store

During the period of selecting some items from the store he leaves his desktop and do

something else leaving this connection to database idling This will waste the precious

resource on the database From database port of view the connection to the database will

assign a space to hold corresponding status and to cache data For example Microsoft

SQL-Servertrade assigns about 36K bytes for each of its connection Resource on the

53

database is limited and idling connection causes such resource unable to be reused for

other users

To solve this problem we can use the technique called connection pooling Essentially a

connection pool is an object holding connections to backend database and managing the

number and status of connections For example if a connection in the pool idles over a

certain time of period the pool can terminate this connection if the requests are not the

same size of the connection pool the pool can dynamically shrink or expand the size of

itself A connection pool can run on a separate thread and is initialized when the server

starts or when a request to database is arrived

To implement a connection pool is pretty straight-forward Because of time constraint

however we did not do it in this paper and leave it as a possible future improvement

52 More Object-Oriented - Better Encapsulation

Another improvement might be done in the future is to create a HTML-related utility

class We have seen in this thesis that there are some duplicated code processing HTML

output such as ldquoout printIn ( lttbxtrgt lttrxtbgt)rdquo All these HTML-

related processes right now are used in a raw way That is they are not encapsulated A

better way to do this is to create a utility class or classes to deal with all HTML-related

processes and hide all HTML tags and format inside the class or classes For example

suppose that we create a Table class then we can use it in a way like

Table table = new Table()

54

table(somerow somecol contents)

table(somerow somecol some_image)

In this way we do not need to use HTML tags in our program and concentrate on the

programming logic The implementation is enriched with more object-oriented property

and therefore it is easy to maintain

55

Chapter 6

Conclusion

The increased awareness and popularity of the Internet make all kinds of electronic

commerce grow vigorously The most popular Web applications are the on-line stores

An on-line store system usually contains four components Web server business

procedure Database system application An on-line store system is different from web

publishing Currently there are three mainstream technologies which are widely used to

develop the on-line store systems CGI Microsoft ASP and Server-side Java application

Introducing the server-side Java application is one of the latest and most exciting trends

in Java programming We have discussed this technology in detail in this thesis The

server-side Java applications have many distinct advantages over CGI and other

technologies We present plenty of examples and figures to analysis the characteristics of

the server-side Java application

As a glance into the future electronic commerce will continue to grow driven by

purchases of home computers and other Web-enabled devices as well as new business

opportunities Electronic commerce is changing whole business procedures The future of

electronic commerce will be exciting and full of opportunities

56

APPENDIX A

Bibliography

57

[1] Karl Moss 1998 Java Servlets Mcgraw-Hill

[2] Jason Hunter William Crawford 1998 Java Servlet Programming O rsquoReilly

[3] Manoj Kumar Anand Rangachari Anant Jhingran Rakesh Mohan 1998 Sales Promitions on the Internet h ttpwwwibmcomiactech-paperhtml

[4] Manoj Kumar Stuart I Feldman 1998 Business Negotiations on the Internet httpwwwibmcomiactech-paperhtml

[5] Manoj Kumar Stuart I Feldman 1998 Internet Auction httpwwwibmcomiactech-paperhtml

[6] Shiwa Fu Jen-Yao Chung Walter Dietrich Vibby Gottemukkala Mitchell Cohen Shyhkwei Chen 1999 A Practical Approach to Web-Based Internet EDI httpwwwibmcomiacpapersicdcsws99indexhtml

[7] Zhong Tian Leo Y Liu Jing Li Jen-Yao Chung Vibby Guttemukkala 1999 Business-to-Business e-Commerce with Open Buying on the Internethttpw w w ibm comi acpapersobi -paperindex html

[8] Gerald J Tesauro Jeffrey O Kephart 1998 Foresight-Based Pricing Algorithms in an Economy os Software Agents http wwwi bm comi actech - paper html

[10] Jeffrey O Kephart James E Hanson Jakka Sairamesh 1998 Price and Niche Wars in a Free-Market Economy o f Software Agents httpwwwibmcomiactech-paperhtml

[11] Jeffrey O Kephart James E Hanson David W Levine Benjamin N Grosof Jakka Sairamesh Richard B Segal Steve R White 1998 Dynamics o f an Information-filtering Economy httpwwwibmcomiactech-paperhtml

[12] James E Hanson Jeffrey O Kephart 1998 Spontaneous Specialization in a Free-Market Economy os Agents httpwwwibmcomiactech-paperhtml

[13] Jakka Sairamesh Jeffrey O Kephart 1998 Price Dynamics o f Vertically differentiated Information Markets httpwwwibmcomiactech-paperhtml

[14] David Kosiur 1997 Understanding Electronic Commerce Microsoft Press

[15] Gunther Birznieks Selena Sol 1997 CGI fo r Commerce MampT Books - A Division of MIS Pres

58

[16] Ravi Kalakota Andrew B Whinston 1997 Electronic Commerce Addison Wesley

[17] Alex Fedorov Richard Harrison Dave Sussman Brian Francis Stephen Wood 1998 Profession Active Server Page 20 Wrox Press

[18] Calvin Austin Minica Pawlan 1999 Writing Advanced Application for the Java PlatformhttpVdeveloper iavasuncomdeveloperonlineTrainingProgrammin gJDCBooki ndexhtml

59

APPENDIX B

The Source Code of An On-Line Store System - Tiny Book Store

60

1 welcomeshtml

lthtmlgtltheadgtlttitlegtSearch Tinybookstorecomlttitlegtltheadgtltbodygt

lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=eeeeccgtlttrgtlttd rowspan=2 align=left valign=top width=15 cellspacing=0 cellpadding=0xIM G border=0 hspace=0 id=IMGl src=flowergif gtlttdgtlttd rowspan=2 align=left valign=centergtltstronggtlth2gtltigtTinyBookStorecomltigtlth2gtltstrongxtdgtlt trx tab legt

lttable border=0 width=100 cellspacing=0 cellpadding=0gtlttrgtlttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtltPgt

lttable width=100 cellspacing=0 cellpadding=5 border=0gtltTRgt ltTDgt ltTDgt ltTD colspan=2gt ltFONT FACE=verdanaarialhelvetica SIZE=-1 gtampnbsp ltFONTgt ltTDgt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD co lsp an = 2 x stro n g x fo n t face=verdanaarialhelvetica size=-lgtSearch B ooksltfontxstronggt ltTDgt ltTRgtltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt ltTD x f o n t face=verdanaarialhelvetica size=-l gt

lta href=w elcom eshtm lgtH om eltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt c T D x fo n t face=verdanaarialhelvetica size=-1 gt

lt A href= servletReqC ol 1 ec tc ategory gtC ate gory ltf o n tx A x T D gtltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollectauthorgtA uthorltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollecttitlengtTitleltorfo n tx A x T D gt ltTRgt

61

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectisbngtISBN ltA xfontxTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectpublisher_dategtPublisherD a telt A x fo n tx T D gtltTRgtlt tab lex p gtlttdgt

lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgtlttd valign=top align=leftgt

ltbr clear=allgtltPgtlt h 3 x s tro n g x fo n t color=ff6347gtWelcome to theltigt T in y B o o k S to rex o m lt ix fo n tx s tro n g x h 3 gt

ltbrgtlt s tro n g x b x h 3 x c e n te rgt F iv e Hot B o o k slt cen te rx h 3 x B x s tro n g gt

ltbrgtltservlet code=EchoServetTag myArgI=myValuel myArg2=myValue2gt ltparam name=myParm 1 value=Hellogtltparam name=myParml value=Worldgtltparam name=myParm2 value=myParmValue2gtltservletgt

lt td x trgt

lttablegt

ltTABLE width=100gtltTRgt ltTD width=50 valign=top align=Ieftgt ltTDgtltTD width=50 valign=top align=rightgtltfont size=-lgtltA href=topgtTop of P ag elt A x fo n tx T D gt ltTRgt

62

ltTABLEgt

ltcentergtltfont size=-lgtltA href=indexhtml gtTinybookstorecom HomeltAgt ampnbsplampnbsp ltA href=categoryhtml gtCategoryltAgt ampnbsplampnbspltA href= author html gtAuthorltAgt ampnbsplampnbspltA href= title html gtTitleltAgt ampnbsplampnbspltA href=7isbnhtml gtISBNltAgt ampnbsplampnbspltA href=publisherhtmrgtPublisher DateltAgtltpgtltfontgtltcentergt

ltPgtltcentergtlt b rx fo n t size=-lgtltA href=copyrighthtml gtCopyright and disclaimerltAgt copy 1999-2001 Fang Xiao ltfontgtltcentergt

ltbodygtlthtmlgt

63

2 AddToShoppingCartjava

ltpgt AddToShoppingCart is the servlet that process the action of adding item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javasql import javautil import javaxservlet import javaxservlethttp

public class AddToShoppingCart extends HttpServlet

protected Connection m_con = null protected ShoppingCart m_cart protected BookDetails book

public void initQ throws ServletException try

Class forName( sunj dbc odbc JdbcOdbcDriver)m_con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintstackTrace ()catch (SQLException e)

e prints tackT race ()

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

String[] params = reqgetParameterValues(isbn)

64

String isbn = get isbn from extra path infomationif (params = null)

isbn = params [0]

Get current session object create one if necessary HttpSession session = reqgetSession(true) m_cart = (ShoppingCart)sessiongetValue(cart)

if (m_cart == null) need new cart create a shopping cart m_cart = new ShoppingCart() add to current session sessionputValue(cart m_cart)

try Statement stmt = m_concreateStatement()ResultSet rs = stmtexecuteQuery(select from book where

ISBN=rsquo + isbn + rsquo)

if (rsnext()) book = new BookDetails(rsgetObject(ISBN)toString()

rsgetObject(TitIe)toStringOrsgetObject( Author) toStringO

rsgetDouble( Price) rs getObj ect( PublicationDate) toStringO)

catch (SQLException e)

eprintStackTrace()m_cartadd(bookgetISBN() book)

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lt h tm lxheadx titlegt T inyB ookS tore com S hopping

Cartlttitlexheadgt)outprintln(ltbody bgcolor=FFFFFF lmk=003399

alink=FF9933 vlink=996633 text=000000ngt)outprintln(lta nam e= topxmdashTop of Pagemdashx a gt )

65

outprin tln(ltpxa href=httplocalhost8080checkouthtmlximg src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=cccc99 gt)ou tp rin tln (lt tdxbrx tdgt )ou tp rin tln (lt tdxbrx tdgt )o u tp rin tln (lt tdxbrx tdgt )outprintln(lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=2xfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=left valign=topxfont

face=verdanaaria lhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=cccc99gt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lt td x b rx td gt ) outprintln(lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantityQ

outprintln(lttr bgcolor=FFFFFFgt) ou tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt )outprintln(ltbrgt + item getltem() get Author()) outprintln(ltbrgtQuantity + itemgetQuantityO) outprintln( ltbrgt) outprintln(lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=POST

action=7servletDeleteFromShoppingCartitemgetItem()getISBN()gt)

66

outprintln(ltpgt cinput type=hidden name=isbn value= + itemgetItem()getISBN())

outprintln(ltpgt ltinput type=submit name=ditemvalue=deletegt)

outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelve tica color=000000gt)

outprintln(ltNOBRgtltbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fon tx bx N O B R gt ltbrgt )

outprintln(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantity() + lt fo n tx b x N O B R x b rgt )

outprintln(ltfontgt) out println( lttdgt)

out printl n( lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)out println( lt fo n tx fo n tgt )outprintln(lttdxtrgt)outprintln(lttablegt)outprin tln(ltpxa href=httplocalhost8080checkouthtmlYximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)outprintln(ltbodygt lthtmlgt)

outflush()outclose()

67

3 AuthorProcessjava

bull ltpgt AuthorProcessbull This is the servlet that process the Author-search request and generatebull search resultbull Author Fang Xiao Purpose Thesis project Copyrightcopy Fang Xiao 1999-2001

import javaxservlet import jav ax servlet http import javaio import javasql

public class AuthorProcess extends HttpServlet protected final String EXACT = ldquoexactrdquo protected final String OTHERS = ldquolastrdquo

protected Connection con = null

public void init() throws ServletException try

ClassforName(ldquosunjdbcodbcJdbcOdbcDriverrdquo)con = DriverManagergetConnection(ldquojdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(ldquotexthtmlrdquo)PrintWriter out = resgetWriterQ

68

String[] valuesString name =

values = reqgetParameterValues(ldquoauthorrdquo) if (values = null)

name = values [0]

String mode = ldquordquovalues = reqgetParameterValues(ldquoauthor_moderdquo) if (values = null)

mode = values [0]

String sqlStmt = ldquordquo if (modeequalsIgnoreCase(EXACT))

sqlStmt = ldquoselect from BOOK where author=rsquordquo + name +else

sqlStmt = ldquoselect from BOOK where author like lsquordquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

ldquoYour Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ldquoltdlgtrdquo) 11 start Glossary List

while (rsnext()) count++outprintln(ldquolt d tx b gt rdquo + count + ldquo ldquo)String isbn = rsgetObject(ldquoISBNrdquo)toString()

69

outprintln(ldquolta href=servletDetailContentrdquo + isbn+

outprintln(rsgetObject(ldquoTitlerdquo)toString() +ldquolt a x b gt rdquo)

outprintln(ldquolt n o b rx fo n t color=990033gtUsually ships in 24 h o u rslt B R x fo n tx n o b rgt rdquo)

outprintln(ldquoltddgtrdquo +rsgetObject(ldquoAuthorrdquo)toString())

outprintln(ldquo ldquo +rsgetObject(ldquoPublisherrdquo)toString() + ldquo ldquo + rsgetObject(ldquoPublicationDaterdquo)toString())

outprintln(ldquoltbrgt Our Price ldquo +rsgetObject(ldquoPrice)toString())

outprintln(ldquolt b rx b rgt rdquo)

if (count == 0) outprintln(ldquoltdtgt No matched data foundrdquo)

outprintln(ldquoltdlgtrdquo) end Glossary List

catch (SQLException e) create footer here outprintln(ldquolttdgt lttrgtrdquo) outprintln(ldquolttablegtrdquo)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(ldquolthtmlgtrdquo) outprintln(ldquoltheadgtrdquo) outprintln(ldquolttitlegt TinyBookStorecom lttitlegtrdquo) outprintln(ldquoltheadgtrdquo)

outprintln(ldquoltbodygtrdquo)

70

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspacing=0 cellpadding=0 bgcolor=rdquoEEEECCYrsquogtrdquo)

outprintln(ldquolttrgtrdquo)outprintln(ldquolttd align=left valign=top width=90 gtrdquo) outprintln(ldquoltIMG border=0 hspace=0 id=IMGl

src=rdquodJavaWebServer20public_htmlflowergifrdquogtlttdgtrdquo) outprintln (ldquolttd width=30gtlttdgtrsquorsquo) outprintln(ldquolttd align=left valign=center width=300gtrdquo)

outprintln(ldquolt stro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x s tro n g x td gt rdquo) outprintln(ldquolttd align=right valign=centergtrdquo) outprintln(ldquolttdgtrdquo) outprintln(ldquolttd w id th= 20x tdgt rdquo) out pri ntln (ldquolttrgtrsquo rsquo) outprintln(ldquolttablegtrdquo)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ldquolttable width= 100gtrdquo)outprintln(ldquolttrgt lttd width=50 valign=top align=leftgt lttdgtrdquo) outprintln(ldquolttd width=50 valign=top align=rightgtrdquo) outprintln(ldquoltfont s iz e = - lx a href=rdquotoprdquogtTop of P agelt ax fon tgt rdquo) outprintln(ldquolttrgtrdquo) outprintln(ldquolttablegtrdquo)

outprintln(ldquoltcentergtrdquo) outprintln(ldquoltfont size=-lgtrdquo) outprintln(ldquolta

href=rdquohttplocalhost 8080welcomeshtmlrdquogtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080$ervletReqCollectcategoryrdquogtCategoryltagtampnbsplampnbsprdquo)

outprintln(ldquoltahref=Yhttplocalhost8080servletReqCollectauthorrdquogtAuthorltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_daterdquogtPublisheramp44Dateltagtrdquo)

outprintln(ldquoltpgtrdquo)

71

outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltpgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquolt b rx fo n t size=-lgtrdquo)outprintln(ldquoltA href=Y7copyrighthtmlrdquogtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiaordquo)outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltbodygtrdquo) outprintln(ldquolthtmlgtrdquo)

i

protected void CreateLeftMenu(PrintWriter out) System out println(ldquoLeftMenurdquo)

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspaeing=0 cellpadding=0gtrdquo)

outprintln(ldquolttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtrdquo)

outprintln(ldquoltpgtrdquo)

outprintln(ldquolttable width=rdquo 100rdquo cellspaeing=0 cellpadding=5border=0gtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquoltfont face=verdanaarialhelvetica SIZE=rdquo- l rdquogtampnbsp

ltfontgtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquolt strongxfon t face=verdanaarialhelvetica size=rdquo-

1 rdquogtSearch B ooksltfontxstronggtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd ldquo) outprintln(ldquoltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080welcomeshtmlYgt H o m elt fo n tx ax td gt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=rdquo-1rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080servletReqColIectcategoryrdquogt C ateg o ry lt fo n tx ax td gtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

72

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectauthorrdquogtAuthorltfontgtltagtlttdgtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width-2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l W rsquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltfontgtltagtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo-lYgtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_dateVrsquogtPublisher Dateltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolt tab lex p gt rdquo)

outprintln(lsquolsquolttdgtrdquo)outprintln(ldquolttd rowspan=4 width=5gtampnbspampnbspltbrgtlttdgtrdquo) outprintln(ldquolttd valign=top align=leftgtrdquo) outprintln(ldquoltbr clear=allgtrdquo)

73

4 BookTeatailsjava

ltpgt This is the class describing a book item in shopping cart

Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class BookDetails private String m_isbn = null private String m_title = null private String m_author = null private double m_price = 00 private String m_year = null

public BookDetails(String isbn String title String author double price String year)

thism_isbn = isbn thism_title = title thism_author = author thism_price = price thism_year = year

public String getISBN() return m_isbn

public String getTitle() return m_title

public String getAuthor() return m_author

public double getPrice() return m_price

ipublic String getYearQ

return m_year

75

5 CategoryProcessjava

ltpgt CategoryProcess This is the servlet that process the Category-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql import javautil

public class CategoryProcess extends FlttpServlet protected final String EXACT = exactprotected final String OTF1ERS = last

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

76

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentType( texthtml)Print Writer out = resgetWriterQ

String[] values String name = String sqlStmt =

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

else

path = pathsubstring(l) if (pathequalsIgnoreCase(cO 1))

sqlStmt = select from BOOK wherecategoryid=rsquo + cOl +

else if (pathequalsIgnoreCase(c02))sqlStmt = select from BOOK where

categoryid=rsquo + c02 +else if (pathequalsIgnoreCase(c03))

sqlStmt = select from BOOK wherecategoryid=rsquo + c03 +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftM enu(out)

Your Book Search Results try

77

if (con = null) Statement stmt = concreateStatement() rs = stmt executeQuery (sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn

+outprintln(rsgetObject(Title)toString() +

lt ax bgt )outprintln(ltnobrxfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltddgt +

rsgetObject( Author)toStringO)outprintln( +

rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)outprintln(ltbrgt Our Price +

rsgetObject( Price) toStringO) ltfont color=990000gtYou Save $1100

(20)ltfontgtoutprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

78

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)out println( lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20publicbdquohtmlflowergifgtlttdgt) outprintln(lttd width=3 0gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln( lt s tro n g x h 2 x igt T inyB ookS to re com lt ix h2x s tro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlngtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

79

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYrsquogtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln( ltfontgt)outprintln(ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rOwspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt)

outprintln(lttablewidth= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=Y2Ygt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y-1 Yrsquogtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2Yrsquogt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=Y-

lYrsquogtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=Y-lYgt)

80

outprintln(ltahref=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqColIectcategorygtCategoryltfontxagtlttdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(nltahref=httplocalhost8080servletReqCollectauthorVrsquogt A u th o rlt fo n tx ax td gtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httpIocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

6 CustomerlnfoProcessjava

ltpgt CustomerlnfoProcessThis servlet is responsible to process userrsquos information when heshe check out

Author Fang Xiao

Purpose Thesis projectCopyright (C) Fang Xiao 1999-2001

import javasql import javaio import j avau til import javaxservlet import javaxservlethttp

public class CustomerlnfoProcess extends HttpServlet protected Connection m_con = null protected HttpSession m_session = null protected static int m_cartID = 1 protected String firstname =protected String middleinit =protected String lastname =protected String email =protected String password =protected String creditcard =protected String cardtype =protected String cardholder =protected String expiredate =protected String shipping =protected String receiver =protected String address =protected String city =protected String state =protected String zipcode =protected String phone =

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)

82

m_con = DriverManagergetConnection(jdbcodbcfxbookstorenull null)

catch (ClassNotFoundException e)

eprintStackTrace()catch (SQLException e)

eprintStackTrace()i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

get informationString[] values = reqgetParameterValues(firstname) if (values = null)

firstname = values [0]

values = reqgetParameterValues(middleinit) if (values = null)

middleinit = values [0]

values = reqgetParameterValues(lastnameM) if (values = null)

lastname = values [0]

values = reqgetParameterValues(email) if (values = null)

email = values [0]

values = reqgetParameterValues(password) if (values = null)

password = values [0]

values = reqgetParameterValues(creditcard)

if (values = null) (creditcard = values [0]

values = reqgetParameterValues(cardtype) if (values = null)

cardtype = values [0]

values = reqgetParameterValues(cardholder) if (values = null) (

cardholder = values [0]

values = reqgetParameterValues(expiredate) if (values 1= null)

expiredate = values [0]

values = reqgetParameterValues(shippingrdquo) if (values = null)

shipping = values [0]

values = reqgetParameter Values (receiver) if (values = null)

receiver = values [0]

values = reqgetParameterValues(address) if (values = null)

address = values [0]

values = reqgetParameterValues(city) if (values = null) (

city = values [0])

values = reqgetParameterValues(state) if (values = null) (

state = values [0]

84

values = reqgetParameterValues(zipcode) if (values = null) (

zipcode = values [0]

values = reqgetParameterValues(phone) if (values = null)

phone = values[0]i

get session object m_session = reqgetSessionQ

try update databaseStatement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where Email Address=rsquo + email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext()) Systemoutprintln(insert customeraccount)

sql = insert into CUSTOMERACCOUNT (emailaddress password firstname middleinit lastname) values ( +

+ email + + password + + firstname +V + middleinit + + lastname + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber=rsquo +creditcard +

rs = stmtexecuteQuery (sql)

if (rsnext()) Systemoutprintln(insert creditcart)

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype HolderName ExpirationDate) values( +

+ creditcard + + cardtype + +cardholder + + expiredate + rdquo)

Systemoutprintln(sql)stmtexecute (sql)

i

85

sql = insert into SHOPPINGCART (ShoppingCartIDEmail Address CreditCardNumber ShippingType ReceiverName ReceiverAddress ReceiverCity ReceiverState ReceiverZipcode ReceiverPhone) values ( + m_cartID + V + email + Vrdquo +

creditcard + V + shipping + + receiver ++ address + V +

city + V + state + V + zipcode + V + phone +gt gt

Systemoutprintln(sql)stmtexecute (sql)

BookDetails book = nullShoppingCartltem bookAndQuantity = null Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

int aQuantity =0 String alSBN = null

while (itemshasMoreElementsO) insert into Orderltems bookAndQuantity =

(ShoppingCartItem)itemsnextElement()book = bookAndQuantitygetItem()

aQuantity = bookAndQuantitygetQuantity() alSBN - book getISBN()

Systemoutprintln(insert Orderltems)sql = insert into ORDERITEMS (shoppingCartED ISBN

quantity) values ( + m_cartID + +alSBN + + aQuantity + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

im_cartID++ must increase by one

86

catch (SQLException e) eprintS tackTrace()

printOrder(out)

public void printOrder(PrintWriter out) outprintln( lthtmlgt ltheadgt lttitlegt Order List lttitlegt ltheadgt) outprintln( ltbodygt)outprintln(lthlgt Your order reads as follows lthlgt)outprintln(lttablegt)outprintln( lttrgt)outprintln( lttdgtE-Mail Addres s lttdgt) outprintln(lttdgt+ em ail+lttdxtrgt) outprintln(lttrgt) outprintln(lttdgtship tolttdgt) outprintln(lttdgt+ receiver +ltbrgt) outprintln(address +ltbrgt) outprintln(city +ltbrgt) outprintln(state +ltbrgt) outprintln(zipcode + lt b rx td x trgt ) outprintln(lttrgt) outprintln( lttdgtTel lttdgt) outprintln(lttdgt+ phone +lttdxtrgt) outprintln(lttrgt) outprintln( lttdgtItems lttdgt)

BookDetails book = nullShoppingCartltem bookAndQuantity = nullEnumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

double total = 00

while (itemshasMoreElements()) bookAndQuantity = (ShoppingCartItem)itemsnextElement()

total += bookAndQuantitygetItem()getPrice() bookAndQuantitygetQuantityO

book = bookAndQuantitygetltem()

87

outprintln(lttdgtTitle+ bookgetTitle() + Qty + bookAndQuantitygetQuantity() + ltbrgt)

outprintln(Price + bookgetPrice() + Subtotal + bookAndQuantitygetQuantityO bookgetPrice() +ltbrgt)

outprintln(Total + total )outprintln(lttdxtrgt)outprintln(lttablegt)outflush()outclose()

7 DeleteFromShoppingCartjava

ltpgt DeleteFromShoppingCart is the servlet that process the action of deleting item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javautil import javaxservlet imp ort j avax servlet http

public class DeleteFromShoppingCart extends HttpServlet

protected ShoppingCart m_cart protected BookDetails book

public void doPost(HttpServletRequest req FIttpServletResponse res) throws ServletException IOException res setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String[] params = reqgetParameterValues(isbnrsquo) String isbn = get isbn hidden fieldif (params = null)

isbn = params [0]

Systemoutprintlnfisbn = + isbn)

Get current session objectHttpSession session = reqgetSession()m_cart = (ShoppingCart)sessiongetValue(carf)

m_cartremove(isbn)

89

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lthtm lgtltheadxtitlegtAm azoncom Shopping

C artlt titlexheadgt)out pri ntln ( ltb ody bgcolor=FFFFFF link=003399

alink=FF9933 vlink=Yrsquo996633Y text=rdquo000000rdquogtrdquo)outprintln(lta nam e= top xmdashTop of Pagemdashx a gt ) ou tp rin tln (lt pxa href=httplocalhost8080checkouthtmlximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=Yrsquocccc99Yrsquo gt)ou tp rin tln (lt tdxbrx tdgt )out pri ntln ( lt td x b r x td gt )outprintln( lt td x b r x td gt )out println (rsquo1 lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=Y2Yxfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=YleftY valign=YtopYxfont

face=verdanaarialhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=Ycccc99Yrsquogt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantity()

outprintln(lttr bgcolor=FFFFFFgt) o u tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt)outprintln(ltbrgt + itemgetItem()getAuthor())

90

outprintln(ltbrgtQuantity + itemgetQuantityO)outprintln(ltbrgt)outprintln( lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=VPOST

action=7servletDeleteFromShoppingCartVgt)outprintln(ltpgt ltinput type=hidden name=isbn value= +

itemgetItem()getISBN())outprintln(ltpgt cinput type=submit name=ditem

value=Y rsquo deletegt rsquo rsquo)outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelvetica color=000000gt)

outprintln(ltNOBRxbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fo n tx b x N O B R x b rgt )

outprintin(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantityO + lt fo n tx b x N O B R x b rgt )

outprintln( ltfontgt) outprintln( lttdgt)

i

outprintln(lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)outprintln(ltfontxfontgt)outprintln( lt td x trgt ) outprintln(lttablegt)ou tp rin tln (lt pxa href=Yhttplocalhost8080checkouthtmlYximg

src=YdYJavaWebServer20servletsimageproceed-to-checkoutgifYxagt)outprintln(ltbodygt lthtmlgt)

outflushOoutcloseQ

91

8 Detailcontentjava

ltpgt DetailContent is the servlet responsible for generating detailed information page for a book The book is identified by its ISBN Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaio import javasql import jav ax servlet import javaxservlethttp

public class DetailContent extends FIttpServlet protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String isbn = reqgetPathInfo()isbn = isbnsubstring(l) skip over rsquo rsquo

92

try String sql = select from book where ISBN=rsquo + isbn +

Statement stmt = concreateStatement()ResultSet rs = stmtexecuteQuery(sql)

create header here CreateHeader(out)

create left menu here CreateLeftMenu(out)

outprintlnfctd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintlnfctd valign=top align=leftgt)

cellpadding=0gt)

outprintln(ltbrgt)

create detailcontent here while (rsnext())

String strlSBN = rsgetObject(ISBN)toString() outprintln(lttable width=100 border=0 cellspacing=0

+ltbgtlttdxtrgt)

+ lt tdx trgt)

outprintln(lttrgt lttd colspan=3 align=leftxbgt) outprintln( rsgetObject(Title)toString()

outprin tln(lt trxtd colspan=3 align= leftxbgt by ltbgt) out println( rs getObj ec t( Author) toS tringQ

cellpadding=0gt)

outprin tln(lt trx td x i m g src=xtdgt) outprintln( lttd valign=topgt) outprintln( lttable border=0 cellspacing=0

outprintln( lt t r x td valign=topxbgtPrice )outprintln(

rsgetObject(Price)toString() + lt b x td x trgt ) outprintln(

lt trx td x b gt A v ailab ility lt b gt U su a lly lt td x trx b rgt )outprintln( lt t r x td vlign=topgtships within 24

hou rs lt td x trgt )outprintln( lt tab lextdgt)

93

outprintln( lttd align=rightgt) outprintln( lttable border=0 cellspacing=0

cellpadding=0gt)outprintln( lt trx td gt )outprintln( ltform

method=POST action=httplocalhost8080servletAddToShoppingCartgt)outprintln( ltinput

type=hidden name=isbn value= + strlSBN +outprintln( cinput

type=submit value=Add to cart )outprintln( lt tdx trgt )

outprintln( lt tab lex tdgt ) outprintln(rdquolttrgt)outprintln(lttrgt lttd clospan=3 align=leftgt ISBN ) outprintln( strlSBN +lttdxtrgt)outprintln(lttrgt lttd clospan=3 align=leftgt) outprintln( rsgetObject(Publisher)toString()

+rsgetObject(PublicationDate)toString() + lt tdx trgt )outprintln(lttablegt)outprintln(ltbrgt)outprintln(ltbrgt)

output reviewString review = rsgetObject(BookReview)toString() if (review = null)

review =DJavaWebServer20servletsreview + review

outprintln(ltbgtReviewsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(review))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprin tin (thisLine) ou t println( ltpgt)

)

icatch (IOException e)

need do something here eprintstackTrace ()

94

outprintln(ltbrgt)String comment =

rsgetObject(BookComment)toString()if (comment = null) comment = DJavaWebServer20servletscomment +

commentoutprintln(ltbgtReader Commentsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(comment))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprintln(thisLine) outprintln(ltpgt)

catch (IOException e)

need do something here eprintstackTrace ()

ou t pri ntln ( ltb rgt)

catch (SQLException e)

need to do something here

add table end tab outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt)

95

ou t pri ntln ( lthe adgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=YTOO cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d J avaW eb S erver 2 Opublic_htmlflo wer gif gtlttdgt) outprintln(lttd width=30gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyBookStorecomltigtlth2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln( lttd width=20gtlttdgt) out pri ntln ( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-1 gt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

96

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsptampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out prin tin ( ltcen tergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

eellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=Yhttplocalhost8080Avelcom eshtm lgtHom eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-1gt)

97

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=http7localhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref-httpIocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lVgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

98

9 EchoServlettagjava

import javaio import j avasql import javaxservlet import javaxservlethttp

public class EchoServletTag extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintStackTrace ()catch (SQLException e)

eprintStackTrace()

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

try Statement stmt = concreateStatementQResultSet rs = stmtexecuteQuery(select from book where title

like rsquoProgrammingrsquo)int count = 1outprintln(ltdlgt)while (rsnext() ampamp count lt 6)

outprintln(ltdtxbgt + count + )

99

String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn + outprintln(rsgetObject(Title)toString() + lt ax bgt ) outprintln(ltddxnobrgtltfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltbrgt + rs getObject( Author) toStringO) outprintln( + rsgetObject(Publisher)toStringO +

+ rsgetObject(PublicationDate)toStringO)outprintIn(ltbrgt Our Price +

rsgetObject(Price)-toStringO)

out println( lt b rx b rgt ) count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()outprintln(lttdgt lttrgt) outprintln(lttablegt) outflush() outcloseO

ii

100

10 ISBNProcessjava

ltpgt ISBNProcess This is the servlet that process the ISBN-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javax servlet import javaxservlethttp import javaio import j a vasql

public class ISBNProcess extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forN ame( sun j dbc odbc J dbcOdbcDri ver)con = DriverManagergetConnection(j dbc odbc fxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s s e tC on te n tTy pe ( tex th tm l)PrintWriter out = resgetWriter()

String[] values

String alSBN =

values = reqgetParameterValues(isbn) if (values = null)

alSBN = values [0]

String sqlStmt = select from BOOK where ISBN= + alSBN

ResultSet rs = null int count = 0

create header here bullCreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject( IS BN) toStringO

outprintln(lta href=servletDetailContent + isbn+ gt)

outprintln(rsgetObject(Title)toStringO +lt ax bgt )

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toStringO)

outprintln( +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

102

outprintln(ltbrgt Our Price +rsgetObject(rdquoPrice) toStringO)

outprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width= 100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d Uava WebS erver2 Opubhc_htmlflo wer gif gtlttdgt) outprintln(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS tore com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt)

103

out println( lttdgt) outprintln(lttd w id th= 20x tdgt ) out pri ntln( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)out pri ntln (lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) out pri ntln ( lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsp1ampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out println( ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

104

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 eellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Books lt fontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocaihost8080servletReqCollectcategorygtCategoryltfontxaxtdgt lttr gt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

105

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lttablegtltpgt)

o u t println( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

ii

106

11 PublisherDataProcessjava

ltpgt AuthorProcess This is the servlet that process the PublisherampDate-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql

public class PublisherDateProcess extends FIttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbc odbc JdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentT ype ( texthtml)PrintWriter out = resgetWriterQ

String[] valuesString namel =

107

values = reqgetParameterValues(publisher) if (values = null)

nam el = values [0]

String name2 =values = reqgetParameterValues(rdquopublication_date) if (values = null)

name2 = values [0]

String sqlStmt =sqlStmt = select from BOOK where publisher=rsquo + namel + rsquoand

publicationdate=rsquo +name2

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprin tln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toStringO outprintln(lta href=servletDetailContent + isbn

+ gt)outprintln(rsgetObject(Title)toString() + (

lt ax bgt )

108

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rs getObj ect( Author) toS tring())

outprintln(V +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

outprintln(ltbrgt Our Price +rsgetObject( Price) toStringO)

outprintln( lt b rx b rgt )

if (count == 0) (outprintln(ltdtgt No matched data found)

outprintln(rdquoltdlgt) end Glossary List

catch (SQLException e) ( create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 celipadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt)

109

outprintln(ltIMG border=0 hspace=0 id=IM Gl src=dJavaW ebServer20public_htmlflowergifxtdgt)

outprintln(lttd width=3 0 x td gt ) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS to re com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ctable w idths 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt) outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) ou t println( ltcentergt)

no

outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaim er^A gt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) out pri ntln ( lthtml gt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-1 gtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=V-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-1gt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

I l l

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitleYrsquogt T itle lt fo n tx a x td gt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(nltahref=Yhttplocalhost8080servletReqCollectisbnY gtISBNltaxfontxtdgt lttrgt)

outprindn(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdana arial helvetica size=Y -1 gt)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYgtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

1 12

12 ReqCollectjava

ltpgt This is a servlet responsible for generating search request collection page It read extra path information from URL and then according to the extra path information it generates corresponding page format Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001import javaxservlet import javaxservlethttp import javautil import javaio

public class ReqCollect extends HttpServlet

protected final String CATEGORY = categoryrdquo protected final String AUTHOR = author protected final String TITLE = titlerdquo protected final String ISBN = isbnprotected final String PUBLISHER_DATE = publisher_date

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentType( texthtml)PrintWriter out = resgetWriter()

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

)else

Create standard header CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

path = pathsubstring(l) if (pathequalsIgnoreCase(CATEGORY))

I I Create category request collect

outprintln(ltpgt)outprintln(lth3xstronggtProgrammingltstronggtlth3gt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc01gtAlgorithmsltagt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc02gtCampC++ltagt)outprintln( Delphi) outprintln(lta

href=httplocalhost8080servletCategoryProcessc03gtJavaltagt)outprintln( MFC Perl)

outprintln(software Design UML Visual Basic More)

outprintln(lth3xstronggtW eb Developm entltstrongxh3gt) outprintln(ASP Commercem Cyberculture HTML

JavaScript)

outprintln(Security Web Design XML more)

outprintln(lth3xstronggtGraphics amp Softwareltstrongxh3gt) outprintln(Asobe CAD Desktop Publishing Graphics)

outprintln(Microsoft More)

outprintln(lth3xstronggtNetW orking amp O Sltstrongxh3gt) outprintln(Linux Macs Oracle PCs SAp R3 SQL)

outprintln(TCPIP Unix WindowsampDOS W indowsNT)

out println( More)

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

1 14

outprintln(ltfont color-CC6600 face=verdana arial helvetic a size=+1 gtltbgtEnter Authorltbgtltfontgt)

outprintln(ltbrgt You can enter authorrsquos full name firstname or last nameltpgt)

outprintln(ltform method=POST action=httplocalhost 8080servletAuthorProcessY id=form 1 name=form 1 gt)

outprintln( lttable border=0gt) outprintln(lttrgt lttd valign=middle

ahgn= leftx ttx b gt A u th o rlt b gt lt ttx td gt )outprintln(lttd valign=middle align= leftx input

type=YtextY name=author size=40 value=YYxtdgt)outprintln(lttrgt)outprintln(lttrgt lttd colspan=2gt ltfont size=-lgt) outprintln(ltcentergt ltinput type=radio

name=Yauthor_modeY value=YexactY checkedgt Exact Name)outprintln(ltinput type=radio name=author_mode

value=lastgtLast First Name (or Initial))outprintln(ltcentergt) outprintln(ltfontgt) outprintln(lttdgt lttrgt)outprintln(lttrgt lttd colspan=2gt ltpgt ltbrgt lttdgt lttrgt)outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search NowY

id=submitl name=submitlgt)outprintln(cinput type=reset value=YClear Form

id=resetl nam e= rese tlxpgt )outprintln(ltcentergt ltformgt)

else if (pathequalsIgnoreCase(TITLE))

Create title request collect

outprintln(ltfont color=CC6600 face=verdanaarialhelvetica s ize= + lxbgt E n ter T itlelt bxfontgt)lsquo

outprintln(ltbrgtYou can enter the exact title or part oftitleltPgt)

outprintln(ltform method=YPOSTY action=Yhttplocalhost8080servletTitleProcessY id=form l name=formlgt)

outprintln(lttable border=0gt) outprintln(lt trxtd valign=middle

a lig n = le ftx ttx b gt T itle lt b x t tx td gt )

115

outprintln(lttd valign=middle align= leftx input type=text name=title size=40 value=xtdgt)

outprintln(lttrgt) outprintln(lttrgt) outprintln( lttd colspan=2gt) outprintln( ltfont size=-lgt) outprintln( ltcentergt)outprintln( ltinput type=radio name=title-mode

outprintln(value=exact checkedgt) outprintln( Exact Title)outprintln( ltinput type=radio name=title-mode

outprintln( value=titlewords gt ) outprintln( Title Words )outprintln(ltcentergt ltfontgt lttdgt lttrgt)outprin tln(lt trxtd c o ls p a n = 2 x p x b r x td x tr gt ) outprintln(lttablegt)

outprintln(ltcentergt)outprintln( ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln( ltinput type=reset value=Clear Form

id=resetl nam e= resetlxP gt )outprintln(ltcentergt) ou t println ( ltformgt)

outprintln(lthr noshade size=lgt)

outprintln(ltBgtExamplesltBgt)outprintln(ltULgt)outprintln(ltLIgtEntering ltbgtampquotJava Servlet

Programmingampquotltbgt in the title field )outprintln(and choosing ltemgtExact Titleltemgt finds the

book without also finding the many books)

outprintln(ltLIgtEntering ltbgtampquotJavaampquotltbgt in the Title field and choosing ltemgtTitle Wordsltemgt)

outprintln( finds all books whose title are related toltigtJavaltigt)

outprintln(ltULgt)

out printl n( lttdgtlttrgt) outprintln(lttablegt)

ielse if (pathequalsIgnoreCase(ISBN))

Create isbn request collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n ter ISBN ltbxfontgt)outprintln(ltbrgt) outprintln(ltform method=POSTY

action=httplocalhost8080servletISBNProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

a lig n = le ftx ttx b gt IS B N lt b x t tx td gt ) outprintln(lttd valign=middle a lign= leftx input

type=text name=isbn size=40 value=xtdgt)outprintln(lttrgt)

outprin tln(lt trxtd c o ls p a n = 2 x p x b rx td x trgt ) outprintln(lttablegt)

out println( ltcentergt)outprintln(ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln(ltinput type=reset value=Clear

FormV id=resetl nam e= resetlxP gt )outprintln(ltcentergt)outprintln(ltformgt)

outprintln(lthr noshade size=lgt)

outpiintln(ltULgtrdquo)outprintln(lttdxtrgt)outprintln(lttablegt)

else if (pathequalsIgnoreCase(PUBLISHER_DATE))

Create publisher date collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n te r Publisher and Publication D ate ltb gtltfontgt)

1 17

outprintln( ltbrgt) outprintln(ltform method=POST

action=httplocalhost8080servletPublisherDateProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

align=leftgtlt ttxbgt P ub lisher lt b x t t x t d gt )outprintln(lttd valign=middle align= leftx input

type=text name=publisher size=40 value=xtdgt)outprintln(lttrgt) outprintln(lttrgt lttd valign=middle

a lign= leftx ttxbgt P ub lica tion D a te lt b x ttx td gt )outprintln(lttd valign=middle align= leftx input

type=text name=publication_date size=40 value=xtdgt)outprintln(lttrgt)outprintln( c t r x td c o l s p a n = 2 x p x b r x td x t r gt )outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search Now

id=submitl name=submitlgt)outprintln(ltinput type=reset value=VClear FormYrsquo

id=resetl nam e= resetlxpgt )outprintln(ltcentergt) outprintln(ltformgt) outprintln(lthr noshade size=lgt)

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush()outclose()

)

protected void CreateHeader(PrintWriter out) outprintln(lthtmigt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding bgcolor=EEEECCgt)

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20pubiic_htmlflowergifgtlttdgt) outprindn(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(lt s tro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x stro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt)outprintln(lttd w idth=20xtdgt) ou t println ( rsquo lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

out pri ntln ( ltfon tgt) outpri ntln( ltcentergt ) out pri ntln ( ltpgt) outprintln(ltcentergt) outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)out pri ntln ( ltf on tgt) outprintln(irltcentergt) out println ( ltbodygt) out pri ntln( lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

cellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=YT00 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE= -lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

1 gtS earch B ookslt fontx stronggt)outprintln(lttdgt lttrgt)out pri ntln (lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=l-lgt)

outpri ntln(ltahref=httplocalhost8080servletReqCoilectauthorgtA uthorltfontxaxtdgtlttrgt)

120

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprindn(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=V-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln(lttablexpgt)outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

121

13 ShoppingCartjava

ltpgt This is the definition for ShoppingCart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import Javautil

public class ShoppingCart Hashtable items = null int numberOfltems = 0

public ShoppingCart() items = new Hashtable()

add BookDetails to cart param bookID isbn param book book need to be added to cart copyreturn void

public void add(String bookld BookDetails book) if(itemscontainsKey(bookId))

ShoppingCartltem scitem = (ShoppingCartltem)itemsget(bookld) scitemincrementQuantity ()

else ShoppingCartltem newltem = new ShoppingCartltem(book) itemsput(bookId newltem)

numberOftems++

param bookld isbn

public void remove(String bookld) if(itemscontainsKey(bookd))

items remove (bookld) numberOfltems - -

public Enumeration getltems() return itemselements()

protected void finalize() throws Throwable items clear()

public int getNumberOfItems() return numberOfltems

public void clear() items clear() numberOfltems = 0

123

14 ShoppingCartltemjava

ltpgt This is the definition for the shoppingcart item Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class ShoppingCartltem BookDetails item int quantity

public ShoppingCartItem(BookDetails anltem) this item = anltem this quantity = 1

public void decrementQuantity() if (quantity gt 0)

quantitymdash

public void incrementQuantity() thisquantity++

i

public BookDetails getltem() return thisitem

public int getQuantity() ( return thisquantity

i

124

15 StandardFooterjava

package servlets

import j avax servlet

ltpgt This is a server side include servlet that will format the TinyBookStore HTML footer

public class StandardFooter extends GenericServlet

ltpgtPerform the servlet service

param req The request from the client param res The response from the servlet public void service (ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the response javaioPrintW riter out = new

javaioPrintWriter(resgetOutputStream())

Format the standard footeroutprintln(ctable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(rdquoltfont s iz e = - lx a href=topgtTop of

P agelt ax fon tgt )outprintln(lttrgt) out println( lttablegt) outprintln(ltcentergt) outprintln(rsquoltfont size=-lgt)outprintln(lta href=7welcomeshtmlYgtTinybookstorecom

Homeltagt ampnbsplampnbsp)outprintln(lta href=categoryhtmlgtCategoryltagt

ampnbsplampnbsp)outprintln(lta href-authorhtmlgtAuthorltagt

ampnbsplampnbsp)outprintln(lta href=titlehtmlrdquogtTitleltagt ampnbsplampnbsp)

125

outprintln(lta href=isbnhtmlgtISBNltagt ampnbsplampnbsp) outprintln(lta href=7publisherhtmlgtPublisheramp44

Dateltagt)outprintln(ltpgt)outprintln(ltfontgt)ou t println ( ltcen tergt)outprintln(ltpgt)out println (ltcentergt )outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and

disclaim er^A gt ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln( ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

outflush()outclose()

126

16 StandardHeaderjava

package servlets

import javaxservlet

ltpgt This is a server side include servlet that will format the standard TinyBookStore HTML header The Title of the page will be set to the value of the title property

public class StandardHeader extends Generic Servlet

ltpgt Performs the servlet service param req The request from the client param res The response from the servlet

public void service(ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the responsejavaioPrintWriter out = new javaioPrintWriter(resgetOutputStream())

Get the title of the page Set to empty string if no title parameter was givenString titles[] = reqgetParameterValues(title)String title = if (titles = null)

if (titleslength gt 0) title = titles [0]

outprintln(lthtmlgt) outprintln(ltheadgt) outprintln(lttitlegt + title + lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=T00 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)

127

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src=dJavaWebS erver2 Opublic_htmlflower gi A gtlttdgt) out println(lttd width=3 O x td gt ) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyB ookStorecom ltigtlth2xstrongxtdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) out printl n ( lttd width=20gtlttdgt) out printl n( lttrgt) outprintln(lttablegt)

outflush()outclose()

128

17 TitleProcessjava

ltpgt TltleProcess This is the servlet that process the Tltle-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import j avax servlet import javaxservlethttp import javaio import j avasql

public class TitleProcess extends HttpServlet protected final String EXACT = exact protected final String OTFIERS = titleWords

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

129

String[] valuesString name =

values = reqgetParameterValues(title) if (values = null)

name = values [0]

String mode =values = reqgetParameterValues(title_mode) if (values = null)

mode = values [0]

String sqlStmt =if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where title=rdquo + name +else

sqlStmt = select from BOOK where title like rsquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString()

130

outprintln(lta href=servletDetailContent + isbn+

outprintln(rsgetObject(Title)toString() +ltagtltbgt)

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toString())

outprintln( +rsgetObject(Publisher)toString() + + rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +rsgetObject(Price)toString())

outprintln(ltbrxbrgt)i

if (count == 0) outprintln(ltdtgt No matched data found)

ioutprintln(ltdlgt) II end Glossary List

catch (SQLException e) i create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

131

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=EEEECCgt)

outprintln(rdquolttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaW ebServer20public_htmlflowergifxtdgt) outprintln(lttd w idth=30xtdgt) outprintln(rdquolttd align=left valign=center width=300gt)

outprintln(ltstronggtlth2gtltigtTinyBookStorecomltixh2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(rdquolttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln( lttrgt)outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(rdquolta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(rdquoltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

132

out println( ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) outprintln( ltcentergt) outprin tln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disciaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) S y s te m out println( LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt )

outprintln(lttable width= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y- lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost 8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

133

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lt tab lex pgt )

ou t pri ntl n ( lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

134

18 checkouthtml

lthtmlgtltheadgt lttitlegtCustomer Informationlttitlegt ltheadgtltbodygt

lt hlgt ltcentergt ltbgt Customer Information ltbgt ltcentergt lt hlgt

ltform method=POST action=httplocalhost8080servletCustomerInfoProcessgt lttable border=0gt

lttrgtlttd align=rightgtFirst namelttdgtlttd colspan=2 align= leftx input type=text name=firstname size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtMiddle initiallttdgtlttd colspan=2 align= leftx input type-text name=middleinit s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtLast namelttdgtlttd colspan=2 align= leftx input type-text name=lastname size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtEmail addresslttdgtlttd colspan=2 align= leftx input type=text name=email s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgt Account pass word lttdgtlttd colspan=2 align= leftx input type=text name=password s ize= 40x tdgt

lttrgtlttrgt

lthrgtlttrgt

lttablegtltbrgt

ctable border=0gtlttrgt

lttd align=rightgtCredit card numberlttdgtlttd colspan=2 align= leftx input type=text name=creditcard s ize= 40x tdgt

lttrgtlttr valign=topgt

135

lttd align=rightgtCredit card typelttdgtlttd align=leftgtltinput type=radio name=cardtype value=visagtVisaltbrgtltinput type=radio name=cardtype value= mastercard gtMasterCardltbrgt lttdgtlttd align=leftgtltinput type=radio name=cardtype value=bluebirdgtBluebirdltbrgtltinput type=radio name=cardtype value=fishergtFisherltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtCredit card holderlttdgtlttd colspan=2 a lign= leftx input type=text name=cardholder s ize= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCredit card expire date (mmddyy)lttdgtlttd colspan=2 align= leftx inpu t type=text name=expiredate size= 40x tdgt

lttrgtlt trx trgtlt trx trgtlttr valign=topgt

lttd align=rightgtSelect shipping methodlttdgtlttd align=leftgtltinput type=radio name=shipping value=upsgtUPSltbrgtltinput type=radio name=shipping value=expressgtExpressltbrgtlttdgtlttd align=leftgtcinput type=radio name=shipping value=normalgtNormalltbrgtltinput type=radio name=shipping value=abnormalgtAbnormalltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtReceiver Namelttdgtlttd col span=2 a lign= leftx inpu t type=text name=receiver size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtAddresslttdgtlttd colspan=2 align= leftx input type=text name=address size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCitylttdgtlttd colspan=2 align= leftx inpu t type=text name=city size= 4 0 x td gt

lttrgtlttrgt

136

lttd align=rightgtStatelttdgtlttd colspan=2 align= leftx inpu t type=text name=state s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtZipcodelttdgtlttd colspan=2 align= leftx inpu t type=text name=zipcode size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtPhonelttdgtlttd colspan=2 align= leftx input type=text name=phone size= 40x tdgt

lttrgtlttablegtlt b rx b rgtcinput type=submit value=Process name=actiongt

ltformgt

ltbodygtlthtmlgt

137

APPENDIX C

Screen Display of the Test

138

mmm File Edit View Favorites T o d s Help

^ Jit j j ^ LJ U 3) ~ pound=J _Am Back - S top Refresh Home j Search Favorites History Mait Print Edit

Links gtgt Address |4S ] httDVIocalhost808QAvdcorne shtml

TinyBookStore com

Welcome to the TJnyBoakStoro com

F i v e H o t B o o k s

1 T h e C + + Programming LanguageU s u a l l y s h i p s i n 24 h o u r s

B j a r n e S t r o u s t r u p A d d i s o n - W e s l e y Pub Co 1997 Our P r i c e 31 47

2 - P r o g r a m m i n g V i s u a l C + +U s u a l l y s h i p s i n 24 h ou r I I

Local intranet

Search BooksHorne

Category

Author

Title

ISBNPublisherDate

3 iigt60

3 1 S earch T inybooksloiecom - Microsoft Internet Explorer

139

T inyB ookStorecom - Microsoft Internet Explorer

j File Edit View Favorites lo o k Help

q a a H 3 1 d B ack S top R efresh Home S earch Favorite History j M aJ Print

Links gtgt A ddress httpV localhost 308QoryleV PetailCorterV 020i8SC l4

MM

Edit

Search Books

Home

Category

Author

Title

ISBN

PublisherDate

TinyBookStore com

The C++ Programming Languageby B j a r n e S t r o u s t r u p

0

ISBN 0 2 0 1 8 8 9 5 4 4 A d d i s o n - W e s 1e y P ub Co 199 7

Reviews

P r i c e 31 47A v a i 1ab i 1i t y U s u a l 1 ys h i p s w i t h i n 24h o u r s

Aic t o c a r t

ijgJ Local intranet

140

^ | I myBook5torecom Shopping Cart - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

[v] I ^ -J JB ack - Stop R efresh Home S earch Favorites History lsquo Mail Print

Links A ddress 0 1 h ttp localhost8080servetA ddT oShoppingCart ~3 ltGdeg

Shopping Cart Item s Price

The C++ Programmi ng LanguageB j a r n e S t r o u s t r u p Q u a n t i 1 7 1

Price $ 3 1 4 7 Subtotal $ 3 1 4 7

d e l e t e

Total 31 47

Customer Information Microsoft Internet Explorer

File Edit View Favorites lo o ls Help bull _

bullgt 3i 4 n j j d a 31Back ~-j Stop- R efresh Home S earch Favorites History j Mail Print Edit

Link gtgt j Address ] j j h ttplocalhost SOSOcheekoot html

EMH1

~3

Customer Information

First name jFang

Middle initial |a

Last name Xiao

Email address fxiaomitecnet

Account password pooooc

0 1 Done

Credit card number 1234567891234567

Credit card type VisaC MasterCard

C Bluebir d C Fisher

Credit card holder jr ong Xiao

ard expire date (mmddyy) J010102

Select shipping method UPSO Express

O Normal C Abnormal

J |sect Local intranet

141

lt2] Order List - Microsoft Internet ExplorerFile |d i t View Fayotites lo o t Help

^ 3 ^ S i l S - j S tep R efresh Home Search Favorite History Mail Print h-

HFte-LLinks A ddress I g ] httplocalhost8030servletCustemeilrifoProcess 3 ^Go

Your order reads as followsE - M a i l A d d r e s s f x i a o

F a n g X i a o

ship to

T e l

11 e m s

pound] Pc

10821 W e s t e r n P l a z aOmahaME6 8 1 5 4

( 4 0 2 ) 4 9 6 - 7 5 7 0T i t l e T h e C++ P r o g r a m m i n g L a n g u a g e Q t y 1 P r i c e 31 47 S u b t o t a l 31 47

| a [ Local intianet rsquo

l i

T inyB ookSloiecom - Microsoft Internet Explorer

T 7 ~ J iii 4 a i t Vi 1+ a Si

5 E

P r i te i+ A d d ie r I ig l httplocalhot8080ervletReqCollectauthor

S e a r c h B o o k s

Horne

Ca t e g o r y

A u th o r

Title

ISBN

P ublishe r Date

jS 1 D one

TinyBookStore com

fc t i t e r l i t n o rYou can enter authors full name first name or last name

A u t h o r |sCOtt

O ExactName amp Last F irst Name (or Initial)

T itiv b o o k s to re c o m H o a e | C a te g o ry | A u th o r | T itle | ISBN | P u b lish e r D ate

C opyright and disclaim ercopy 1999-2001 F an g Xiao

T op o f P f

|sect g j Local intranet

142

linyBookStore^com- MiciosoFUnteinet ExplorerFite Edit View Favorites Tools Ftelp

IIl4 rsquojO IjjlI - 3 -Upraquo 8 a c k ltbullltbullbullltlaquo Stop R efresh Home S earch Favorites History Mail Print 1

| Links 1 Address j raquo 3 http7localhost8CI80servletAuthorProcess

l - i f l |x |

S e a r c h B o o k s

Home

C a t e g o r y

Ti t le

ISBN

P ublishe r D a te

D o n e-

TinyB o okStore com

1- Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

I G aleampory I A utho t | I jt te | ISBN | PubH shei^D atg

i t and disclaim erreg 1999-2001 F ang Xiao

Top of

l i Local intranet

j T iny8ookStorecom - M icrosoft Internet Explorer

Fite Edit View Favorites Tools Help

4- 5 ni M m ~ltpound C r =gt 2f|L i p | | | | | iAdiiill|^Thttp7localhost8080seivletD etailContent0201924889

U 3

S e a r c h B o o k s

H ome

C a t e g o r y

A u th o r

Title

ISBN

P u b lish e r P a te

TinyB o okStore com

Effective C++b y Scott Meyers

ISBN 0201924889 Addison-Wesley Pub Co 1995

R eviews

This is the review of Effective C++

R eader Comments

Price 3795 Availability U sually ships within 24 hours

Add to iosil

IIH LdcSiiihttahdt

143

l inyBookStorecom Shopping Cart - Microsoft Internet Explorer

4- -- _ t lS M JJ ltpound I 7 r mdash2--I or- Stop R efiesh Home S ea rch Favorites History Wait PrintBach

Links Y 1^ddtessj-^1 httDvVlocalliostiBOBOyservletMddToShoppinqCart 73 ^

0

Shopping Cart Item s

Effective C + +Scott Meyers Quantity 1

0 1 Done

delete

Price

Price $ 3 7 9 5 Su b to ta l $ 3 7 9 5

Total 3 7 9 5

IB~ht Locai intranet

bull 3 TinyBooKGIoFooom M icrosoft Internet Cxplorcr

Fite Edit View Favorites Tools Help

4- -4gt Lfl 4 r amp J J lt$ i icirsquo s J ~lAB ack Ti(^poundprV aTdV iS^Stop-T SfSjefre^ptr I i - M t s s j r y rvlih- i JPopSnr -JE

i i i l l l P I I I ^ I i l l ] httplocalhost8080servletR eqC ollectauthor

G3SJ

7 ^ Go

S e a r c h B o o k s

H om e

C a t e g o ry

A u th o r

Title

ISBN

Eytoiisiier Date

101 D one

T i n y B o o k S t o r e c o m

E n te r AuthorYou can enter authors full name first narne or last name

A u t h o r jCraig Larmen

E Exact N ante O Last F irst N ame (or Initial)

Search Now 1 Clear Form

I C ategory | A u th o r | j j t l s | ISBN |

C opyright and ctiiclali[er copy 1999-2001 F an g Xiao

T o p o fP ag e

^tDpcafihttangfe-

144

gj TinyBbokSlorecom - Microsoft Internet ExplorerFile Edit View F a v o n te s - Pools

4-1 4 gt_poundj Q Jl3S top R efresh Home S ea rch Favorites History Mail PrintCacl-

lsquo Unko A ddress j ig ] httplocalhostSOSCiservletAuthorProces 71

S e a r c h B o o k s

Home

C a t e o o r v

A u th o r

Tit le

ISBN

P ub l i she r D a t e

Titty Bo okStore com

1 Applying UM L and Pattern Usually ships in 24 hours Craig Larmen Prentice Hall 1997 Our Price 450

T im booksto re com Home | C ateg o ry | A u th o r | Title | I3BM | Publisher P a ts

C opyrigh t and disclaimer copy 1999-2001 F an g X iao IIg ] http7localhost 8080eopyright html Local intranet

7 j T inyBookStorecom - Microsoft Internet Explorer

^ 03 4 31 0 i -_r _j _T B ack ~j~ S top R efresh Hom e Search Favorites History Mail Print Edit

I Links Addiess AocalhcistiiiOciOserv-letCctailConfent0137488S07

u m m

S e a r c h B o o k s

HorneC a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r Date

Tiny Bo okStore com

Applying LOVIL and Patternby Craig Larmen

0 Price 450 Availability TJ sually ships within 24 hours

ISBN 013748880 Prentice Halil 997

R ev iew s

Tins is the review o f Applying UML and Pattern

R ea d er Com ments

Add to cart

01ll iPdSSIihirSdety

145

3 TinyBookStorecom Shopping Cart bull Microsoft internet ExplorerFile Edit View Favorites Tools Help

vJBeck

JStop Refresh

4Home

H Si - iS- -=dSearch Favorites History Mail Pnnt

Links rdquo Address jlti] httpVlocalhostBOSOservletAddToShoppingCart 3 ^ Gc

r o 1

Shopping Cirt J toms Price

A pplying UML and PatternCraig Larmen Quantity 1 Effective C++Scott Meyers Quantity 1

l i l le t e

delete

Price $ 4 5 0 Subtotal $45 0

Price $ 3 7 9 5 Subtotal $ 3 7 9 5

Total 82 95

d f g a j Local intranet

146

lt3 TinyBookStoiecom - Microsoft Internet ExplorerFile Edit View Favorites Io o ls Help

gt j i 4 a - a i [j JB ack Forward Stop Refresh Home S earch Favorites Histeiy Mail Print Edit

Links Address ] pound ] hiipVonahost803CeerveirsquoReqColectlsquoauthor

0 1 i

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r D a te

Tiny Bo okStore com

You can enter authors full name first name or last name

A u t h o r jJeff

O Exact N ame Last First N ame (or Initial)

Search Now i Clear Form

T inybookstorecotti H oinf | Category | A trthor | Title j ISBN | Publisher Date

Copyright and disclaimer copy 1999-2001 Fang Xiao

Top of Page

M Local intraZl

m TinyBook Stote com - Microsoft Internet Explorer

Fife Edit View Favorites Joo ls Help

ISregBack Stop Refresh Home S earch Favorites History Marl Print c

Lirrks Address samp] httplocalhost8080servletAuthorProcess ~z ^ Gc

S e a r c h B o o k s

H ome

CategoryA u th o r

Title

ISBN

P u b lishe r D a te

i M

TinyBookStore com

1 Progi aimning Windows bullwith M FC Usually slaps in 24 hours JeffProsise Microsoft P ress 1999 Our Price 4799

jnybo-okstorscom Homo | Category | A u th or | Title | ISBN | Publisher P a h

C opyright and disclaijRief copy 1999-liOO1 FangX iao

Loccii intranet

147

148

m I myUookSlorecom - Microsoft Internet ExplorerFile- pound d it View Favorite T ools Help

^ J ] 4 U J j j =jgt Stop R efresh Home S e a rc h Favorites History i Mail Print EditBack

Links AddressilaquojigThttplocalhost5 i380ser4eM D etailContent157231 pound350

rfgKxi

ldquo3 gt6deg

S e a r c h B o o k s

HorneC a teg o ry

A u th o r

Ti tle

ISBN

P ub l i she r D a t e

TinyBookStorecom

Programming Windows with M FCby JeffProsise

0

ISB N 1572316950 Micro s oft Pre s s 19 9 9

Price 4799 Availability Usually ships within 24 hours

R e N ew s

This is the review of Programming Windows with MFC

R eader Comments

A dd to cart

D one i jh j Local intranet

lt 3 TjryBook S tore com Shop p in g Cart - M icrosoft Internet Exolorer

File Edit View f a nute T ools Help

r 1B ack

J 3 Q 0J amp poundlr - Jlilip isS h lA ld rS s httpy |ocalhost8U 80AervletA ddToShoppingCait TSIIlli

Shopping Cart Item s

Program m ing W indow s w ith M F CJeffProsise Quantity 1A pplying UML a n d PatternCraig Larmen Quantity 1 E ffective C++Scott Meyers Quantity 1

d e le te

d elete

d elete

Price

Price $ 4 7 9 9 S u b to ta l $ 4 7 9 9

P rice $ 4 5 0 S u b to ta l $ 4 5 0

Price $ 3 7 9 5 S u b to ta l $ 3 7 9 5

Total 1 3 0 9 4

^ h W h e iM

S s i Local intranet

149

File Edit View Favorites lo o ls Help n4- -0 iS - M L U

Back Stop Refresh Home Search FavoritesJ

History I3 H H H B H H H BMail Pm Edit

Links rdquo Addrecs |s] hHplocalhogt5t8080servletReqCollectcategorii ^_____ bulllt bullbull llilltllll

Search Books

Home

Category

Author

Title

ISBNPublisherDate

TinyBookStore com

P r o g r a m m in g

AI g o r i t Lins CampC++ D e l p h i J a v a MFC P e r l s o f t w a r e D e s i g n UML V i s u a l B a s i c M o r e

Done

Web D e v e lo p m e n t

ASP Commercem C y b e r c u l t u r e HTML J a v a S c r i p t S e c u r i t y Web D e s ig n XML more

G r a p h i c s amp S o f t w a r e

Asobe CAD D es k t op P u b l i s h i n g G r a p h i c s M i c r o s o f t More

I J J ig Local intranet

150

finvBookStorecom - Microsoil Internet Explorer - j g j x

j Fite Edit Jfiew Favorites lo o ts Help

bull j 5 a i B ack lsquolti S top Refresh Home S e a tc h Favorites History Mail Print Edit

Links 1 Address |ltg] hitpVocalhostl-i030seryletCateciofyPreceigtVc03 ^ | g

S e a r c h B o o k s

Home CategoQ

A u th o r

Title

ISBN

Publishe r D a te

TinyBookStore com

1 Core Ja v a 2 Usually ships in 24 hoursCay S Horstmaun Prentice Hall 1999 Our Price 2579

2 Ja v a S erv let Programm itig Usually ships in 24 hoursJason Hunter i O Reilly 1993 Our Price 1977

3 Ju st J a v a 2 Usually ships in 24 hoursPerter van der Linden Prentice Hall 1999 Our Price 3149

Tinybookstorecom Home | C ategory | A u th o r | T itle | IbBN | Publisher D ateloRoIEage

n g Local intranet

ta

151

41 Tinytfookbtorecom - Microsoft Internet ExplorerFile gdit y iew Favorites JLools Help

1 ^ hgt a a a amp a j ri i - 3 bull a Back Forward Stop Refresh Home S earch Favorites History Mart Print Edit

lisLinteslsii Address ji^]h ttp localhost8D 8o7serv letD etailC ontent0130319336

M i

3 f^Gc

S e a r c h B o o k s

Homec a t e g o r y

Tiny Bo okStore com

Core Java 2by Cay S Horstmaun

El

ISBN 0130819336 Prentice H alil999

Reviews

This is the review of Core Java

R eader Comments

Price 2579 Availability U sually ships within 24 hours

I Add to car

S ] Done S i Local intranet

TinyBookStorecom Shopping Cart - Microsoft Internet Explorerfel11 File Eefit View Favorite l o o k H e lp

tljH|V| 4 a 3 j 09 c T J

Stop Refresh Home S e a rc h Favorites History j Mail Print

jiiLihkIi87js ^ B ie s S ij^ ] http Z localhost8080servletiddT oShoppirigC art

B I B

3= i

Shopping Cart Item s

Core Java 2Cay S Horstmaun Quantity 1

Icopy

t i l

delete

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Total 2 5 7 9

sal Local intranet

152

a TinvBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites J o o lr Fjelp

NBack

amp Id b iStop Refresh Home

ISearch Favorifes History - Mail Print Edit

Links gty I Address [ jg l httplocalhost8080servletD etailContent156592391 x d

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

T i t le

IS B N

Publisher Date

ampJ Lrl e

Tiny Bo okStore com

J a v a S erv le t Piograitmmigby Jason Hunter

a Price 1977 Availability XT sually ships within 24 hours

ISBN 15659239 lx O Refflvl998

R e N ew s

In this brand-new third edition of Java Servlet Programming author Bjame Stroustrup the creator of Java presents the full specification for the Java language and standard library a spec that will soon become the joint ISOANSI Java standard

j ~2J Local intranetm

dH T iny8ook5torecom Shopping Cart - Microsoft Internet Explorer

File pound d t y iew Favorites Io o ls HelpB H

a $ a i a a -Stop Refresh Home S ea rch Favorites Hi lory Mjl

3- lsquonr I

| j | i | H | g i | i | i d ^ | | | | l Q httplocalhost80S0servletAddToShoppirigCart J P

m

Shopping Cart Item s

Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d e le te

d e le te

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Price $ 1 9 7 7 S y b to ta l $ 1 9 7 7

Total 4 5 5 6

I O I

aiil

153

Lustomer Information - Microsoft Internet Explorerpoundite pounddit View Favorites Xoo|s Help

v- _) _ l 4 J I VB ack - Stop R efresh Home Search Favorites History Mail

Links gty] A ddress ] j i l h ttD localhost8080checkouthtm l

F -iVj ~f

l l i l i i

C u sto m er In fo rm a tio n

First name jFang

Middle initial lA

Last name fXiao

Email address jfxiao m itecnet

Account password jxxxxx

Credit card number ]1234567B91234567

Credit card type C VisaC M asterCard

C Bluebird O Fisher

Credit card holder jFang Xiao

Credit card expire date (mmddyy) jo 10102

Select shipping method c u p sC Express

NormalAbnormal

0 ] D one Local intranet

poundpound Order List - Microsoft Internet Explorer

s

Back

Li il raquo

Yiew Favorites l o o h Help

bullV Y lJ j X I T- lty S to p Refresh H o m e

amp 1 3 J - jrS earch Favorite History lt Mail Print

fcesssaampl httplocalhost8080servletCustom erlnfoProcess

Y o u r ord er reads as fo llow sE-Mail Address 6daomitecnet

Fang Xiao

ship to

Tel

Items

12345 Western PlazaOmahaNE68154(402) 123-4567

Title C ore Java 2 Qty 1 Price2579 Subtotal 2579

Tide Java Servlet ProjammingQty 1 Pnce 1977Subtotal 1977 Total4556

ffl|b ] Done kl Local intranet

154

mammmm 1

File Edit View Favorites lo o ts tieip

E=cl i u F t l H -n e -i i rdquo F j-oiilsquoiBillHistory lsquo gt1 ll Print Edit

iiiiiiiiiiiiiiiiiirsquo Links Address j-copy] http localhust 8080servletReqCollectisbn J

TinyBookStore com

Search Books

Home ISBN

Author

Title

IS B N

S e a r c h Hew C le a r Form

PubnsheuDate

Top o f PageITnjrbooksj^ore^ com Horne I C a te g o rv | ^ i t h o r | T i t Ie I ISBN | Publisher Date

- g ] http locdlho-st SOSOwelcome shtrnl

TinvBookStorecom - Microsoft Internet Exploier

poundaj Local intranetId

| File Edit View Favorites Tools Help

i -e -e u u r5_ _ _ a u ^ 4 - a a j Back Forward S top Refresh Home S earch Favorites History Hail Print Edit

Links A d d re ss ^ hitp rsquoIdcanc-stEtnSOservlltlsquoF-aqZoll-~ntispn z raquo h

TinyB o okStore com

S e a r c h B o o k s

Horne

A utho r

T itle

ISBN

P u b lish e r P a t e

fcntar ISBN

I SB H 1565922840

|sectplli||pbw||l| IliM M pifiillj

T rgU onL cirrti -nr Kini- | Cgtgpound-gg | Agithor | Title | ISBN f uhhe-rt Pete

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top o f Pag e

aipoundbull] O o n e Local intranet

155

File Edit View Favorites Tools Help

HUTinyBookStorecom - MicrosoH InternetExplorer

B ad-J J A J d -2r =3

Stop R efresh Home S e a rc h Favorites History Mail Print

Links ygt A ddress j ^ ] httpVlocalhost8080servletrsquoISBM Process

S e a r c h B o o k s

Horne

C a t e g o r y

A u th o r

T itle

IS B N

Pub l i she r D a t e

TinyB o okStore com

1 Learning Perl Usually ships m 24 hours Randal L Schwartz O Reilly 1997 Our Price 1997

T in vh ooksto re c o m H orne | C at ego tv | A u th o r | Title | ISBM | Publisher D ate

C opy rig h t a n d d isclaim ercopy 1999-2001 F a n g X iao

0 ] Done

yen

ighj Local i

TinyB ookStoiecom - Microsoft Internet Explorer

Erie Edrt View Favorites- lo o ls Help

-s pound] 4 pound1 jLl icArdquo =pound 2 S top Refresh Home S earch Favorites History Marl Print Edit

iilHI

NpBack

httpyiocalhostSOBOservleMDetailContentAI 565922840 ~T] Cm

Tiny Bo okStore com

S e a r c h B o o k s

H o m e i

C a teg o ry

A u th o r

T itle

ISBN

Publishe r D a te

Learning Perlby Randal L Schwartz

I ^

ISBN 1565922840 O Reillvl997

Price 1997 Availability U sually ships within 24 hours

Reviews

This is the review of learning Perl

Reader Comments M0 ] Done lsquofR | Local intranet

156

IHHHHHI _ I f f i x |

File E d t yiew Favorites J o e ls H elp 11v- -__ l

Back ~ rc Stop R efresh Home S earch Favorites HistoryJ rMail

HH1111Pgtnt

Links A ddress | ] http7docalhost8030servleM AddToShoppingCart 3 tgt G o

O S III

Shopping Cart Item s

Learning PeriRandal L Schwartz Quantity 1

delete

Price

Price $ 1 9 9 7 Subtota l $ 1 9 9 7

Total 1 9 9 7

s

Done Local intranet

Eg W illi 1 lttMM41 i H H p n B n 1 0 1 x i

Fite Edit View Favorites Toots Help E H

1$3 L plusmn J8ack Forward Stop Refresh Home Search Favoutes

4History i

- i V -=JMail Print

-Edit

71 Address http7localhost8080lsquoservletFleqCollecVisbn I l f i l l l

TinyBookStore com

Search Books

Home

C ateao rv

Author

Title

ISBN

Publisher D a te

Enter ISSN

i s bit [l 565921496

Search Now I Clear Form

Tinybookstore o n Home | Category | A uthor | Titb | ISBN | Publisher Dte

Copyright arid disclaimer copy 1999-2001 Fang Xiao zl amp j Done Js J Local intranet I

157

H H H r f e i x i File Edit View Favorites Lools Help

- J j j j ] JBack Stop Fiefresh Home Search

J JFavorites-

-J i C rHistory Mail Print

111111811i n

r Links wj i Address |reg] http docalhost 8080servletIS8N Process

S ea rch B ooks

Home

Category-

rdquo A u th o r

T i t l e

IS B fi

P u b l i s h e r D a ta

Tiny Bo okStore com

1 Programtning Perl Usually ships in 24 hours Larry Wall O Reilly 1997 Our Price 2397

T o o k s t o r e c o m H P in e | C a t e g o r y | A u t h o r | Till | IS B N | P -ubtu-hai D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g X ia

T o p o f P a g e

zlamp2 Done Local intranet

158

lt3 l mytfookSlorecom - Microsoft Internet ExplorerF3e Edit View FavoMes lo o ts Help

Back3 U Si S rsquo IStop Refresh Home lt Search Favorites History Mail Print Edit

httplocalhost8080servletDetailContent15S5321496 j3

Search Books

Horns

Category

Author

Title

ISBN

Publisher Date

Done

TinyB o okStore com

Programming Perlby Larry Wall

0 Price 2397 Av ail ability U sually ships within 24 hours

ISBN 1565921496 O Reillyl997

Reviews

This is the review of Programming Perl

Reader Comments

Add to cart

l or=lM

159

Tm vBookSlorecom Shopping Cart - M icrosoft Internet Explorer

i Fite Edit View Favorites lo o k Help

^ Beck R efresh Home

ampS earch Favorites History j Mail Print

E Links I Address ] pound http localhost 8080servletA ddT oShoppingCart rsquo ] O rai

i O

Shopping Cart Jlems

Learning Peri Randal L Schwartz Quantity 1 Program m ing PeriLarry W all Quantity 1

delete

d e le te

Price

Price $ 1 9 9 7 S u b to ta l $ 1 9 9 7

Price $ 2 3 9 7 S u b to ta l $ 2 3 9 7

Total 4 3 9 4

3SJ Done j | s [ Local intranet

160

m m mmmHi mmmHHHHHi1 File Edit View Favorites Tools Help

^ - J J -ih Ji - j| B a d Forward Stop Refresh Home S earch FavoritesHIH ctuv Mjl Print

IHIlllliEd

B l

MbfeifcssfjP Address httplocalhost8080servletFleqCollectpLiblisher_date_ ___ ________ ___________ _ bull bull bull bull_________________ Zi T gt 6 o

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

Title

ISBN

Publishe r P a t e

S ] Done

TinyBo okStore com

T rsquov -

Publisher

sind IPpiIs1iclaquoifciori OsifiC

jAd cl i so n-VVe oI e y Fuo C o ~

P u b l i c a t i o n D a t e 1U97

Search Now Clear Form

T inybookstore com Home | C ategory j A u tho r j I itle | ISBN | Publisher Ds

C opyright and disclaimer copy 1999-2001 F an g Xiao

T op o f Page

g a l Local intranet

161

lt|j TinyBookStoiecom - Microsoft Internet Explorerlsquo Erie Edit View Favorites lo o ls Help

v-1 Q rij - 3 rsquo- a u -=pound Ci Back s lsquoi i 1 Stop Refresh Home S earch Favorites History Mail Print i

jL inks i A ddress 0 1 http7localhost8Q80servletPublisherDateProcess

EMM

3

S e a r c h B o o k s

Home

C a t e g o r y

Author Title

ISBN

Publisher D a te

TinyBookStore com

1- Algorithm s in C Usually ships in 24 hoursRobert Sedgewick Addison-Wesley Pub Co 1997 Our Price 4495

2 The C++ P rogr amming L anguage Usually ships in 24 hourBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

3 Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

4- U M L D istilled Usually ships in 24 horn sMartin Fowler Addison-Wesley Pub Co 1997 Our Price 2995

Done | s j L ocalm

TinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorites l o o k Help

Backamp 3 $ -Q 3 3 AJStop Refresh Home S earch Favorites History Mail Print Edit

Lipikkigt7i Ajddr$esjhttpv7localhost8080-servletDetailCoriterit0201314525

m

3 rgtGc

S earch B ooks

Horne

A uthor

Title

ISBN

Publisher D a te

Tiny BookStore com

Algorithms in Cby Robert Sedgewick

S

ISBN 0201314525 Addison-Wesley Pub Co 1995

Reviews

This is the review of Algorithms in C

Reader Comments

Price 4495 Availability U sually ships within 24 hours

Add to cart

0I reg S a i t^ s a l intranet

162

File Edit View Favorites lo o ls Help

2 ^ iVi ^ ^ t j j B ack gt Stop Refresh Home S ea rch Favorites History ||

- i -Mail Print

WB0BUBSSSI B ifl

Links ygt Addrese |isect ] httpvVlocalhostSOSChservletAddToShoppingCart

Shopping Cart Item s

A lgontfim s in CRobert Sedgewick Quantity 1

0 1 D one

delete-

Price

Price $ 4 4 9 5 Subtota l $ 4 4 9 5

Total 4 4 9 5

Local intranet

163

^ l inyBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

ls31

3 bullrsquo -I- _J _jj - j i_ 3 - j rdquo -= $ ABack Forward Stop Refresh Home Search Favorites History Mail Print Edit

Links rdquo Address 6 J http Vlocalhost SOSOAervletR eqCollectpublisher_date j ^G

Search B o o k s

Home

categoryAutho r

Title

IS B N

Publi sher D a te

TinyBookStore com

liter Publisher and Publication Date

P u b l i s h e r Wrox Press Inc

P u b l i c a t i o n D a t e ]1

Search Now j Clear Form

T invbookstor ecotnHomg | Category | A uthor | Title | ISBN | Pu b lish e rP a t

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top of Page

zD one Local infra

m TinyB ookStoiecom - Microsoft Internet Explorer

R e Edit View Favorites Tools Help

- -i 13 4 St 2J amp t r - JHB-1

fff ij if P S | Address |sjpound~| httpVlocalhost8030servletPublisherDateProcess

S e a r c h B o o k s

Home

C a t e g o r y

A utho r

T itle

ISBN

Publisher D a te

0 ] Done

TinyBookStore com

1 Beginning Visual Basic 6 Database Programming Usually ships in 24 hour John Connell W rox Press Inc 1998 Our Price 3199

2 Befmiung Visual Basic 6 Usually ships in 24 hours Peter Wright Wrox Press Inc 1998 Our Price 3199

T inybookstore com H orae | C ategory | A u thor | Title | ISBN | Publisher Date

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top o f Fas

Local intranet

64

| File Edit Yiew Favorites T ook Help

i A - + - - a S 3 rsquo reg - pound J -3 Back ldquo d Stop Refresh Home Search Favorites History

- vMail Print

i

Edit

IllplBlllll________ g - M

isisfcinbsijp Addre s | g ) httplocalhost8080servletDetailCoritent1861001061 3 Gdeg

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

T itle

ISBN

Publishe r D a te

TinyBookStore com

Beginning Visual Basic 6 Database Programmingby John Connell

a Price 3199 Availability U sually ships within 24 hours

ISBN 1861001061 Wrox Press Inc 1998

Reviews

This is the review of beginning Visual Basic 6 Database Programming

Reader Comments

A d d to c a n

S] pone Local intranet

m u i

lillllEHl ^ bdquo A 3 2tl 4 t M liJ i

Back Forward Stop Refresh Home Search Favorites3

History 4 _ r

M j 1J

Print EditiSillilillllS

httplocalhost8080servletReqCollecttitle

S e a r c h B o o k s

Home

C a t e g o r y

Author

Title

ISBN

Publisher Date

TinyB o okStore com

Enter TicleYou can enter the exact title or part of title

T i t l e C++

O Exact Title Title Words

Search Now Clear Form

Example

bull Entering Java Servlet Programming in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title are related to Java _li

165

lt5 TinyBookStorecom - Microsoft Internet ExplorerFite Edit View Favorites lo o ts Help

Back Stop Refresh Home S earch Favorites History Mail Print

Links gty Addiess http-localhost8080servlet7TitleProcess

i|p1

I

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

Publi sher IS a t e

TinyBookStore com

1 The C++ Programming L anguage Usually ships in 24 hoursBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

2 Effective C+-F Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

3 Programttung Visual C-H- Usually ships in 24 hours David J Kmglinski Microsoft Press 1998 Our Price 3999

T m y h o o k s to e co m H o m e | C a te g o ry | A u th o r | T itle | ISBH | P u b lish er D ate

http iocalhost SOSOservletFleqCollectcategary

T op of P age

~hj Local intranet

bull a TlnjpBflOkStOfecom - Microsoft Internet Explorer

File Edit View Favorite Pools Help

0 3 4 S l i 3 O - J J i t of Stop Refresh Home S earch Favorites History - Mart Print Edit

HBack

i i i i lS i lB i I i f f id i l f f lH Q http Vlocalhost 8080AervletD etailContent1572318570

EEEI

J

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b lis h e r D a f t

TinyBookStore com

Programming Visual C++by David J KrngHnski

[Hj

ISBN 1572318570Microsoft Press 1998

Price 3999 Availability Usually ships within 24 hours

R e v ie w s

This is the review o f Programming Visual1

Reader Comments

Add to cart

if Local intranet

166

mm| File pounddtt View Favorites Jo o ls Help

c J J j j mdash JB ack - J Stop Refresh Home S earch Favorites History

- _ i -M u

J tPrint

t e t a f e w P A ddress | ^ ] httplocalhost8080servletAddToShoppingCart zl -lt1gtSo

Shopping Cart Item s

Programmeng Visual C + +David J Kmgbnski Quantity 1

delete-

Price

Price $ 3 0 9 0 Sub to ta l $ 3 9 9 9

Total 3 0 9 9

D one ^aj Local intranet

TinyBookStorecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

vHBack-

-J a 4 -a si fi- 3 aStop R efresh Home S earch Favorites History j Mail Print- Edit

Links gty A d d re s sL ^ ] hrtpWlocalhostSOSOservleVFIeqCollectAitle

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

ISBN

Pub l i she r Date

TinyBookStore com

Enter TitleYou can enter the exact title or part of title

Title Distil I nrfExact T itle V T itle W o rd s

Search Now | Cle ar Fo rm

Examples

rpound] Done

bull Entering Java Servlet Programming11 in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title arei date 11 j Java JZJ

167

a TlnyBA5kSioiecom - Microsoft Internet Explorergt 0e Edit ifiew Favorites Jock Jd lp

a a amp -a tii j k i Back s - Stop Refresh Home Search Favorites History Mail Print

liilP raquo httpiVlocalhostSOSOservletTitleProcess

E M 3

ldquo3 rgt-

S ea rch B ook s

Horne

C a t e d o r v

A utho r

TiUgt~ ISSN

Publi sher D a te

Tiny BookStore com

1- TJML D istilled Usually ships in 24 nowsMartin Fowler Addis on-Wesley Pub Co 1997 Our Price 2995

| C s rg g o ty | A u th o r | T itle | IStBH I P u b lis h e r D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g Xiao

-jg Local intranetS3

m n ^ i l a i i x l

File Edd View Favorites Joels- Help M Mi r J lt 3 L h f 4 - 0 lt 3

Back i t Stop Refresh Home S earch Favorites History Mail9

PrintM

Edit

Links raquo A ddress j | i ] http do ca lh o d 1030N m letDetailContenr0201325632 Mimas

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

Title

IS B N

Publisher Date

Tiny BookStore com

TJML Distilledby Martin Fowler

0

ISBN 0201325632 Addison-Weslev Pub Co 1997

Reviews

Tins is the review of The UML Distilled

Reader Comments

Price 2995 Avail abilityTJs u ally ships within 24 hours

Add to c a r t

0 3S i] Done |g^iLnealiihfrregei

TinyBookStorecom Shopping Cart Microsoft Internet ExplorerFile Edit View Favorites Jo o ls HetP

IBiiiBlll l l lHBlSglSlllllilMH MlllBliriilllgllSlIlBack - f - i - S top Refresh Home

a J i l ^ j 3 Search Favorites History 1 Mail Print liiii

3 Links ( A ddress j ig j hrtplocalhost803DservletAddToShoppingCart

Shopping Cart Herns Price

UML D istilledMartin Fowler Quantity 1Program m ing Visual C + +David J Kraglinski Quantity 1

Price $ 2 9 9 5 Subtota l $ 2 9 9 5

delete

Price $ 3 9 9 9 Subtota l $ 3 9 9 9d elete

Total 6 9 9 4

  • Electronic Commerce on Business Application
    • Recommended Citation
      • tmp1499779448pdf2JOpQ

THESIS ACCEPTANCE

Acceptance for the faculty of the Graduate College

University of Nevraska in partial fulfillment of the

Requirements for the degree of Master of Science

University of Nebraska at Omaha

Committee

DepartmentSchoolName

Chairperson_

Date rdquo l l - l l - i m

Acknowledgements

I would like to express my sincere appreciation to my thesis advisor Professor Peter A

NG for his kind guidance time and support I would also like to say thank you to my

supervisory committee Dr Qiuming Zhu Dr Bin Chen for their suggestions help and

cooperation

Abstract

For some time now Whole size business enterprises have used electronic commerce

to conduct their business activities The On-Line store is one of a number of popular

web applications This thesis focuses on one of the emerging On-Line store

technologies which is known as Server-Side Java Application

In early 1960 private networks were dedicated for the use of electronic data

interchange (EDI) and electronic funds transfer (EFT) in banking business Recently

however with the increased awareness and popularity of the Internet electronic

commerce has come to encompass individual consumers as well as businesses of all

size For most people electronic commerce is defined as the buying and selling of

products and services over the Internet but there are many more aspects We will

discuss different definitions of electronic commerce in this paper

The most popular Web applications are the On-Line Stores Most of such applications

involve functions as searching for product information ordering products paying for

goods and services and for providing online customer service A Web server running

continuously accepts userrsquos connection gets user requests and forward requests to

business procedure retrieves data (answers to user requests) from business procedure

and sends it back to the user

An on-line store system is different from a traditional web publishing It needs a

customerrsquos interactive communication and frequent data update The traditional

HTML page does not satisfy the customerrsquos needs because all it does is simply

publish static contents More complex technologies are required in order to produce

dynamic contents

There are a few technologies that can be used for implementing the on-line stores

Common Gateway Interface (CGI) Microsoft Active Server Page (ASP) and Server-

side Java application are the most popular technologies Introducing the Server-Side

Java application is one of the latest and most exciting trends in Java programming

The Server-side Java application has many advantages over the other technologies

Table of Contents

Chapter 1 Introduction 1

Chapter 2 Electronic Commerce 2

21 What Is Electronic Commerce2

22 The Importance of Electronic Commerce3

23 Types of Electronic Commerce3

24 Why Most Internet Based Electronic Commerce Is In

The Business-To-Consumer W orld 6

25 Current State of Business-To-Consumer E-Commerce7

26 The Structure of The On-Line Store8

Chapter 3 Technologies For On-Line Store System11

31 Traditional Web Application - Common Gateway Interface(CGI) 11

32 Active Server Page 12

33 Server-Side Java Application 14

Chapter 4 Design of On-Line Bookstore Using Java Servlets

A Practical Verification18

41 The Design of Home Page of Tiny Book Store18

42 Design of Search by Different Requests27

43 Servlets Chaining To Process Requests In Different Levels28

44 Database Connectivity and Search from Database29

45 Session Tracking 35

46 Check O ut42

47 Customer Information Processing 43

Chapter 5 Future Work50

51 Connection Pooling50

52 More Object-Oriented - Better Encapsulation51

Chapter 6 Conclusion 53

Appendix A Bibliography54

Appendix B The Source Code of An On-Line Store System -

Tiny Book Store57

Appendix C Screen Display of the Test 135

List of Figure

Figure 261 The Structure of An Online Store 10

Figure 321 Handle Requests Flow Chart 13

Figure 331 HttpService of The Java Web Server Using Servlets 15

Figure 411 The Home Page of Tiny Book Store 22

Figure 412 One of The Searching by Author Pages26

Figure 441 One of The Outputs of Servlet AuthorProces 34

Figure 451 A Page Show All Information About A Book 39

Figure 452 A Page Show Items In The Shopping Cart After A User

Added Books To The Shopping Cart 40

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A

Book From The Shopping Cart42

Figure 461 A Check Out Page 43

Figure 471 An Invoice Page48

1

Chapter 1

Introduction

As we step in the year 2000 we can no longer look to the past as the guide for the

future A combination of business social and technical possibilities drives the rapid

progress in electronic commerce

Electronic commerce can offer a company both short-term and long-term benefits

Not only can it open new markets enabling a business firm to reach new customers

but it can also make it easier and faster for the firm to do business with their existing

customer base Moving business practices such as ordering invoicing and customer

support to network-based systems can also reduce the paperwork involved in

business-to-business transactions When more of the information is digitized it

allows that business firm to focus on meeting their customerrsquos needs Tracking

customer feedbacks and presenting customer solutions for their clientele are just

some of the opportunities that can stem from electronic commerce

2

Chapter 2

Electronic- Commerce

21 What Is Electronic Commerce

For some time now large business enterprises have used electronic commerce to conduct

their business-to-business transactions In early 1960 private networks were dedicated

for the use of electronic data interchange (EDI) and electronic funds transfer (EFT) in the

banking industry Recently however with the increased awareness and popularity of the

Internet electronic commerce has come to encompass individual consumers as well as

businesses of all size

To many electronic commerce is defined as the buying and selling of products and

service over the Internet But there are many other aspects Depending on whom you ask

electronic commerce has different definitions

From a communications perspective electronic commerce is the delivery of information

productsservices or payments via telephone lines computer networks or any other

means From a business process perspective electronic commerce is the application of

technology toward the automation of business transactions and workflow From a service

perspective electronic commerce is a tool that addresses the desire of firms consumers

and management to cut service costs while improving the quality of goods and increasing

3

the speed of service delivery From an online perspective electronic commerce provides

the capability of buying and selling products and information on the Internet and other

online services [16]

These definitions are valid with their perspectives It is a matter of which lens is used to

view the electronic commerce landscape Broadly speaking electronic commerce

emphasizes the generation and exploitation of new business opportunities by ldquogenerating

business valuerdquo or ldquodoing more with lessrdquo

22 The Importance of Electronic Commerce

As we approach the year 2000 we can no longer look to the past as guide to the future In

the face of strong market forces created by electronic commerce and mounting

competition corporations can no longer plod along historical tracks or seek the

preservation of the status quo Companies are discovering that old solutions do not work

with new problems The business parameters have changed and so have the risks and

payoffs

23 Types of Electronic Commerce

From a broad view there are three distinct general classes of electronic commerce

applications Inter-organizational (business-to-business) intra-organizational (within

business) and customer-to-business application [16]

4

231 Inter-Organizational Electronic Commerce

Inter-organizational electronic commerce makes business more convenient on the

following aspects

Firstly e-commerce can improve supplier management since electronic applications can

reduce the processing costs and cycle times for each purchase order and it can reduce the

number of people who work on purchase orders

Secondly e-commerce can improve inventory management since electronic applications

make the business partners can fast exchange information and easy track their documents

to ensure that they were received This not only can eliminate out-of-stock occurrences

but also can reduce inventory and improve inventory turn

Thirdly e-commerce can improve distribution management since electronic applications

can make the business partners receive the shipping documents as soon as possible and

enable better resource management by ensuring that the documents contain more accurate

data

Fourthly e-commerce can improve channel management since electronic application can

let the business partner post the information to electronic bulletin boards This can

eliminate repeated telephone calls and countless labor hours

Fifthly e-commerce can improve payment management since the business partner are

linked by network so the payments can be sent and received electronically Electronic

payment is more accurate and fast than traditional payment

232 Intra-Organizational Electronic Commerce

5

Intra-organizational electronic commerce facilities the following business applications

Workgroup communications Electronic applications enable manager to

communicate with employees using electronic mail videoconferencing and

bulletin boards

Electronic publishing Electronic applications enable companies to publish

information by using tools such as the World Wide Web On-line publishing can

show information immediately and clearly and reduce costs for printing and

distributing documentation

Sales promotion Electronic application improve the flow of information between

the production and sales forces and between the firms and customers This can

make companies have greater access to market and competitor information

Today Intranets are primarily set up to publish and access vital corporate information

Some of the most common types of information are Human Resources information

employee communications product development and project management data internal

catalogs sales support data equipment and shipment tracking and accessing corporate

database

233 Consumer-To-Business Electronic Commerce

In consumer-to-business transactions customers learn about products through electronic

publishing buy products with electronic cash and other secure payment systems and

even have information goods delivered over the network

6

From the consumerrsquos perspective there are three transactions

1 Electronic applications enable consumers to communicate with each other through

electronic mail videoconferencing and news groups

2 Electronic applications enable consumers to manage investments and personal finances

using online banking tools

3 Electronic application enable consumers to find online information about existing and

new products services

Consumers consistently demand greater convenience and lower prices Electronic

commerce provides consumers with convenient shopping methods from online catalog

ordering to phone banking both of which eliminate the costs of expensive retail

branches Electronic commerce facilitates factory orders by eliminating many

intermediary steps thereby reducing manufacturersrsquo inventory and distribution costs and

indirectly providing consumers with lower prices

24 Why Most Internet Based Electronic Commerce Is In The Business-To-

Consumer World

For the Business-to-Business e-commerce the lack of well-accepted standards is

hindering the success in promoting Business-to-Business electronic commerce

solutions[5] VAN (Value-Added Networks) EDI (Electronic Data Interchange) based

solutions are only accessible to large organizations due to the cost factor Corporate

buyers and suppliers large and small are looking for Internet based solutions to

streamline the procurement procedures and to reduce the cost of establishing trading

relationship and the trading transactions Such demands put forward some fundamental

challenge on issue like trust infrastructure on the Internet standards and inter-operability

etc

25 Current State of Business-To-Consumer E-Commerce

Business activity on the Internet is currently limited to publicizing the business

opportunity and to catalog based sales but it will rapidly expand to include the

negotiations conducted to settle the price of the goods or commodities being traded

These negotiations are currently conducted by human intermediaries through various

forms of auctions bidding systems for awarding contracts and brokerages The role of

the intermediaries can now be performed by Internet trading applications at a fraction of

the cost[4] Trading on the Internet allows a business to reach a large number of potential

customers and suppliers in a shorter time and a lower cost than possible by other modes

of communication and to settle business transaction with lower cost overhead in a shorter

time

Auctioned or brokered sales are the norm in business world for negotiating trades of large

monetary value But consumer sales and small-scale purchases have used the fixed price

mode perhaps because of the high overhead cost of using the auction or brokerage

method The new economics of the Internet will make auctions popular in consumer and

small business transactions also

Auctions are just one form of business negotiations Other examples are competitive bids

for procurement brokeragesexchangescartels and two party negotiations

Nowadays the free-market economy of software agents is in the embryonic stage But in

the near future the software agents will populate the Internet and provide trade and use

a rich variety of information goods and services in an open free-market economy In a

free-market economy of software agents information is produced traded and consumed

by vast numbers of autonomous self-motivated agents An essential task in such an

economy is the retailing or brokering of information gathering it from the right

producers and distributing it to the right consumers[10] The overall research goal is to

characterize and understand the dynamic behavior of information economies very large

open economies of automated information agents that are likely to come into existence in

the Internet

26 The Structure of The On-Line Store

9

Nowadays there are thousands of on-line stores running on the Internet A few well-

known ones are amazoncom and bookpoolcom Most of such applications involve

common functions which are as following

Searching for product information

Ordering products

Paying for goods and services

Providing online customer service

So they have a similar structure as shown in Figure 261 The system contains the

following components

1 A web server running continuously accepts userrsquos connection gets user requests and

forward requests to business procedure retrieves data (answers to user requests) from

business procedure and send it back to user

2 Business procedure usually consists of a user identification procedure like credit card

check user request analysis procedure analyzing requests calculating discomposing (if

necessary) and dispatching request to different data source component Also in some

case business procedure is responsible to compose data obtained from different data

sources into user-readable format

3 Database is the place to hold relevant data These data not only serve as a data source

describing commercial goods and prices but can be used for data mining to improve

store service quality as well Database is updated and maintained by both customersrsquo

input and system applications A customerrsquos input usually includes order information

10

Figure 261 The Structure of An Online Store

(through browser)

Databas

(through browser)client

client

serverWeb

Systemapplication

Busines

procedu

4 System applications can include a search engine running all the time and searching

relevant information from the internet data mining application deals with mining and

analyzing customer and sale data for management use database maintaining application

handles update data when product information changes Varying from system size to

system size not every system has cleardistinct boundaries between these components

The system can be 3-tired or n-tired but these systems all operate in similar ways

11

Chapter 3

Technologies For On-Line Store System

An on-line store system is different from traditional web publishing It needs customerrsquos

interactive communications and frequent data update The traditional HTML page is

insufficient because all it does is provide static content publishing Other technologies

are required in order to implement the on-line store

Currently there are three mainstream technologies which are widely used Common

Gateway Interface (CGI) Microsoft Active Server Page (ASP) and Server-side Java

application We briefly explore these technologies here

31 Traditional Web Application - Common Gateway Interface (CGI)

The common Gateway Interface normally referred to as CGI is one of the first practical

techniques for creating dynamic content With CGI a web server passes certain requests

to an external program The output of this program is then sent to the client in place of a

static file The advent of CGI makes it possible to implement all sorts of new

functionality in web pages and CGI quickly become a defacto standard implemented on

dozens of web servers Even though a CGI program can be written in almost any

language the Perl programming language is the predominant choice However CGI have

some distinct disadvantages

Firstly CGI program is transient A request is made each time to a CGI program It must

be loaded and executed by the Web server When the CGI program is complete it is

removed from memory and the results are returned to the client All program

initialization (such as connecting to a database) must be repeated each time a CGI

program is used

Secondly when a server receives a request that accesses a CGI program it must create a

new process to run the CGI program and then pass to it via environment variables and

standard input Every bit of information might be necessary to generate a response

Creating a process for every such request requires time and significant server resources

which limits the number of requests a server can handle concurrently

Thirdly a CGI program cannot interact with the web server or take the advantage of the

serverrsquos abilities once it begins execution because it is running in a separate process

32 Active Server Page

As shown in figure 321 the following list walks you step-by-step through what

happens if the client requests the page xyzasp

The client requests the page xyzasp from the server The Web server checks the file

extension to see whether a special program (such as the Active server Pages engine)

13

must be invoked to process the request If therersquos a asp extension the Web server

determines that it should invoke ASP to process this page

Figure 321 Handle Requests Flow Chart

Request

Response

WEB SERVERComponents

Databas

ns

ASP File

CLIENT

Active X Data

VBScript

If this page has never been requested before or has been changed since the last

request it must be parsed and the syntax checked and then be compiled by the Web

server Otherwise the page might be read from a cache of recently processed pages

which aids in performance During the parsing process the HTML and scripting code

14

are separated IIS (Internet Information Server) determines which scripting engine is

responsible for which part of the script and delegates the work of syntax checking and

compiling to the proper scripting engine (such as VB Script)

Now the code is executed by the scripting engine using resources from IIS which is

hosting the scripting engines All objects that the language engine cannot handle are

requested by the IIS which is also responsible for handling inputs and outputs for the

external ActiveX objects that are created and used inside the script If it is not able to

supply the object an error is generated

Script output and static HTML code in the ASP file are merged

The final HTML is sent back to the user in an HTTP response

The important point about ASP is that the Script runs entirely in a server to protect the

intellectual property by shielding it from browser which are different from the account

for when writing client-side code The entire server-side code is processed and only plain

HTML - or whatever kind of content you chose to generate - is sent to the client

33 Server-Side Java Application

The rise of server-side Java applications is one of the latest and most exciting trends in

Java programming A Servlet can be thought of as a server-side applet Servlets are

loaded and executed by a Web server in the same manner that applets are loaded and

executed by a Web browser

15

As shown in Figure 331 a servlet accepts requests from a client (via the Web server)

performs some task and returns the results

The client (mostly likely a Web browser) makes a request via HTTP The Web server

receives the request and forwards it to the servlet If the servlet has not yet been loaded

the Web server will load it into the Java virtual machine and execute it The servlet will

receive the HTTP request perform some type of process and return a response back to

the Web server The Web server will forward the response to the client

Figure 331 HttpService of The Java Web Server Using Servlets

RequestResponseRequestResponse

RequestResponse

Java Web Server

Administrative SERVLET

SERVLETHTTP

SERVLETWeb Proxy

Servlets have distinct advantages over CGI program

Servlets are persistent Servlets are loaded only once by the Web server and can

maintain services (such as a database connection) between requests

Servlets are fast since servlets only need to be loaded once

16

Servlets are platform independent Servlets are written in Java and conform to a well-

defined and widely accepted API They are highly portable across operating systems

and across server implementations A servlet can be developed on a Windows NT

machine running the Java Web Server and later can be deployed effortlessly on a

high-end Unix server running Apache

Servlet portability is not the stumbling block it so often is with applets There are two

reasons Firstly servlet portability is not mandatory Unlike applets which have to be

tested on all possible client platforms servlets have to work only in the server

machines that you are using for development and deployment Unless you are in the

business of selling your servlets you donrsquot have to worry about complete portability

Secondly servlets avoid the most error-prone and inconsistently implemented portion

of the Java language the Abstract Windowing toolkit (AWT) that forms the basis of

Java graphical user interfaces

Servlets are extendable Servlets that are written in Java brings all of the other

benefits of Java to servlet Java is a robust object-oriented programming language

which can be extended easily to suit our needs

Servlets are secure The only way to invoke a servlet from the outside world is

through a Web server This brings a high level of security especially if the Web

server is protected behind a firewall

Servlets can be used with a variety of clients

Servlets are tightly integrated with the server This integration allows a servlet to

cooperate with the server For example a servlet can use the server to translate file

paths to perform logging and to check authorization

Servlets are quite flexible An HTTP servlet can be used to generate a complete web

page it can be added to a static page using a ltSERVLETgt tag in whatrsquos know as a

server-side include and it can be used in cooperation with any number of other

servlets to filter content in something called a servlet chain

18

Chapter 4

Design of On-line Bookstore Using Java Servlets A Practical

Verification

Server-side Java application is one of the latest technologies used to implement an onshy

line store system Servlet is a set of classes that come up from Java language It is

designed to be used for server-side Java applications There are many techniques people

can use when they utilize servlet such as Server-Side Include (SSI) Servlet Chaining

Applet and Servlet communication etc We tried to use as many such techniques as

necessary in our implementation to demonstrate the advantages of servlets

The demonstration system module is same as the one we mentioned above Figure 331

We use this module to show how such system works

The system called Tiny Book Store emulates an on-line bookstore selling computer

books It has the full functionality of other on-line stores The only difference between

this system and the other on-line systems is the database size We donrsquot want to spend

much developing time for database maintaining part because this part is similar to

ordinary database maintaining and it is an independent subsystem The Tiny Book Store

mainly consists of three modules user interface business procedure and data access

19

41 The Design of Home Page of Tiny Book Store

The home page - welcome page - is designed using the Server-Side Include technique

That is embedding a servlet inside HTML file with a specific HTML tag ltSERVLETgt

In our case this servlet when invoked can run a query on database via data access

objects to retrieve most recent top 5 best-seller books and then returns the retrieved data

to the place within the page where the ltSERVLETgt tag was As long as the data in

database update timely it is guaranteed that customer will get the most recent data

The embedded servlet is invoked by Java Web Server before the page is sent back to

client Java Web Server processes any HTML file having shtml extension and invokes

the embedded servlet marked by ltSERVLETgt tags

Server-Side Includes are useful when a page is primarily static but contains a few distinct

dynamic portions One of the servlets produces the ldquo Five Hot Books ldquo which is shown in

the following example

Example 411 A Part of Code of welcomeshtml

lt P gt

lth3xstrongxf ont color= f f 6347 gtWelcome to theltigt

TinyBookStorecomltigtltfontgtltstronggtlth3 gt

20

ltstrongxbxh3gtltcentergtFive Hot

Booksltc e n t e r x h3gtltbgtltstronggt

ltbrgt

ltservlet code=EchoServletTaggt

ltservletgt

The servlet EchoServletTag searches database according to some business rule and gets

data from data access objects to produce the Five Hot Books The following example is

the sample code

Example 412 A Part of Code of The EchoServletTagjava

public void service(HttpServletRequest req

HttpServletResponse res)

throws ServletException IOException

res setContentType ( text Jhtml)

PrintWriter out = resgetWriter()

try

Statement stmt = concreateStatement()

21

ResultSet rs = stmtexecuteQuery(select from

book where

title like Programming)

int count = 1

outprintln(ltdlgt)

while (rsnext() ampamp count lt 6)

out print In ( ltdtxbgt + count + )

String isbn =

rsgetObj ect(ISBN) toString()

outprintln(lta

href=servletDetailContent + isbn +

outprintln(rsgetObj ect(Title) toString()

+ lt a x bgt )

out println ( ltddxnobrxfont color=990033gtUsuallY

ships in 24 hoursltBRxfontxnobrgt )

outprintIn(ltbrgt +

rsgetObject(Author) toString() )

outprintIn( +

r s getObject(Publisher)toString() + +

r s getObj ect(PublicationDate) toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

out println ltbrxbrgt )

22

count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()

The servelt EchoServletTag by the business mle that searching a specific table sends a

request query through data access object stmt and gets search result through another

data access object rs It then passes data to the page The content between ltservletgt and

ltservletgt tags in the HTML of home page is replaced by the search result at run time

The center part of the sample result page in Figure 411 is an example

23

Figure 411 The Home Page of Tiny Book Store

gj Search TinybookstGiecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

^ bullgt o a 4 i a a j ugt- a a Back lt7gtn Stop Refresh Home j Search Favorites History Mail Print Etfe

-Six

sfekinlfeSsI 3 Address |iS1 httpiVlocalhosLSOSCVwelcomeshtrnl Cj

f S M B l TinyBookStorecom

Search B o o k sW e l c o m e tc f l i e

HomeFive H ot Books 1 1

Category i-si

IA uthor

Title1 The C + + Programming L a n g u a g e B

Usually ships in 114 hoursISBN

k

IPublisher D a teBjame Stroustrup Addis on-Wesley Pub Co 1997Our Price 3147

m2 Programming Visual C+ +

Usually ships in 24 hours y

David J Krn^dinski Dlicrosoft Press 1998 c damp Local intranet

From this practice we know Server-Side Include not only can produce dynamic portion

of the page but also prevent from other people spy into your code Since Java servlet runs

entirely on a server thus protecting your intellectual property and shielding you from the

browser This means what the client sees can be totally different from what the server

does From the client side it is difficult to figure out how the server works

The left-hand menu items are implemented by using a characteristic of servlet - extra

path information or virtual path The extra path information can be used as a kind of

parameter passed to a servlet In general this extra path information is used to indicate a

24

file on the server that should use for something We use this feature here in an abnormal

way to manage customer requests and process these requests in a single place

Consider a traditional method When a menu item is selected by a customer it redirects

the customer to another page where it hyperlinks to If we have several ten items we

need to pre-create several ten pages This is the disadvantage of static HTML pages

However with servlet which can dynamically generate page content we can direct all the

customer requests to a central servlet and process the requests there according to some

condition (parameters) and then generate the page which customer need to see In this

way we only need one place to hold the code to save serverrsquos space And this place is

easy to maintain

The following is how it was doing for the Tiny Book Store

The Author item uses the following hyperlink

ltA

href = servlet ReqCo 11 ect author gtAuthorlt fontx AxTDgt

ltTRgt

The ReqCollect is the name of a servlet We pass the ldquoauthorrdquo in the hyperlink as a

parameter to ReqCollect When the Author item is selected ReqCollect is invoked by

lava Web Server ReqCollect generates a html page to let a user input author search

condition The ReqCollect code is listed below

25

Example 413 A part of Source Code of ReqCollectjava

public class ReqCollect extends HttpServlet

protected final String AUTHOR = author

public void service(HttpServletRequest req

HttpServletResponse res) throws ServletException

IOException

PrintWriter out = resgetWriter()

String path = reqgetPathlnfo ()

if (path == null)

error handling

else

Create standard header

CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

26

path = pathsubstring(1)

if (pathequalsIgnoreCase(CATEGORY))

Create category request collect

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

outprintln(ltfont color=CC66 0 0

face-verdana arial helvetica size = + lxbgtEnter

Authorltbgtltfontgt )

outprintln(ltbrgt You can enter

authors full name first name or last nameltpgt)

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess

id=forml name=formlgt)

outprintln(lttable border=0gt)

outprintln(lttrgt lttd valign=middle

align = lef txttgtltbgtAuthor ltbxttxtdgt )

outprintln(lttd valign=middle

align = lef txinput type = text name= author size = 40

value=x tdgt )

outprintln(lttrgt)

27

outprintln(lttrgt lttd colspan=2gt ltfont

size=-lgt)

outprintln(ltcentergt ltinput

type=radio name=author_mode value=exact

checkedgt Exact Name)

outprintln(ltinput type=radio

name=author_mode value=lastgtLast First Name (or

Initial) )

outprintln(ltcentergt)

outprintln(ltfontgt)

outprintln(lttdgt lttrgt)

outprintln(lttrgt lttd colspan=2gt ltpgt

ltbrgt lttdgt lttrgt)

outprintln(lttablegt)

outprintln(ltcentergt)

outprintln(ltinput type=submit

value=Search Now id=submitl name=submitlgt)

outprintln(cinput type=reset

value=Clear Form id=resetl name=resetlxpgt )

outprintln(ltcentergt ltformgt)

Create standard footer

28

CreateFooter(out)

outflush()

outclose()

The generated page looks like this

Figure 412 One of The Searching by Author PagesTinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorite l o o k H e lp

^ 3 4 s j ] S o zdStop Refresh Home Search Favorites History Mail Print EditBack bull

I t i h f e l f f httplocalhost8080servletReqCollectauthor

S ea rch Books

Home

C a t e g o r y

Author

Title

ISBN Publisher Date

poundj

TinyBookStore com

You can enter authors foil name first name or last name

A u t h o r jbjarne

C Exact N ame amp Last First N atne (or Initial)

Search Now | Clear Form

Taw boekstofeeoraH om e | Category | A uthor | Title | IS3M | Publisher Date

jpyright and disclaimer copy 1999-2001 F ang Xiao

ihtterteti

42 Design of Search by Different Requests

29

According to different requests the different pages should be produced There are many

common parts in the produced pages So we donrsquot need to code the common parts for

each page We can design the common parts into standard utility classes or static

functions You can simply call the standard classes or functions when you needed them

An example looks like this

CreateHeader(out)

CreateLeftMenu(out)

CreateFooter(out)

The three lines above invoke the standard functions CreateHeader() CreateFooter() and

CreateLeftMenu() which are developed in this thesis writing The CreateHeader()

function produces the top part of the pages The CreateLeftMenu() function produces the

left part of the pages The Createfooter() function produces the bottom part of the pages

You can find the source code in several servlets in Appendix

43 Servlet Chaining To Process Requests In Different Levels

A request can be handled by a sequence of servlets This system is designed to use the

first level servlets to handle the search requests If needed the first level servlets can

cooperates with the second level servlets by passing their processing result to the second

level servlets and let them to proceed the request until the final result is obtained The

final result is returned by the last servlet This is called servlet chaining The request

30

from the client browser is sent to the first servlet in the chain The response from the last

servlet in the chain is returned to the browser In between the output from each servlet is

passed as an input to the next servlet Each servlet in the chain has the option to change

or extend the content W e can see the example in the ReqCollect code

Example 431 A Part of Code of The ReqCollectjava

if (pathequalsIgnoreCase(AUTHOR))

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess id=forml

name=formlgt)

The ReqCollect servlet uses the getPathInfo() method to get the extra path information

This method returns the extra path information associated with request According to the

different extra path information the first level servlet invokes the different servlet of the

second level In this case ReqCollect invokes AuthorProcess servlet The final output

has been listed in Figure 412

31

44 Database Connectivity and Search from Database

The biggest advantage for servlets with regard to database connectivity is that the servlet

life cycle allows servlets to maintain open database connections An existing connection

can trim several seconds from a response time compared to a CGI program that has to

reestablish its connection for every invocation

Another advantage of the servlets over CGI and many other technologies is that JDBC is

database-independent JDBC is a SQL-level API - one that allows you to execute SQL

statements and retrieve the results if any The API itself is a set of interfaces and classes

designed to perform action against any database

An individual database system is accessed via a specific JDBC driver that implements the

javasqlDrivers interface Drivers exist for nearly all-popular RDBMS systems The

database connection used for Tiny Book Store uses a JDBC-ODBC bridge driver coming

along with the JDK 12 to allow access to standard ODBC data source such as the

Microsoft Access database

The first step in using a JDBC driver to get a database connection involves loading the

specific driver class into the applicationrsquos Java Virtual Machine This makes the driver

available later when we need it for opening the connection An easy way to load the

driver class is to use the ClassforNameQ method

32

ClassforName(sunj dbcodbcJdbcOdbcDriver)

When the driver is loaded into memory it registers itself with the javasqlDriverManager

class as an available database driver

The next step is to ask the DriverManager class to open a connection to a given database

where the database is specified by a specified formatted URL The method used to open

the connection is DriverManagergetConnection() It returns a class that implements the

javasqlConnection interface

Connection con =

DriverManagergetConnection(j dbcodbcsomedb

user passwd)

A JDBC URL identifies an individual database in a driver-specific manner Different

drivers may need different information in the URL to specify the host database

During the call to getConnection() the DriverManager object asks each registered driver

if it recognizes the URL If a driver says yes the driver manager uses that driver to create

the Connection object Here is an example

Example 441 A Part of Code of AuthorProcessjava

public void init() throws ServletException

try

ClassforNamesunj dbcodbcJdbcOdbcDriver)

con =

DriverManagergetConnection(j dbcodbcfxbookstore null

null)

catch (ClassNotFoundException e)

catch (SQLException e)

After we got the database connection we need to have some way to execute queries The

simplest way to execute a query is to use the javasqlStatement class Statement objects

are never instantiated directly instead a program calls the createStatement() method of

Connection to obtain a new Statement object

Statement stmt = concreateStatement()

34

A query that returns data can be executed using the executeQuery() method of Statement

This method executes the statement and returns a javasqlResultSet that encapsulates the

retrieved data

Example 442 A Part of Code of AuthorProcessjava

String sqlStmt =

if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where author= + name +II i n

else

sqlStmt = select from BOOK where author like +

name +

ResultSet rs = null

Statement stmt = concreateStatement()

rs = stmtexecuteQuery(sqlStmt)

35

A ResultSet object can be thought as a representation of the query result returned one row

at a time The next() method of ResultSet is used to move from row to row The

ResultSet interface also boasts a multitude of methods designed for retrieving data from

the current row The getStringO and getObject() methods can be used for retrieving

column values

Example 443 A Part of Code of AuthorProcessjava

while (rsnextO )

count++

outprintln(ltdtgtltbgt + count + )

String isbn = rsgetObject(ISBN)toString()

outprintln(lta href=servletDetailContent + isbn +

gt )

outprintln(rsgetObj ect(Title) toString() +

ltagtltbgt)

outprintln (ltnobrxfont color=990033gtUsually ships

in 24 hoursltBRgtltfontxnobrgt)

outprintln(ltddgt +

rsgetObj ect(Author) toString() )

36

outprintln( +

rs getOb j ect ( Publisher) toString () + +

rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

outprintln(ltbrgtltbrgt)

One of the outputs of servlet AuthorProcess is show in Figure 421 and Figure 441

Figure 441 One of The Outputs of Servlet AuthorProcess

37

File Edit View Favorites lo o k - Help M i

T 1 bdquo - 0 L Q 4 pound $ L L lBack r s Stop Refresh Home S earch Favorites History

A - Mail Print

Links rdquo Address | jyen j http7ocalhost808O$ervletAuthorProcess 3

Search B ooks

Home

CategoryA uthor

Title

ISBN

P u b l i sh e r D a te

Tiny Bookstore com

1 The C++ Prograitmuitg Language Usually ships in 24 hour Bjame Stroustrup Addison-Wesley Pub Co i 1997 Our Price 3147

T in yb o oks to re c om H ora e | Category | A uthor | Till | ISBN | Publisher P a t

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top of Page

gk j Local intranet

45 Session Tracking

Session Tracking is one of the most important techniques for any on-line store systems

This is because that HTTP protocol is a stateless protocol A HTTP server sees only a

series of requests and it by itself has no way to know exactly who is making the request

This means that when a customer puts a book in his shopping cart and then goes to other

pages to find more books next time when he puts another book in his shopping cart there

is no guarantee that he puts the book in the same cart It is very possible that he uses

another customerrsquos shopping cart at this time

38

To solve this problem session-tracking is introduced Traditional techniques used by

CGI include hidden form fields URL rewriting user authorization and persistent cookies

For server-side Java applications a built-in class supplied servlet can be used easily to

handle such tasks

When a user first accesses the site web server assigns a new HttpSession object and a

unique session ID to the user The session ID identifies the user and is used to match the

user with the HttpSession object in subsequent requests Usually the session ID is saved

on the client in a cookie or sent as part of a rewritten URL The Tiny Book Store uses this

technique

The Tiny Book Store is a classic shopping cart application A client can put items in his

virtual cart accumulating them until he checks out several page requests later How to

make sure a userrsquos shopping items will be put in his shopping cart or delete from his

shopping cart The Java Servlet API provide built in session tracking to handle this

problem Every user of a site is associated with a javaxservlethttpHttpSession object

that servlets can use to store or retrieve information about that user We can save any set

of arbitrary Java objects in a session object For example a userrsquos session object provides

a convenient location for a servlet to store the userrsquos shopping cart contents An example

shows below

Example 451 A Part of Code of AddToShoppingCartjava

39

1 Get current session object create one if necessary

2 HttpSession session = reqgetSession(true)

3 m_cart = (ShoppingCart)sessiongetValue(cart)

4 if (ra_cart == null) need new cart

5 create a shopping cart

6 m_cart = new ShoppingCart()

7 add to current session

8 sessionputValue(cart m_cart)

9

10

11 try

12 Statement stmt = m_concreateStatement()

13 ResultSet rs = stmtexecuteQuery(select from

book where ISBN= + isbn +)

14 if (rsnext())

15 book - new

BookDetails(rsgetObj ect(ISBN) toString()

16 rsgetObject(Title)toString()

rsgetObj ect(Authorrdquo) toString()

17 rsgetDouble(Price)

rsgetObj ect(PublicationDate) toString() )

18

40

1 9

2 0 catch (SQLException e)

21 e printStackTrace()

22

23 m_cartadd(bookgetlSBN() book)

The servlet uses its request objectrsquos getSession() method to retrieve the current

httpSession object

public HttpSession HttpServeltRequestgetSession (boolean create)

This method returns the current session associated with the user making the request If

the user has no current valid session this method creates one if create is true or return

null if create is false To ensure the session is properly maintained this method must be

called at least once before any output is written to the response Please look at the line 2

in the example 451

If you want to add data to an HttpSession object you can use the putValueQ method

public void HttpSessionputValue(String name Object value)

41

This method binds the specified object value under the specified name Any existing

binding with the same name is replaced This specifies at line 8 of the example 451

If you want to retrieve an object from a session you can use getValue() method

public Object HttpSessiongetValue(String name)

This method specified at line 3 of example 451 returns the object bound under the

specified name or null if there is no binding

From line 4 to line 9 the servlet checks whether the user already has a shopping cart If

the user didnrsquot have a shopping cart the servlet assigns a shopping cart to this user and

add the shopping cart to the current session to keep tracking The ShoppingCartjava class

is developed in this thesis writing code is provided in the appendix

From line 10 to line 21 the servlet knows the user already has a shopping cart m_con is

a data member of AddtoShoppingCart class Lines 12-13 have been discussed in the

previous section Lines 16-20 get some information of the book which the user selected

The information will be the data members of the ldquobookrdquo object that is an instance object

of BookDetailsjava class BookDetailsjava class is developed in this thesis writing the

source code is provided in the Appendix

Line 25 puts the book which is selected by the user into the shopping cart

42

Please see a set of pages are shown below

Figure 451 A Page Show All Information About A Book

TinjiRnfikStnre com - M inrnsnfl Interned Explnrpr

File Edit View Favorites Tools Help-

^ O 4 4 1 f i tStop Refresh Home I Search Favorites History Mail Print Edit

I Link gtgt Address [gl hgtplocalhos9l]IBrit-rvetDetailConetit-Ll20183l)544

S e a r c h B o o k s

Home-

C a t e g o r y

Author

Title

ISSNPublisher Pate

TinyBookStore com

The C++ Programming Languageby Bjarne Stroustrup

aISBN 0201889544 Addison-Wesley Pub Co 1997

Price 3147 Availability U sually ships within 24 hours

Add to cart

Done

R ev iew s

In tins brand-new third edition of The C + + Programming Language author Bjame Stroustrup the creator of C++ presents the full specification for the C++ language and standard library a spec that will soon become the joint ISOANSI C++ standard

g ig L o ca l in tranet

43

Figure 452 A Page Show Items In The Shopping Cart after A User Added Books To The Shopping Cart

H H I H I - I I

j File Edit View Favorites l o o k Help I f

| S ack Stop Refresh Home Search FavoritesJ V

History Wail Print

j Links Address |S1 http7localhost8O80servletAddToShoppingCart i i i i a i i i

( O ldquo ii

Shopping Cart Item s Price

An Introduction to fen e tic Algorithm sMelanie MteheU Quantity 1 Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

drle trgt

delete

delete

Price $ 2 2 0 Subtotal $ 2 2 0

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 6 7 5 6

|euro

rfuj Local intranet

44

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A Book From The Shopping Cart

^ A m a z o n c o m Shopping Cart - Microsoft Internet Explorer

- J A l 4Stop Refresh Home

gtH bdquo ] Back bdquo

httplocalhost8080servletDeleteFromShoppingCartitemgetltem()getlSBN()

Ji _J 3Search Favorites History

j - JMarl Print

~U ccdeg

Shopping Cart Item s

Core Java 2Cay S Horstrnaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d elete

delete

Price

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 4 5 5 6

rsquo0 1 Done gSsfLocat intranet

46 Check Out

This part is designed only using the HTML It collects all information from a user The

information will be written into the database

An important line in this HTML file is shown below

45

ltform method=POST

action=httplocalhost808 0servletCustomerlnfoProcessgt

This line will invoke the servlet CustomerlnfoProcess that will process all data collected

from the user This servlet will discuss in the next section The check out page shows in

Figure 461

Figure 461 A Check Out Page

M M iH M M M i M MmmrnfrnM File Edit View Favorites too ls Help

^ gt a 3 A hi -ltamp f V j HISllll mmB ack S lop R efresh H em e S earch 1 i l lie History M 1 Print Edit

^Links A ddrecs j ig ] h ltp localhostSO SO checkouth tm l i i i l a s

Custom er Information

First name (Fang

Middle initial |a

Last name [Xiao

Email address |fgtdaomitecnet

Account password Jxxxxx

C red it card num ber jl 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7

Credit card type ttV isa O BluebirdO MasterCard O Fisher

Credit card holder jFarig Xiao

Credit card expire date (tnmddyy) joi 0102 ~

Select shipping method t UPS 0 NormalO Express C Abnormal

| | ] Dorraquo raquo f j^ I o c a l intranet

47 Customer Information Processing

The customer information processing is handled by a servlet CustomerlnfoProces Its

source code is provided in the appendix

46

All information collected from the user should be written into the database therefore we

have to open a connection to a given database at first Example 461 is given for this

purpose

Example 471 A Part of Code of CustomerlnfoProcessjava

public void init() throws ServletException

try

ClassforName(sunjdbcodbcJdbcOdbcDriver)

m_con = riverManagergetConnection(jdbcodbcfxbookstore

null null)

catch (ClassNotFoundException e)

e printStackTrace()

catch (SQLException e)

e printStackTrace( )

There is a PO ST request in the check out page The servlet CustomerlnfoProcess will

handle the PO ST request by doPost function which is demonstrated in the following

example

47

Example 472 A Part of Source Code of CustomerlnfoProcessjava

public void doPost (HttpServletRequest req HttpServletResponse res)

throws ServletException IOException

ressetContentType(texthtml)

PrintWriter out = resgetWriter()

get information

String[] values = reqgetParameterValues(firstname)

if (values = null)

firstname = values[0]

values = reqgetParameterValues(middleinit)

if (values = null)

middleinit = values[0]

In the example the HttpServletRequest object res will get each data which was input by

the user by the getParameterValues() function

If the user is a returned user we donrsquot need open a new account again If the returned user

use the same credit card as previous we also donrsquot need to insert the credit card

48

information into the CREDITCARD table Otherwise we should insert all related

information into related table This is shown in the following example

Example 473 A Part of Source Code of CustomerlnfoProcessjava

Statement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where EmailAddress= +

email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext())

sql = insert into CUSTOMERACCOUNT (emailaddress password

firstname middleinit lastname) values ( + + email +

password + + firstname + + middleinit + lastname +

)

stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber= + creditcard

+

rs = stmtexecuteQuery (sql)

if (rsnext())

49

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype

HolderName ExpirationDate) values( + + creditcard + +

cardtype + + cardholder + 11 + expiredate + )

stmtexecute (sql)

All information related the books selected by the user can be obtained from the

shopping cart as shown in the following example

Example 474 A Part of Source Code of CustomerlnfoProcessjava

BookDetails book = null

ShoppingCartltern bookAndQuantity = null

Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getltems()

int aQuantity =0

String alSBN = null

while (itemshasMoreElements())

insert into Orderltems

bookAndQuantity = (ShoppingCartItem)itemsnextElement()

book = bookAndQuantitygetltem()

50

aQuantity = bookAndQuantitygetQuantity()

alSBN = book getISBN()

sql = insert into ORDERITEMS (shoppingCartID ISBN quantity)

values ( + + m_cartID + + aISBN + + aQuantity + )

stmtexecute (sql)

After all information inserted into related tables the servlet CustomerlnfoProcess will

produce invoice page The example page shows in Figure 471

51

Figure 471 An Invoice Page 3 Order List Microsoft Internet Explorer

is File Edit View Favorites Tools Help

J J J U r PS to p Refresh Hom e i -S earch Favorites History s Mai Print

Links Address iff 1 httpVlocalhostBOSOservletCustomerlnfoProcess 3

s5al Local intranet

Y ou r order reads as fo llow sE-MailAddress fiiiaomitecnet

ship to

Tel

Items

F ang Xiao12345 Western Plaza 23OmahaNE68154(402)123-4567

TitleCore Java 2Qtyl Price2579Subtotal2579

TitleJava Servlet PrograrnmingQtyl Price 1977 Sub total 1977 Total4556

i|51 D one

52

Chapter 5

Future Work

In this chapter we discuss two major problems for our future work They are the

Connection Pooling and Object-Oriented for better encapsulation

51 Connection Pooling

After we have used JDBC for a short time it will become evident that the major

performance bottleneck often comes right at the beginning when you are opening a

database connection This is because that opening a connection might involve a series of

low level communications between network protocols and database connection protocols

such as TCPIP ODBC etc

Servlet life cycle allows for extremely fast database access Servlet is loaded into Web

server only once Once it is loaded it can hold a connection to database all its life cycle

Every time it receives a request to read from or write data to database it can just use the

connection to do this

Here comes a problem however Suppose that a customer comes to the on-line store

During the period of selecting some items from the store he leaves his desktop and do

something else leaving this connection to database idling This will waste the precious

resource on the database From database port of view the connection to the database will

assign a space to hold corresponding status and to cache data For example Microsoft

SQL-Servertrade assigns about 36K bytes for each of its connection Resource on the

53

database is limited and idling connection causes such resource unable to be reused for

other users

To solve this problem we can use the technique called connection pooling Essentially a

connection pool is an object holding connections to backend database and managing the

number and status of connections For example if a connection in the pool idles over a

certain time of period the pool can terminate this connection if the requests are not the

same size of the connection pool the pool can dynamically shrink or expand the size of

itself A connection pool can run on a separate thread and is initialized when the server

starts or when a request to database is arrived

To implement a connection pool is pretty straight-forward Because of time constraint

however we did not do it in this paper and leave it as a possible future improvement

52 More Object-Oriented - Better Encapsulation

Another improvement might be done in the future is to create a HTML-related utility

class We have seen in this thesis that there are some duplicated code processing HTML

output such as ldquoout printIn ( lttbxtrgt lttrxtbgt)rdquo All these HTML-

related processes right now are used in a raw way That is they are not encapsulated A

better way to do this is to create a utility class or classes to deal with all HTML-related

processes and hide all HTML tags and format inside the class or classes For example

suppose that we create a Table class then we can use it in a way like

Table table = new Table()

54

table(somerow somecol contents)

table(somerow somecol some_image)

In this way we do not need to use HTML tags in our program and concentrate on the

programming logic The implementation is enriched with more object-oriented property

and therefore it is easy to maintain

55

Chapter 6

Conclusion

The increased awareness and popularity of the Internet make all kinds of electronic

commerce grow vigorously The most popular Web applications are the on-line stores

An on-line store system usually contains four components Web server business

procedure Database system application An on-line store system is different from web

publishing Currently there are three mainstream technologies which are widely used to

develop the on-line store systems CGI Microsoft ASP and Server-side Java application

Introducing the server-side Java application is one of the latest and most exciting trends

in Java programming We have discussed this technology in detail in this thesis The

server-side Java applications have many distinct advantages over CGI and other

technologies We present plenty of examples and figures to analysis the characteristics of

the server-side Java application

As a glance into the future electronic commerce will continue to grow driven by

purchases of home computers and other Web-enabled devices as well as new business

opportunities Electronic commerce is changing whole business procedures The future of

electronic commerce will be exciting and full of opportunities

56

APPENDIX A

Bibliography

57

[1] Karl Moss 1998 Java Servlets Mcgraw-Hill

[2] Jason Hunter William Crawford 1998 Java Servlet Programming O rsquoReilly

[3] Manoj Kumar Anand Rangachari Anant Jhingran Rakesh Mohan 1998 Sales Promitions on the Internet h ttpwwwibmcomiactech-paperhtml

[4] Manoj Kumar Stuart I Feldman 1998 Business Negotiations on the Internet httpwwwibmcomiactech-paperhtml

[5] Manoj Kumar Stuart I Feldman 1998 Internet Auction httpwwwibmcomiactech-paperhtml

[6] Shiwa Fu Jen-Yao Chung Walter Dietrich Vibby Gottemukkala Mitchell Cohen Shyhkwei Chen 1999 A Practical Approach to Web-Based Internet EDI httpwwwibmcomiacpapersicdcsws99indexhtml

[7] Zhong Tian Leo Y Liu Jing Li Jen-Yao Chung Vibby Guttemukkala 1999 Business-to-Business e-Commerce with Open Buying on the Internethttpw w w ibm comi acpapersobi -paperindex html

[8] Gerald J Tesauro Jeffrey O Kephart 1998 Foresight-Based Pricing Algorithms in an Economy os Software Agents http wwwi bm comi actech - paper html

[10] Jeffrey O Kephart James E Hanson Jakka Sairamesh 1998 Price and Niche Wars in a Free-Market Economy o f Software Agents httpwwwibmcomiactech-paperhtml

[11] Jeffrey O Kephart James E Hanson David W Levine Benjamin N Grosof Jakka Sairamesh Richard B Segal Steve R White 1998 Dynamics o f an Information-filtering Economy httpwwwibmcomiactech-paperhtml

[12] James E Hanson Jeffrey O Kephart 1998 Spontaneous Specialization in a Free-Market Economy os Agents httpwwwibmcomiactech-paperhtml

[13] Jakka Sairamesh Jeffrey O Kephart 1998 Price Dynamics o f Vertically differentiated Information Markets httpwwwibmcomiactech-paperhtml

[14] David Kosiur 1997 Understanding Electronic Commerce Microsoft Press

[15] Gunther Birznieks Selena Sol 1997 CGI fo r Commerce MampT Books - A Division of MIS Pres

58

[16] Ravi Kalakota Andrew B Whinston 1997 Electronic Commerce Addison Wesley

[17] Alex Fedorov Richard Harrison Dave Sussman Brian Francis Stephen Wood 1998 Profession Active Server Page 20 Wrox Press

[18] Calvin Austin Minica Pawlan 1999 Writing Advanced Application for the Java PlatformhttpVdeveloper iavasuncomdeveloperonlineTrainingProgrammin gJDCBooki ndexhtml

59

APPENDIX B

The Source Code of An On-Line Store System - Tiny Book Store

60

1 welcomeshtml

lthtmlgtltheadgtlttitlegtSearch Tinybookstorecomlttitlegtltheadgtltbodygt

lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=eeeeccgtlttrgtlttd rowspan=2 align=left valign=top width=15 cellspacing=0 cellpadding=0xIM G border=0 hspace=0 id=IMGl src=flowergif gtlttdgtlttd rowspan=2 align=left valign=centergtltstronggtlth2gtltigtTinyBookStorecomltigtlth2gtltstrongxtdgtlt trx tab legt

lttable border=0 width=100 cellspacing=0 cellpadding=0gtlttrgtlttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtltPgt

lttable width=100 cellspacing=0 cellpadding=5 border=0gtltTRgt ltTDgt ltTDgt ltTD colspan=2gt ltFONT FACE=verdanaarialhelvetica SIZE=-1 gtampnbsp ltFONTgt ltTDgt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD co lsp an = 2 x stro n g x fo n t face=verdanaarialhelvetica size=-lgtSearch B ooksltfontxstronggt ltTDgt ltTRgtltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt ltTD x f o n t face=verdanaarialhelvetica size=-l gt

lta href=w elcom eshtm lgtH om eltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt c T D x fo n t face=verdanaarialhelvetica size=-1 gt

lt A href= servletReqC ol 1 ec tc ategory gtC ate gory ltf o n tx A x T D gtltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollectauthorgtA uthorltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollecttitlengtTitleltorfo n tx A x T D gt ltTRgt

61

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectisbngtISBN ltA xfontxTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectpublisher_dategtPublisherD a telt A x fo n tx T D gtltTRgtlt tab lex p gtlttdgt

lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgtlttd valign=top align=leftgt

ltbr clear=allgtltPgtlt h 3 x s tro n g x fo n t color=ff6347gtWelcome to theltigt T in y B o o k S to rex o m lt ix fo n tx s tro n g x h 3 gt

ltbrgtlt s tro n g x b x h 3 x c e n te rgt F iv e Hot B o o k slt cen te rx h 3 x B x s tro n g gt

ltbrgtltservlet code=EchoServetTag myArgI=myValuel myArg2=myValue2gt ltparam name=myParm 1 value=Hellogtltparam name=myParml value=Worldgtltparam name=myParm2 value=myParmValue2gtltservletgt

lt td x trgt

lttablegt

ltTABLE width=100gtltTRgt ltTD width=50 valign=top align=Ieftgt ltTDgtltTD width=50 valign=top align=rightgtltfont size=-lgtltA href=topgtTop of P ag elt A x fo n tx T D gt ltTRgt

62

ltTABLEgt

ltcentergtltfont size=-lgtltA href=indexhtml gtTinybookstorecom HomeltAgt ampnbsplampnbsp ltA href=categoryhtml gtCategoryltAgt ampnbsplampnbspltA href= author html gtAuthorltAgt ampnbsplampnbspltA href= title html gtTitleltAgt ampnbsplampnbspltA href=7isbnhtml gtISBNltAgt ampnbsplampnbspltA href=publisherhtmrgtPublisher DateltAgtltpgtltfontgtltcentergt

ltPgtltcentergtlt b rx fo n t size=-lgtltA href=copyrighthtml gtCopyright and disclaimerltAgt copy 1999-2001 Fang Xiao ltfontgtltcentergt

ltbodygtlthtmlgt

63

2 AddToShoppingCartjava

ltpgt AddToShoppingCart is the servlet that process the action of adding item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javasql import javautil import javaxservlet import javaxservlethttp

public class AddToShoppingCart extends HttpServlet

protected Connection m_con = null protected ShoppingCart m_cart protected BookDetails book

public void initQ throws ServletException try

Class forName( sunj dbc odbc JdbcOdbcDriver)m_con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintstackTrace ()catch (SQLException e)

e prints tackT race ()

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

String[] params = reqgetParameterValues(isbn)

64

String isbn = get isbn from extra path infomationif (params = null)

isbn = params [0]

Get current session object create one if necessary HttpSession session = reqgetSession(true) m_cart = (ShoppingCart)sessiongetValue(cart)

if (m_cart == null) need new cart create a shopping cart m_cart = new ShoppingCart() add to current session sessionputValue(cart m_cart)

try Statement stmt = m_concreateStatement()ResultSet rs = stmtexecuteQuery(select from book where

ISBN=rsquo + isbn + rsquo)

if (rsnext()) book = new BookDetails(rsgetObject(ISBN)toString()

rsgetObject(TitIe)toStringOrsgetObject( Author) toStringO

rsgetDouble( Price) rs getObj ect( PublicationDate) toStringO)

catch (SQLException e)

eprintStackTrace()m_cartadd(bookgetISBN() book)

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lt h tm lxheadx titlegt T inyB ookS tore com S hopping

Cartlttitlexheadgt)outprintln(ltbody bgcolor=FFFFFF lmk=003399

alink=FF9933 vlink=996633 text=000000ngt)outprintln(lta nam e= topxmdashTop of Pagemdashx a gt )

65

outprin tln(ltpxa href=httplocalhost8080checkouthtmlximg src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=cccc99 gt)ou tp rin tln (lt tdxbrx tdgt )ou tp rin tln (lt tdxbrx tdgt )o u tp rin tln (lt tdxbrx tdgt )outprintln(lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=2xfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=left valign=topxfont

face=verdanaaria lhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=cccc99gt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lt td x b rx td gt ) outprintln(lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantityQ

outprintln(lttr bgcolor=FFFFFFgt) ou tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt )outprintln(ltbrgt + item getltem() get Author()) outprintln(ltbrgtQuantity + itemgetQuantityO) outprintln( ltbrgt) outprintln(lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=POST

action=7servletDeleteFromShoppingCartitemgetItem()getISBN()gt)

66

outprintln(ltpgt cinput type=hidden name=isbn value= + itemgetItem()getISBN())

outprintln(ltpgt ltinput type=submit name=ditemvalue=deletegt)

outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelve tica color=000000gt)

outprintln(ltNOBRgtltbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fon tx bx N O B R gt ltbrgt )

outprintln(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantity() + lt fo n tx b x N O B R x b rgt )

outprintln(ltfontgt) out println( lttdgt)

out printl n( lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)out println( lt fo n tx fo n tgt )outprintln(lttdxtrgt)outprintln(lttablegt)outprin tln(ltpxa href=httplocalhost8080checkouthtmlYximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)outprintln(ltbodygt lthtmlgt)

outflush()outclose()

67

3 AuthorProcessjava

bull ltpgt AuthorProcessbull This is the servlet that process the Author-search request and generatebull search resultbull Author Fang Xiao Purpose Thesis project Copyrightcopy Fang Xiao 1999-2001

import javaxservlet import jav ax servlet http import javaio import javasql

public class AuthorProcess extends HttpServlet protected final String EXACT = ldquoexactrdquo protected final String OTHERS = ldquolastrdquo

protected Connection con = null

public void init() throws ServletException try

ClassforName(ldquosunjdbcodbcJdbcOdbcDriverrdquo)con = DriverManagergetConnection(ldquojdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(ldquotexthtmlrdquo)PrintWriter out = resgetWriterQ

68

String[] valuesString name =

values = reqgetParameterValues(ldquoauthorrdquo) if (values = null)

name = values [0]

String mode = ldquordquovalues = reqgetParameterValues(ldquoauthor_moderdquo) if (values = null)

mode = values [0]

String sqlStmt = ldquordquo if (modeequalsIgnoreCase(EXACT))

sqlStmt = ldquoselect from BOOK where author=rsquordquo + name +else

sqlStmt = ldquoselect from BOOK where author like lsquordquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

ldquoYour Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ldquoltdlgtrdquo) 11 start Glossary List

while (rsnext()) count++outprintln(ldquolt d tx b gt rdquo + count + ldquo ldquo)String isbn = rsgetObject(ldquoISBNrdquo)toString()

69

outprintln(ldquolta href=servletDetailContentrdquo + isbn+

outprintln(rsgetObject(ldquoTitlerdquo)toString() +ldquolt a x b gt rdquo)

outprintln(ldquolt n o b rx fo n t color=990033gtUsually ships in 24 h o u rslt B R x fo n tx n o b rgt rdquo)

outprintln(ldquoltddgtrdquo +rsgetObject(ldquoAuthorrdquo)toString())

outprintln(ldquo ldquo +rsgetObject(ldquoPublisherrdquo)toString() + ldquo ldquo + rsgetObject(ldquoPublicationDaterdquo)toString())

outprintln(ldquoltbrgt Our Price ldquo +rsgetObject(ldquoPrice)toString())

outprintln(ldquolt b rx b rgt rdquo)

if (count == 0) outprintln(ldquoltdtgt No matched data foundrdquo)

outprintln(ldquoltdlgtrdquo) end Glossary List

catch (SQLException e) create footer here outprintln(ldquolttdgt lttrgtrdquo) outprintln(ldquolttablegtrdquo)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(ldquolthtmlgtrdquo) outprintln(ldquoltheadgtrdquo) outprintln(ldquolttitlegt TinyBookStorecom lttitlegtrdquo) outprintln(ldquoltheadgtrdquo)

outprintln(ldquoltbodygtrdquo)

70

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspacing=0 cellpadding=0 bgcolor=rdquoEEEECCYrsquogtrdquo)

outprintln(ldquolttrgtrdquo)outprintln(ldquolttd align=left valign=top width=90 gtrdquo) outprintln(ldquoltIMG border=0 hspace=0 id=IMGl

src=rdquodJavaWebServer20public_htmlflowergifrdquogtlttdgtrdquo) outprintln (ldquolttd width=30gtlttdgtrsquorsquo) outprintln(ldquolttd align=left valign=center width=300gtrdquo)

outprintln(ldquolt stro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x s tro n g x td gt rdquo) outprintln(ldquolttd align=right valign=centergtrdquo) outprintln(ldquolttdgtrdquo) outprintln(ldquolttd w id th= 20x tdgt rdquo) out pri ntln (ldquolttrgtrsquo rsquo) outprintln(ldquolttablegtrdquo)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ldquolttable width= 100gtrdquo)outprintln(ldquolttrgt lttd width=50 valign=top align=leftgt lttdgtrdquo) outprintln(ldquolttd width=50 valign=top align=rightgtrdquo) outprintln(ldquoltfont s iz e = - lx a href=rdquotoprdquogtTop of P agelt ax fon tgt rdquo) outprintln(ldquolttrgtrdquo) outprintln(ldquolttablegtrdquo)

outprintln(ldquoltcentergtrdquo) outprintln(ldquoltfont size=-lgtrdquo) outprintln(ldquolta

href=rdquohttplocalhost 8080welcomeshtmlrdquogtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080$ervletReqCollectcategoryrdquogtCategoryltagtampnbsplampnbsprdquo)

outprintln(ldquoltahref=Yhttplocalhost8080servletReqCollectauthorrdquogtAuthorltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_daterdquogtPublisheramp44Dateltagtrdquo)

outprintln(ldquoltpgtrdquo)

71

outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltpgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquolt b rx fo n t size=-lgtrdquo)outprintln(ldquoltA href=Y7copyrighthtmlrdquogtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiaordquo)outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltbodygtrdquo) outprintln(ldquolthtmlgtrdquo)

i

protected void CreateLeftMenu(PrintWriter out) System out println(ldquoLeftMenurdquo)

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspaeing=0 cellpadding=0gtrdquo)

outprintln(ldquolttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtrdquo)

outprintln(ldquoltpgtrdquo)

outprintln(ldquolttable width=rdquo 100rdquo cellspaeing=0 cellpadding=5border=0gtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquoltfont face=verdanaarialhelvetica SIZE=rdquo- l rdquogtampnbsp

ltfontgtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquolt strongxfon t face=verdanaarialhelvetica size=rdquo-

1 rdquogtSearch B ooksltfontxstronggtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd ldquo) outprintln(ldquoltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080welcomeshtmlYgt H o m elt fo n tx ax td gt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=rdquo-1rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080servletReqColIectcategoryrdquogt C ateg o ry lt fo n tx ax td gtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

72

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectauthorrdquogtAuthorltfontgtltagtlttdgtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width-2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l W rsquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltfontgtltagtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo-lYgtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_dateVrsquogtPublisher Dateltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolt tab lex p gt rdquo)

outprintln(lsquolsquolttdgtrdquo)outprintln(ldquolttd rowspan=4 width=5gtampnbspampnbspltbrgtlttdgtrdquo) outprintln(ldquolttd valign=top align=leftgtrdquo) outprintln(ldquoltbr clear=allgtrdquo)

73

4 BookTeatailsjava

ltpgt This is the class describing a book item in shopping cart

Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class BookDetails private String m_isbn = null private String m_title = null private String m_author = null private double m_price = 00 private String m_year = null

public BookDetails(String isbn String title String author double price String year)

thism_isbn = isbn thism_title = title thism_author = author thism_price = price thism_year = year

public String getISBN() return m_isbn

public String getTitle() return m_title

public String getAuthor() return m_author

public double getPrice() return m_price

ipublic String getYearQ

return m_year

75

5 CategoryProcessjava

ltpgt CategoryProcess This is the servlet that process the Category-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql import javautil

public class CategoryProcess extends FlttpServlet protected final String EXACT = exactprotected final String OTF1ERS = last

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

76

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentType( texthtml)Print Writer out = resgetWriterQ

String[] values String name = String sqlStmt =

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

else

path = pathsubstring(l) if (pathequalsIgnoreCase(cO 1))

sqlStmt = select from BOOK wherecategoryid=rsquo + cOl +

else if (pathequalsIgnoreCase(c02))sqlStmt = select from BOOK where

categoryid=rsquo + c02 +else if (pathequalsIgnoreCase(c03))

sqlStmt = select from BOOK wherecategoryid=rsquo + c03 +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftM enu(out)

Your Book Search Results try

77

if (con = null) Statement stmt = concreateStatement() rs = stmt executeQuery (sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn

+outprintln(rsgetObject(Title)toString() +

lt ax bgt )outprintln(ltnobrxfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltddgt +

rsgetObject( Author)toStringO)outprintln( +

rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)outprintln(ltbrgt Our Price +

rsgetObject( Price) toStringO) ltfont color=990000gtYou Save $1100

(20)ltfontgtoutprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

78

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)out println( lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20publicbdquohtmlflowergifgtlttdgt) outprintln(lttd width=3 0gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln( lt s tro n g x h 2 x igt T inyB ookS to re com lt ix h2x s tro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlngtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

79

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYrsquogtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln( ltfontgt)outprintln(ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rOwspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt)

outprintln(lttablewidth= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=Y2Ygt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y-1 Yrsquogtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2Yrsquogt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=Y-

lYrsquogtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=Y-lYgt)

80

outprintln(ltahref=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqColIectcategorygtCategoryltfontxagtlttdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(nltahref=httplocalhost8080servletReqCollectauthorVrsquogt A u th o rlt fo n tx ax td gtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httpIocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

6 CustomerlnfoProcessjava

ltpgt CustomerlnfoProcessThis servlet is responsible to process userrsquos information when heshe check out

Author Fang Xiao

Purpose Thesis projectCopyright (C) Fang Xiao 1999-2001

import javasql import javaio import j avau til import javaxservlet import javaxservlethttp

public class CustomerlnfoProcess extends HttpServlet protected Connection m_con = null protected HttpSession m_session = null protected static int m_cartID = 1 protected String firstname =protected String middleinit =protected String lastname =protected String email =protected String password =protected String creditcard =protected String cardtype =protected String cardholder =protected String expiredate =protected String shipping =protected String receiver =protected String address =protected String city =protected String state =protected String zipcode =protected String phone =

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)

82

m_con = DriverManagergetConnection(jdbcodbcfxbookstorenull null)

catch (ClassNotFoundException e)

eprintStackTrace()catch (SQLException e)

eprintStackTrace()i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

get informationString[] values = reqgetParameterValues(firstname) if (values = null)

firstname = values [0]

values = reqgetParameterValues(middleinit) if (values = null)

middleinit = values [0]

values = reqgetParameterValues(lastnameM) if (values = null)

lastname = values [0]

values = reqgetParameterValues(email) if (values = null)

email = values [0]

values = reqgetParameterValues(password) if (values = null)

password = values [0]

values = reqgetParameterValues(creditcard)

if (values = null) (creditcard = values [0]

values = reqgetParameterValues(cardtype) if (values = null)

cardtype = values [0]

values = reqgetParameterValues(cardholder) if (values = null) (

cardholder = values [0]

values = reqgetParameterValues(expiredate) if (values 1= null)

expiredate = values [0]

values = reqgetParameterValues(shippingrdquo) if (values = null)

shipping = values [0]

values = reqgetParameter Values (receiver) if (values = null)

receiver = values [0]

values = reqgetParameterValues(address) if (values = null)

address = values [0]

values = reqgetParameterValues(city) if (values = null) (

city = values [0])

values = reqgetParameterValues(state) if (values = null) (

state = values [0]

84

values = reqgetParameterValues(zipcode) if (values = null) (

zipcode = values [0]

values = reqgetParameterValues(phone) if (values = null)

phone = values[0]i

get session object m_session = reqgetSessionQ

try update databaseStatement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where Email Address=rsquo + email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext()) Systemoutprintln(insert customeraccount)

sql = insert into CUSTOMERACCOUNT (emailaddress password firstname middleinit lastname) values ( +

+ email + + password + + firstname +V + middleinit + + lastname + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber=rsquo +creditcard +

rs = stmtexecuteQuery (sql)

if (rsnext()) Systemoutprintln(insert creditcart)

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype HolderName ExpirationDate) values( +

+ creditcard + + cardtype + +cardholder + + expiredate + rdquo)

Systemoutprintln(sql)stmtexecute (sql)

i

85

sql = insert into SHOPPINGCART (ShoppingCartIDEmail Address CreditCardNumber ShippingType ReceiverName ReceiverAddress ReceiverCity ReceiverState ReceiverZipcode ReceiverPhone) values ( + m_cartID + V + email + Vrdquo +

creditcard + V + shipping + + receiver ++ address + V +

city + V + state + V + zipcode + V + phone +gt gt

Systemoutprintln(sql)stmtexecute (sql)

BookDetails book = nullShoppingCartltem bookAndQuantity = null Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

int aQuantity =0 String alSBN = null

while (itemshasMoreElementsO) insert into Orderltems bookAndQuantity =

(ShoppingCartItem)itemsnextElement()book = bookAndQuantitygetItem()

aQuantity = bookAndQuantitygetQuantity() alSBN - book getISBN()

Systemoutprintln(insert Orderltems)sql = insert into ORDERITEMS (shoppingCartED ISBN

quantity) values ( + m_cartID + +alSBN + + aQuantity + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

im_cartID++ must increase by one

86

catch (SQLException e) eprintS tackTrace()

printOrder(out)

public void printOrder(PrintWriter out) outprintln( lthtmlgt ltheadgt lttitlegt Order List lttitlegt ltheadgt) outprintln( ltbodygt)outprintln(lthlgt Your order reads as follows lthlgt)outprintln(lttablegt)outprintln( lttrgt)outprintln( lttdgtE-Mail Addres s lttdgt) outprintln(lttdgt+ em ail+lttdxtrgt) outprintln(lttrgt) outprintln(lttdgtship tolttdgt) outprintln(lttdgt+ receiver +ltbrgt) outprintln(address +ltbrgt) outprintln(city +ltbrgt) outprintln(state +ltbrgt) outprintln(zipcode + lt b rx td x trgt ) outprintln(lttrgt) outprintln( lttdgtTel lttdgt) outprintln(lttdgt+ phone +lttdxtrgt) outprintln(lttrgt) outprintln( lttdgtItems lttdgt)

BookDetails book = nullShoppingCartltem bookAndQuantity = nullEnumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

double total = 00

while (itemshasMoreElements()) bookAndQuantity = (ShoppingCartItem)itemsnextElement()

total += bookAndQuantitygetItem()getPrice() bookAndQuantitygetQuantityO

book = bookAndQuantitygetltem()

87

outprintln(lttdgtTitle+ bookgetTitle() + Qty + bookAndQuantitygetQuantity() + ltbrgt)

outprintln(Price + bookgetPrice() + Subtotal + bookAndQuantitygetQuantityO bookgetPrice() +ltbrgt)

outprintln(Total + total )outprintln(lttdxtrgt)outprintln(lttablegt)outflush()outclose()

7 DeleteFromShoppingCartjava

ltpgt DeleteFromShoppingCart is the servlet that process the action of deleting item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javautil import javaxservlet imp ort j avax servlet http

public class DeleteFromShoppingCart extends HttpServlet

protected ShoppingCart m_cart protected BookDetails book

public void doPost(HttpServletRequest req FIttpServletResponse res) throws ServletException IOException res setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String[] params = reqgetParameterValues(isbnrsquo) String isbn = get isbn hidden fieldif (params = null)

isbn = params [0]

Systemoutprintlnfisbn = + isbn)

Get current session objectHttpSession session = reqgetSession()m_cart = (ShoppingCart)sessiongetValue(carf)

m_cartremove(isbn)

89

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lthtm lgtltheadxtitlegtAm azoncom Shopping

C artlt titlexheadgt)out pri ntln ( ltb ody bgcolor=FFFFFF link=003399

alink=FF9933 vlink=Yrsquo996633Y text=rdquo000000rdquogtrdquo)outprintln(lta nam e= top xmdashTop of Pagemdashx a gt ) ou tp rin tln (lt pxa href=httplocalhost8080checkouthtmlximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=Yrsquocccc99Yrsquo gt)ou tp rin tln (lt tdxbrx tdgt )out pri ntln ( lt td x b r x td gt )outprintln( lt td x b r x td gt )out println (rsquo1 lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=Y2Yxfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=YleftY valign=YtopYxfont

face=verdanaarialhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=Ycccc99Yrsquogt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantity()

outprintln(lttr bgcolor=FFFFFFgt) o u tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt)outprintln(ltbrgt + itemgetItem()getAuthor())

90

outprintln(ltbrgtQuantity + itemgetQuantityO)outprintln(ltbrgt)outprintln( lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=VPOST

action=7servletDeleteFromShoppingCartVgt)outprintln(ltpgt ltinput type=hidden name=isbn value= +

itemgetItem()getISBN())outprintln(ltpgt cinput type=submit name=ditem

value=Y rsquo deletegt rsquo rsquo)outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelvetica color=000000gt)

outprintln(ltNOBRxbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fo n tx b x N O B R x b rgt )

outprintin(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantityO + lt fo n tx b x N O B R x b rgt )

outprintln( ltfontgt) outprintln( lttdgt)

i

outprintln(lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)outprintln(ltfontxfontgt)outprintln( lt td x trgt ) outprintln(lttablegt)ou tp rin tln (lt pxa href=Yhttplocalhost8080checkouthtmlYximg

src=YdYJavaWebServer20servletsimageproceed-to-checkoutgifYxagt)outprintln(ltbodygt lthtmlgt)

outflushOoutcloseQ

91

8 Detailcontentjava

ltpgt DetailContent is the servlet responsible for generating detailed information page for a book The book is identified by its ISBN Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaio import javasql import jav ax servlet import javaxservlethttp

public class DetailContent extends FIttpServlet protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String isbn = reqgetPathInfo()isbn = isbnsubstring(l) skip over rsquo rsquo

92

try String sql = select from book where ISBN=rsquo + isbn +

Statement stmt = concreateStatement()ResultSet rs = stmtexecuteQuery(sql)

create header here CreateHeader(out)

create left menu here CreateLeftMenu(out)

outprintlnfctd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintlnfctd valign=top align=leftgt)

cellpadding=0gt)

outprintln(ltbrgt)

create detailcontent here while (rsnext())

String strlSBN = rsgetObject(ISBN)toString() outprintln(lttable width=100 border=0 cellspacing=0

+ltbgtlttdxtrgt)

+ lt tdx trgt)

outprintln(lttrgt lttd colspan=3 align=leftxbgt) outprintln( rsgetObject(Title)toString()

outprin tln(lt trxtd colspan=3 align= leftxbgt by ltbgt) out println( rs getObj ec t( Author) toS tringQ

cellpadding=0gt)

outprin tln(lt trx td x i m g src=xtdgt) outprintln( lttd valign=topgt) outprintln( lttable border=0 cellspacing=0

outprintln( lt t r x td valign=topxbgtPrice )outprintln(

rsgetObject(Price)toString() + lt b x td x trgt ) outprintln(

lt trx td x b gt A v ailab ility lt b gt U su a lly lt td x trx b rgt )outprintln( lt t r x td vlign=topgtships within 24

hou rs lt td x trgt )outprintln( lt tab lextdgt)

93

outprintln( lttd align=rightgt) outprintln( lttable border=0 cellspacing=0

cellpadding=0gt)outprintln( lt trx td gt )outprintln( ltform

method=POST action=httplocalhost8080servletAddToShoppingCartgt)outprintln( ltinput

type=hidden name=isbn value= + strlSBN +outprintln( cinput

type=submit value=Add to cart )outprintln( lt tdx trgt )

outprintln( lt tab lex tdgt ) outprintln(rdquolttrgt)outprintln(lttrgt lttd clospan=3 align=leftgt ISBN ) outprintln( strlSBN +lttdxtrgt)outprintln(lttrgt lttd clospan=3 align=leftgt) outprintln( rsgetObject(Publisher)toString()

+rsgetObject(PublicationDate)toString() + lt tdx trgt )outprintln(lttablegt)outprintln(ltbrgt)outprintln(ltbrgt)

output reviewString review = rsgetObject(BookReview)toString() if (review = null)

review =DJavaWebServer20servletsreview + review

outprintln(ltbgtReviewsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(review))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprin tin (thisLine) ou t println( ltpgt)

)

icatch (IOException e)

need do something here eprintstackTrace ()

94

outprintln(ltbrgt)String comment =

rsgetObject(BookComment)toString()if (comment = null) comment = DJavaWebServer20servletscomment +

commentoutprintln(ltbgtReader Commentsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(comment))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprintln(thisLine) outprintln(ltpgt)

catch (IOException e)

need do something here eprintstackTrace ()

ou t pri ntln ( ltb rgt)

catch (SQLException e)

need to do something here

add table end tab outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt)

95

ou t pri ntln ( lthe adgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=YTOO cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d J avaW eb S erver 2 Opublic_htmlflo wer gif gtlttdgt) outprintln(lttd width=30gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyBookStorecomltigtlth2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln( lttd width=20gtlttdgt) out pri ntln ( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-1 gt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

96

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsptampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out prin tin ( ltcen tergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

eellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=Yhttplocalhost8080Avelcom eshtm lgtHom eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-1gt)

97

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=http7localhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref-httpIocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lVgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

98

9 EchoServlettagjava

import javaio import j avasql import javaxservlet import javaxservlethttp

public class EchoServletTag extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintStackTrace ()catch (SQLException e)

eprintStackTrace()

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

try Statement stmt = concreateStatementQResultSet rs = stmtexecuteQuery(select from book where title

like rsquoProgrammingrsquo)int count = 1outprintln(ltdlgt)while (rsnext() ampamp count lt 6)

outprintln(ltdtxbgt + count + )

99

String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn + outprintln(rsgetObject(Title)toString() + lt ax bgt ) outprintln(ltddxnobrgtltfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltbrgt + rs getObject( Author) toStringO) outprintln( + rsgetObject(Publisher)toStringO +

+ rsgetObject(PublicationDate)toStringO)outprintIn(ltbrgt Our Price +

rsgetObject(Price)-toStringO)

out println( lt b rx b rgt ) count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()outprintln(lttdgt lttrgt) outprintln(lttablegt) outflush() outcloseO

ii

100

10 ISBNProcessjava

ltpgt ISBNProcess This is the servlet that process the ISBN-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javax servlet import javaxservlethttp import javaio import j a vasql

public class ISBNProcess extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forN ame( sun j dbc odbc J dbcOdbcDri ver)con = DriverManagergetConnection(j dbc odbc fxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s s e tC on te n tTy pe ( tex th tm l)PrintWriter out = resgetWriter()

String[] values

String alSBN =

values = reqgetParameterValues(isbn) if (values = null)

alSBN = values [0]

String sqlStmt = select from BOOK where ISBN= + alSBN

ResultSet rs = null int count = 0

create header here bullCreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject( IS BN) toStringO

outprintln(lta href=servletDetailContent + isbn+ gt)

outprintln(rsgetObject(Title)toStringO +lt ax bgt )

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toStringO)

outprintln( +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

102

outprintln(ltbrgt Our Price +rsgetObject(rdquoPrice) toStringO)

outprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width= 100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d Uava WebS erver2 Opubhc_htmlflo wer gif gtlttdgt) outprintln(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS tore com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt)

103

out println( lttdgt) outprintln(lttd w id th= 20x tdgt ) out pri ntln( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)out pri ntln (lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) out pri ntln ( lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsp1ampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out println( ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

104

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 eellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Books lt fontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocaihost8080servletReqCollectcategorygtCategoryltfontxaxtdgt lttr gt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

105

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lttablegtltpgt)

o u t println( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

ii

106

11 PublisherDataProcessjava

ltpgt AuthorProcess This is the servlet that process the PublisherampDate-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql

public class PublisherDateProcess extends FIttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbc odbc JdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentT ype ( texthtml)PrintWriter out = resgetWriterQ

String[] valuesString namel =

107

values = reqgetParameterValues(publisher) if (values = null)

nam el = values [0]

String name2 =values = reqgetParameterValues(rdquopublication_date) if (values = null)

name2 = values [0]

String sqlStmt =sqlStmt = select from BOOK where publisher=rsquo + namel + rsquoand

publicationdate=rsquo +name2

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprin tln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toStringO outprintln(lta href=servletDetailContent + isbn

+ gt)outprintln(rsgetObject(Title)toString() + (

lt ax bgt )

108

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rs getObj ect( Author) toS tring())

outprintln(V +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

outprintln(ltbrgt Our Price +rsgetObject( Price) toStringO)

outprintln( lt b rx b rgt )

if (count == 0) (outprintln(ltdtgt No matched data found)

outprintln(rdquoltdlgt) end Glossary List

catch (SQLException e) ( create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 celipadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt)

109

outprintln(ltIMG border=0 hspace=0 id=IM Gl src=dJavaW ebServer20public_htmlflowergifxtdgt)

outprintln(lttd width=3 0 x td gt ) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS to re com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ctable w idths 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt) outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) ou t println( ltcentergt)

no

outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaim er^A gt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) out pri ntln ( lthtml gt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-1 gtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=V-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-1gt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

I l l

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitleYrsquogt T itle lt fo n tx a x td gt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(nltahref=Yhttplocalhost8080servletReqCollectisbnY gtISBNltaxfontxtdgt lttrgt)

outprindn(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdana arial helvetica size=Y -1 gt)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYgtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

1 12

12 ReqCollectjava

ltpgt This is a servlet responsible for generating search request collection page It read extra path information from URL and then according to the extra path information it generates corresponding page format Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001import javaxservlet import javaxservlethttp import javautil import javaio

public class ReqCollect extends HttpServlet

protected final String CATEGORY = categoryrdquo protected final String AUTHOR = author protected final String TITLE = titlerdquo protected final String ISBN = isbnprotected final String PUBLISHER_DATE = publisher_date

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentType( texthtml)PrintWriter out = resgetWriter()

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

)else

Create standard header CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

path = pathsubstring(l) if (pathequalsIgnoreCase(CATEGORY))

I I Create category request collect

outprintln(ltpgt)outprintln(lth3xstronggtProgrammingltstronggtlth3gt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc01gtAlgorithmsltagt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc02gtCampC++ltagt)outprintln( Delphi) outprintln(lta

href=httplocalhost8080servletCategoryProcessc03gtJavaltagt)outprintln( MFC Perl)

outprintln(software Design UML Visual Basic More)

outprintln(lth3xstronggtW eb Developm entltstrongxh3gt) outprintln(ASP Commercem Cyberculture HTML

JavaScript)

outprintln(Security Web Design XML more)

outprintln(lth3xstronggtGraphics amp Softwareltstrongxh3gt) outprintln(Asobe CAD Desktop Publishing Graphics)

outprintln(Microsoft More)

outprintln(lth3xstronggtNetW orking amp O Sltstrongxh3gt) outprintln(Linux Macs Oracle PCs SAp R3 SQL)

outprintln(TCPIP Unix WindowsampDOS W indowsNT)

out println( More)

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

1 14

outprintln(ltfont color-CC6600 face=verdana arial helvetic a size=+1 gtltbgtEnter Authorltbgtltfontgt)

outprintln(ltbrgt You can enter authorrsquos full name firstname or last nameltpgt)

outprintln(ltform method=POST action=httplocalhost 8080servletAuthorProcessY id=form 1 name=form 1 gt)

outprintln( lttable border=0gt) outprintln(lttrgt lttd valign=middle

ahgn= leftx ttx b gt A u th o rlt b gt lt ttx td gt )outprintln(lttd valign=middle align= leftx input

type=YtextY name=author size=40 value=YYxtdgt)outprintln(lttrgt)outprintln(lttrgt lttd colspan=2gt ltfont size=-lgt) outprintln(ltcentergt ltinput type=radio

name=Yauthor_modeY value=YexactY checkedgt Exact Name)outprintln(ltinput type=radio name=author_mode

value=lastgtLast First Name (or Initial))outprintln(ltcentergt) outprintln(ltfontgt) outprintln(lttdgt lttrgt)outprintln(lttrgt lttd colspan=2gt ltpgt ltbrgt lttdgt lttrgt)outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search NowY

id=submitl name=submitlgt)outprintln(cinput type=reset value=YClear Form

id=resetl nam e= rese tlxpgt )outprintln(ltcentergt ltformgt)

else if (pathequalsIgnoreCase(TITLE))

Create title request collect

outprintln(ltfont color=CC6600 face=verdanaarialhelvetica s ize= + lxbgt E n ter T itlelt bxfontgt)lsquo

outprintln(ltbrgtYou can enter the exact title or part oftitleltPgt)

outprintln(ltform method=YPOSTY action=Yhttplocalhost8080servletTitleProcessY id=form l name=formlgt)

outprintln(lttable border=0gt) outprintln(lt trxtd valign=middle

a lig n = le ftx ttx b gt T itle lt b x t tx td gt )

115

outprintln(lttd valign=middle align= leftx input type=text name=title size=40 value=xtdgt)

outprintln(lttrgt) outprintln(lttrgt) outprintln( lttd colspan=2gt) outprintln( ltfont size=-lgt) outprintln( ltcentergt)outprintln( ltinput type=radio name=title-mode

outprintln(value=exact checkedgt) outprintln( Exact Title)outprintln( ltinput type=radio name=title-mode

outprintln( value=titlewords gt ) outprintln( Title Words )outprintln(ltcentergt ltfontgt lttdgt lttrgt)outprin tln(lt trxtd c o ls p a n = 2 x p x b r x td x tr gt ) outprintln(lttablegt)

outprintln(ltcentergt)outprintln( ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln( ltinput type=reset value=Clear Form

id=resetl nam e= resetlxP gt )outprintln(ltcentergt) ou t println ( ltformgt)

outprintln(lthr noshade size=lgt)

outprintln(ltBgtExamplesltBgt)outprintln(ltULgt)outprintln(ltLIgtEntering ltbgtampquotJava Servlet

Programmingampquotltbgt in the title field )outprintln(and choosing ltemgtExact Titleltemgt finds the

book without also finding the many books)

outprintln(ltLIgtEntering ltbgtampquotJavaampquotltbgt in the Title field and choosing ltemgtTitle Wordsltemgt)

outprintln( finds all books whose title are related toltigtJavaltigt)

outprintln(ltULgt)

out printl n( lttdgtlttrgt) outprintln(lttablegt)

ielse if (pathequalsIgnoreCase(ISBN))

Create isbn request collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n ter ISBN ltbxfontgt)outprintln(ltbrgt) outprintln(ltform method=POSTY

action=httplocalhost8080servletISBNProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

a lig n = le ftx ttx b gt IS B N lt b x t tx td gt ) outprintln(lttd valign=middle a lign= leftx input

type=text name=isbn size=40 value=xtdgt)outprintln(lttrgt)

outprin tln(lt trxtd c o ls p a n = 2 x p x b rx td x trgt ) outprintln(lttablegt)

out println( ltcentergt)outprintln(ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln(ltinput type=reset value=Clear

FormV id=resetl nam e= resetlxP gt )outprintln(ltcentergt)outprintln(ltformgt)

outprintln(lthr noshade size=lgt)

outpiintln(ltULgtrdquo)outprintln(lttdxtrgt)outprintln(lttablegt)

else if (pathequalsIgnoreCase(PUBLISHER_DATE))

Create publisher date collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n te r Publisher and Publication D ate ltb gtltfontgt)

1 17

outprintln( ltbrgt) outprintln(ltform method=POST

action=httplocalhost8080servletPublisherDateProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

align=leftgtlt ttxbgt P ub lisher lt b x t t x t d gt )outprintln(lttd valign=middle align= leftx input

type=text name=publisher size=40 value=xtdgt)outprintln(lttrgt) outprintln(lttrgt lttd valign=middle

a lign= leftx ttxbgt P ub lica tion D a te lt b x ttx td gt )outprintln(lttd valign=middle align= leftx input

type=text name=publication_date size=40 value=xtdgt)outprintln(lttrgt)outprintln( c t r x td c o l s p a n = 2 x p x b r x td x t r gt )outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search Now

id=submitl name=submitlgt)outprintln(ltinput type=reset value=VClear FormYrsquo

id=resetl nam e= resetlxpgt )outprintln(ltcentergt) outprintln(ltformgt) outprintln(lthr noshade size=lgt)

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush()outclose()

)

protected void CreateHeader(PrintWriter out) outprintln(lthtmigt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding bgcolor=EEEECCgt)

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20pubiic_htmlflowergifgtlttdgt) outprindn(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(lt s tro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x stro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt)outprintln(lttd w idth=20xtdgt) ou t println ( rsquo lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

out pri ntln ( ltfon tgt) outpri ntln( ltcentergt ) out pri ntln ( ltpgt) outprintln(ltcentergt) outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)out pri ntln ( ltf on tgt) outprintln(irltcentergt) out println ( ltbodygt) out pri ntln( lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

cellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=YT00 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE= -lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

1 gtS earch B ookslt fontx stronggt)outprintln(lttdgt lttrgt)out pri ntln (lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=l-lgt)

outpri ntln(ltahref=httplocalhost8080servletReqCoilectauthorgtA uthorltfontxaxtdgtlttrgt)

120

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprindn(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=V-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln(lttablexpgt)outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

121

13 ShoppingCartjava

ltpgt This is the definition for ShoppingCart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import Javautil

public class ShoppingCart Hashtable items = null int numberOfltems = 0

public ShoppingCart() items = new Hashtable()

add BookDetails to cart param bookID isbn param book book need to be added to cart copyreturn void

public void add(String bookld BookDetails book) if(itemscontainsKey(bookId))

ShoppingCartltem scitem = (ShoppingCartltem)itemsget(bookld) scitemincrementQuantity ()

else ShoppingCartltem newltem = new ShoppingCartltem(book) itemsput(bookId newltem)

numberOftems++

param bookld isbn

public void remove(String bookld) if(itemscontainsKey(bookd))

items remove (bookld) numberOfltems - -

public Enumeration getltems() return itemselements()

protected void finalize() throws Throwable items clear()

public int getNumberOfItems() return numberOfltems

public void clear() items clear() numberOfltems = 0

123

14 ShoppingCartltemjava

ltpgt This is the definition for the shoppingcart item Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class ShoppingCartltem BookDetails item int quantity

public ShoppingCartItem(BookDetails anltem) this item = anltem this quantity = 1

public void decrementQuantity() if (quantity gt 0)

quantitymdash

public void incrementQuantity() thisquantity++

i

public BookDetails getltem() return thisitem

public int getQuantity() ( return thisquantity

i

124

15 StandardFooterjava

package servlets

import j avax servlet

ltpgt This is a server side include servlet that will format the TinyBookStore HTML footer

public class StandardFooter extends GenericServlet

ltpgtPerform the servlet service

param req The request from the client param res The response from the servlet public void service (ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the response javaioPrintW riter out = new

javaioPrintWriter(resgetOutputStream())

Format the standard footeroutprintln(ctable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(rdquoltfont s iz e = - lx a href=topgtTop of

P agelt ax fon tgt )outprintln(lttrgt) out println( lttablegt) outprintln(ltcentergt) outprintln(rsquoltfont size=-lgt)outprintln(lta href=7welcomeshtmlYgtTinybookstorecom

Homeltagt ampnbsplampnbsp)outprintln(lta href=categoryhtmlgtCategoryltagt

ampnbsplampnbsp)outprintln(lta href-authorhtmlgtAuthorltagt

ampnbsplampnbsp)outprintln(lta href=titlehtmlrdquogtTitleltagt ampnbsplampnbsp)

125

outprintln(lta href=isbnhtmlgtISBNltagt ampnbsplampnbsp) outprintln(lta href=7publisherhtmlgtPublisheramp44

Dateltagt)outprintln(ltpgt)outprintln(ltfontgt)ou t println ( ltcen tergt)outprintln(ltpgt)out println (ltcentergt )outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and

disclaim er^A gt ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln( ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

outflush()outclose()

126

16 StandardHeaderjava

package servlets

import javaxservlet

ltpgt This is a server side include servlet that will format the standard TinyBookStore HTML header The Title of the page will be set to the value of the title property

public class StandardHeader extends Generic Servlet

ltpgt Performs the servlet service param req The request from the client param res The response from the servlet

public void service(ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the responsejavaioPrintWriter out = new javaioPrintWriter(resgetOutputStream())

Get the title of the page Set to empty string if no title parameter was givenString titles[] = reqgetParameterValues(title)String title = if (titles = null)

if (titleslength gt 0) title = titles [0]

outprintln(lthtmlgt) outprintln(ltheadgt) outprintln(lttitlegt + title + lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=T00 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)

127

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src=dJavaWebS erver2 Opublic_htmlflower gi A gtlttdgt) out println(lttd width=3 O x td gt ) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyB ookStorecom ltigtlth2xstrongxtdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) out printl n ( lttd width=20gtlttdgt) out printl n( lttrgt) outprintln(lttablegt)

outflush()outclose()

128

17 TitleProcessjava

ltpgt TltleProcess This is the servlet that process the Tltle-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import j avax servlet import javaxservlethttp import javaio import j avasql

public class TitleProcess extends HttpServlet protected final String EXACT = exact protected final String OTFIERS = titleWords

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

129

String[] valuesString name =

values = reqgetParameterValues(title) if (values = null)

name = values [0]

String mode =values = reqgetParameterValues(title_mode) if (values = null)

mode = values [0]

String sqlStmt =if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where title=rdquo + name +else

sqlStmt = select from BOOK where title like rsquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString()

130

outprintln(lta href=servletDetailContent + isbn+

outprintln(rsgetObject(Title)toString() +ltagtltbgt)

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toString())

outprintln( +rsgetObject(Publisher)toString() + + rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +rsgetObject(Price)toString())

outprintln(ltbrxbrgt)i

if (count == 0) outprintln(ltdtgt No matched data found)

ioutprintln(ltdlgt) II end Glossary List

catch (SQLException e) i create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

131

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=EEEECCgt)

outprintln(rdquolttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaW ebServer20public_htmlflowergifxtdgt) outprintln(lttd w idth=30xtdgt) outprintln(rdquolttd align=left valign=center width=300gt)

outprintln(ltstronggtlth2gtltigtTinyBookStorecomltixh2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(rdquolttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln( lttrgt)outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(rdquolta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(rdquoltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

132

out println( ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) outprintln( ltcentergt) outprin tln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disciaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) S y s te m out println( LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt )

outprintln(lttable width= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y- lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost 8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

133

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lt tab lex pgt )

ou t pri ntl n ( lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

134

18 checkouthtml

lthtmlgtltheadgt lttitlegtCustomer Informationlttitlegt ltheadgtltbodygt

lt hlgt ltcentergt ltbgt Customer Information ltbgt ltcentergt lt hlgt

ltform method=POST action=httplocalhost8080servletCustomerInfoProcessgt lttable border=0gt

lttrgtlttd align=rightgtFirst namelttdgtlttd colspan=2 align= leftx input type=text name=firstname size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtMiddle initiallttdgtlttd colspan=2 align= leftx input type-text name=middleinit s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtLast namelttdgtlttd colspan=2 align= leftx input type-text name=lastname size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtEmail addresslttdgtlttd colspan=2 align= leftx input type=text name=email s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgt Account pass word lttdgtlttd colspan=2 align= leftx input type=text name=password s ize= 40x tdgt

lttrgtlttrgt

lthrgtlttrgt

lttablegtltbrgt

ctable border=0gtlttrgt

lttd align=rightgtCredit card numberlttdgtlttd colspan=2 align= leftx input type=text name=creditcard s ize= 40x tdgt

lttrgtlttr valign=topgt

135

lttd align=rightgtCredit card typelttdgtlttd align=leftgtltinput type=radio name=cardtype value=visagtVisaltbrgtltinput type=radio name=cardtype value= mastercard gtMasterCardltbrgt lttdgtlttd align=leftgtltinput type=radio name=cardtype value=bluebirdgtBluebirdltbrgtltinput type=radio name=cardtype value=fishergtFisherltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtCredit card holderlttdgtlttd colspan=2 a lign= leftx input type=text name=cardholder s ize= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCredit card expire date (mmddyy)lttdgtlttd colspan=2 align= leftx inpu t type=text name=expiredate size= 40x tdgt

lttrgtlt trx trgtlt trx trgtlttr valign=topgt

lttd align=rightgtSelect shipping methodlttdgtlttd align=leftgtltinput type=radio name=shipping value=upsgtUPSltbrgtltinput type=radio name=shipping value=expressgtExpressltbrgtlttdgtlttd align=leftgtcinput type=radio name=shipping value=normalgtNormalltbrgtltinput type=radio name=shipping value=abnormalgtAbnormalltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtReceiver Namelttdgtlttd col span=2 a lign= leftx inpu t type=text name=receiver size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtAddresslttdgtlttd colspan=2 align= leftx input type=text name=address size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCitylttdgtlttd colspan=2 align= leftx inpu t type=text name=city size= 4 0 x td gt

lttrgtlttrgt

136

lttd align=rightgtStatelttdgtlttd colspan=2 align= leftx inpu t type=text name=state s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtZipcodelttdgtlttd colspan=2 align= leftx inpu t type=text name=zipcode size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtPhonelttdgtlttd colspan=2 align= leftx input type=text name=phone size= 40x tdgt

lttrgtlttablegtlt b rx b rgtcinput type=submit value=Process name=actiongt

ltformgt

ltbodygtlthtmlgt

137

APPENDIX C

Screen Display of the Test

138

mmm File Edit View Favorites T o d s Help

^ Jit j j ^ LJ U 3) ~ pound=J _Am Back - S top Refresh Home j Search Favorites History Mait Print Edit

Links gtgt Address |4S ] httDVIocalhost808QAvdcorne shtml

TinyBookStore com

Welcome to the TJnyBoakStoro com

F i v e H o t B o o k s

1 T h e C + + Programming LanguageU s u a l l y s h i p s i n 24 h o u r s

B j a r n e S t r o u s t r u p A d d i s o n - W e s l e y Pub Co 1997 Our P r i c e 31 47

2 - P r o g r a m m i n g V i s u a l C + +U s u a l l y s h i p s i n 24 h ou r I I

Local intranet

Search BooksHorne

Category

Author

Title

ISBNPublisherDate

3 iigt60

3 1 S earch T inybooksloiecom - Microsoft Internet Explorer

139

T inyB ookStorecom - Microsoft Internet Explorer

j File Edit View Favorites lo o k Help

q a a H 3 1 d B ack S top R efresh Home S earch Favorite History j M aJ Print

Links gtgt A ddress httpV localhost 308QoryleV PetailCorterV 020i8SC l4

MM

Edit

Search Books

Home

Category

Author

Title

ISBN

PublisherDate

TinyBookStore com

The C++ Programming Languageby B j a r n e S t r o u s t r u p

0

ISBN 0 2 0 1 8 8 9 5 4 4 A d d i s o n - W e s 1e y P ub Co 199 7

Reviews

P r i c e 31 47A v a i 1ab i 1i t y U s u a l 1 ys h i p s w i t h i n 24h o u r s

Aic t o c a r t

ijgJ Local intranet

140

^ | I myBook5torecom Shopping Cart - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

[v] I ^ -J JB ack - Stop R efresh Home S earch Favorites History lsquo Mail Print

Links A ddress 0 1 h ttp localhost8080servetA ddT oShoppingCart ~3 ltGdeg

Shopping Cart Item s Price

The C++ Programmi ng LanguageB j a r n e S t r o u s t r u p Q u a n t i 1 7 1

Price $ 3 1 4 7 Subtotal $ 3 1 4 7

d e l e t e

Total 31 47

Customer Information Microsoft Internet Explorer

File Edit View Favorites lo o ls Help bull _

bullgt 3i 4 n j j d a 31Back ~-j Stop- R efresh Home S earch Favorites History j Mail Print Edit

Link gtgt j Address ] j j h ttplocalhost SOSOcheekoot html

EMH1

~3

Customer Information

First name jFang

Middle initial |a

Last name Xiao

Email address fxiaomitecnet

Account password pooooc

0 1 Done

Credit card number 1234567891234567

Credit card type VisaC MasterCard

C Bluebir d C Fisher

Credit card holder jr ong Xiao

ard expire date (mmddyy) J010102

Select shipping method UPSO Express

O Normal C Abnormal

J |sect Local intranet

141

lt2] Order List - Microsoft Internet ExplorerFile |d i t View Fayotites lo o t Help

^ 3 ^ S i l S - j S tep R efresh Home Search Favorite History Mail Print h-

HFte-LLinks A ddress I g ] httplocalhost8030servletCustemeilrifoProcess 3 ^Go

Your order reads as followsE - M a i l A d d r e s s f x i a o

F a n g X i a o

ship to

T e l

11 e m s

pound] Pc

10821 W e s t e r n P l a z aOmahaME6 8 1 5 4

( 4 0 2 ) 4 9 6 - 7 5 7 0T i t l e T h e C++ P r o g r a m m i n g L a n g u a g e Q t y 1 P r i c e 31 47 S u b t o t a l 31 47

| a [ Local intianet rsquo

l i

T inyB ookSloiecom - Microsoft Internet Explorer

T 7 ~ J iii 4 a i t Vi 1+ a Si

5 E

P r i te i+ A d d ie r I ig l httplocalhot8080ervletReqCollectauthor

S e a r c h B o o k s

Horne

Ca t e g o r y

A u th o r

Title

ISBN

P ublishe r Date

jS 1 D one

TinyBookStore com

fc t i t e r l i t n o rYou can enter authors full name first name or last name

A u t h o r |sCOtt

O ExactName amp Last F irst Name (or Initial)

T itiv b o o k s to re c o m H o a e | C a te g o ry | A u th o r | T itle | ISBN | P u b lish e r D ate

C opyright and disclaim ercopy 1999-2001 F an g Xiao

T op o f P f

|sect g j Local intranet

142

linyBookStore^com- MiciosoFUnteinet ExplorerFite Edit View Favorites Tools Ftelp

IIl4 rsquojO IjjlI - 3 -Upraquo 8 a c k ltbullltbullbullltlaquo Stop R efresh Home S earch Favorites History Mail Print 1

| Links 1 Address j raquo 3 http7localhost8CI80servletAuthorProcess

l - i f l |x |

S e a r c h B o o k s

Home

C a t e g o r y

Ti t le

ISBN

P ublishe r D a te

D o n e-

TinyB o okStore com

1- Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

I G aleampory I A utho t | I jt te | ISBN | PubH shei^D atg

i t and disclaim erreg 1999-2001 F ang Xiao

Top of

l i Local intranet

j T iny8ookStorecom - M icrosoft Internet Explorer

Fite Edit View Favorites Tools Help

4- 5 ni M m ~ltpound C r =gt 2f|L i p | | | | | iAdiiill|^Thttp7localhost8080seivletD etailContent0201924889

U 3

S e a r c h B o o k s

H ome

C a t e g o r y

A u th o r

Title

ISBN

P u b lish e r P a te

TinyB o okStore com

Effective C++b y Scott Meyers

ISBN 0201924889 Addison-Wesley Pub Co 1995

R eviews

This is the review of Effective C++

R eader Comments

Price 3795 Availability U sually ships within 24 hours

Add to iosil

IIH LdcSiiihttahdt

143

l inyBookStorecom Shopping Cart - Microsoft Internet Explorer

4- -- _ t lS M JJ ltpound I 7 r mdash2--I or- Stop R efiesh Home S ea rch Favorites History Wait PrintBach

Links Y 1^ddtessj-^1 httDvVlocalliostiBOBOyservletMddToShoppinqCart 73 ^

0

Shopping Cart Item s

Effective C + +Scott Meyers Quantity 1

0 1 Done

delete

Price

Price $ 3 7 9 5 Su b to ta l $ 3 7 9 5

Total 3 7 9 5

IB~ht Locai intranet

bull 3 TinyBooKGIoFooom M icrosoft Internet Cxplorcr

Fite Edit View Favorites Tools Help

4- -4gt Lfl 4 r amp J J lt$ i icirsquo s J ~lAB ack Ti(^poundprV aTdV iS^Stop-T SfSjefre^ptr I i - M t s s j r y rvlih- i JPopSnr -JE

i i i l l l P I I I ^ I i l l ] httplocalhost8080servletR eqC ollectauthor

G3SJ

7 ^ Go

S e a r c h B o o k s

H om e

C a t e g o ry

A u th o r

Title

ISBN

Eytoiisiier Date

101 D one

T i n y B o o k S t o r e c o m

E n te r AuthorYou can enter authors full name first narne or last name

A u t h o r jCraig Larmen

E Exact N ante O Last F irst N ame (or Initial)

Search Now 1 Clear Form

I C ategory | A u th o r | j j t l s | ISBN |

C opyright and ctiiclali[er copy 1999-2001 F an g Xiao

T o p o fP ag e

^tDpcafihttangfe-

144

gj TinyBbokSlorecom - Microsoft Internet ExplorerFile Edit View F a v o n te s - Pools

4-1 4 gt_poundj Q Jl3S top R efresh Home S ea rch Favorites History Mail PrintCacl-

lsquo Unko A ddress j ig ] httplocalhostSOSCiservletAuthorProces 71

S e a r c h B o o k s

Home

C a t e o o r v

A u th o r

Tit le

ISBN

P ub l i she r D a t e

Titty Bo okStore com

1 Applying UM L and Pattern Usually ships in 24 hours Craig Larmen Prentice Hall 1997 Our Price 450

T im booksto re com Home | C ateg o ry | A u th o r | Title | I3BM | Publisher P a ts

C opyrigh t and disclaimer copy 1999-2001 F an g X iao IIg ] http7localhost 8080eopyright html Local intranet

7 j T inyBookStorecom - Microsoft Internet Explorer

^ 03 4 31 0 i -_r _j _T B ack ~j~ S top R efresh Hom e Search Favorites History Mail Print Edit

I Links Addiess AocalhcistiiiOciOserv-letCctailConfent0137488S07

u m m

S e a r c h B o o k s

HorneC a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r Date

Tiny Bo okStore com

Applying LOVIL and Patternby Craig Larmen

0 Price 450 Availability TJ sually ships within 24 hours

ISBN 013748880 Prentice Halil 997

R ev iew s

Tins is the review o f Applying UML and Pattern

R ea d er Com ments

Add to cart

01ll iPdSSIihirSdety

145

3 TinyBookStorecom Shopping Cart bull Microsoft internet ExplorerFile Edit View Favorites Tools Help

vJBeck

JStop Refresh

4Home

H Si - iS- -=dSearch Favorites History Mail Pnnt

Links rdquo Address jlti] httpVlocalhostBOSOservletAddToShoppingCart 3 ^ Gc

r o 1

Shopping Cirt J toms Price

A pplying UML and PatternCraig Larmen Quantity 1 Effective C++Scott Meyers Quantity 1

l i l le t e

delete

Price $ 4 5 0 Subtotal $45 0

Price $ 3 7 9 5 Subtotal $ 3 7 9 5

Total 82 95

d f g a j Local intranet

146

lt3 TinyBookStoiecom - Microsoft Internet ExplorerFile Edit View Favorites Io o ls Help

gt j i 4 a - a i [j JB ack Forward Stop Refresh Home S earch Favorites Histeiy Mail Print Edit

Links Address ] pound ] hiipVonahost803CeerveirsquoReqColectlsquoauthor

0 1 i

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r D a te

Tiny Bo okStore com

You can enter authors full name first name or last name

A u t h o r jJeff

O Exact N ame Last First N ame (or Initial)

Search Now i Clear Form

T inybookstorecotti H oinf | Category | A trthor | Title j ISBN | Publisher Date

Copyright and disclaimer copy 1999-2001 Fang Xiao

Top of Page

M Local intraZl

m TinyBook Stote com - Microsoft Internet Explorer

Fife Edit View Favorites Joo ls Help

ISregBack Stop Refresh Home S earch Favorites History Marl Print c

Lirrks Address samp] httplocalhost8080servletAuthorProcess ~z ^ Gc

S e a r c h B o o k s

H ome

CategoryA u th o r

Title

ISBN

P u b lishe r D a te

i M

TinyBookStore com

1 Progi aimning Windows bullwith M FC Usually slaps in 24 hours JeffProsise Microsoft P ress 1999 Our Price 4799

jnybo-okstorscom Homo | Category | A u th or | Title | ISBN | Publisher P a h

C opyright and disclaijRief copy 1999-liOO1 FangX iao

Loccii intranet

147

148

m I myUookSlorecom - Microsoft Internet ExplorerFile- pound d it View Favorite T ools Help

^ J ] 4 U J j j =jgt Stop R efresh Home S e a rc h Favorites History i Mail Print EditBack

Links AddressilaquojigThttplocalhost5 i380ser4eM D etailContent157231 pound350

rfgKxi

ldquo3 gt6deg

S e a r c h B o o k s

HorneC a teg o ry

A u th o r

Ti tle

ISBN

P ub l i she r D a t e

TinyBookStorecom

Programming Windows with M FCby JeffProsise

0

ISB N 1572316950 Micro s oft Pre s s 19 9 9

Price 4799 Availability Usually ships within 24 hours

R e N ew s

This is the review of Programming Windows with MFC

R eader Comments

A dd to cart

D one i jh j Local intranet

lt 3 TjryBook S tore com Shop p in g Cart - M icrosoft Internet Exolorer

File Edit View f a nute T ools Help

r 1B ack

J 3 Q 0J amp poundlr - Jlilip isS h lA ld rS s httpy |ocalhost8U 80AervletA ddToShoppingCait TSIIlli

Shopping Cart Item s

Program m ing W indow s w ith M F CJeffProsise Quantity 1A pplying UML a n d PatternCraig Larmen Quantity 1 E ffective C++Scott Meyers Quantity 1

d e le te

d elete

d elete

Price

Price $ 4 7 9 9 S u b to ta l $ 4 7 9 9

P rice $ 4 5 0 S u b to ta l $ 4 5 0

Price $ 3 7 9 5 S u b to ta l $ 3 7 9 5

Total 1 3 0 9 4

^ h W h e iM

S s i Local intranet

149

File Edit View Favorites lo o ls Help n4- -0 iS - M L U

Back Stop Refresh Home Search FavoritesJ

History I3 H H H B H H H BMail Pm Edit

Links rdquo Addrecs |s] hHplocalhogt5t8080servletReqCollectcategorii ^_____ bulllt bullbull llilltllll

Search Books

Home

Category

Author

Title

ISBNPublisherDate

TinyBookStore com

P r o g r a m m in g

AI g o r i t Lins CampC++ D e l p h i J a v a MFC P e r l s o f t w a r e D e s i g n UML V i s u a l B a s i c M o r e

Done

Web D e v e lo p m e n t

ASP Commercem C y b e r c u l t u r e HTML J a v a S c r i p t S e c u r i t y Web D e s ig n XML more

G r a p h i c s amp S o f t w a r e

Asobe CAD D es k t op P u b l i s h i n g G r a p h i c s M i c r o s o f t More

I J J ig Local intranet

150

finvBookStorecom - Microsoil Internet Explorer - j g j x

j Fite Edit Jfiew Favorites lo o ts Help

bull j 5 a i B ack lsquolti S top Refresh Home S e a tc h Favorites History Mail Print Edit

Links 1 Address |ltg] hitpVocalhostl-i030seryletCateciofyPreceigtVc03 ^ | g

S e a r c h B o o k s

Home CategoQ

A u th o r

Title

ISBN

Publishe r D a te

TinyBookStore com

1 Core Ja v a 2 Usually ships in 24 hoursCay S Horstmaun Prentice Hall 1999 Our Price 2579

2 Ja v a S erv let Programm itig Usually ships in 24 hoursJason Hunter i O Reilly 1993 Our Price 1977

3 Ju st J a v a 2 Usually ships in 24 hoursPerter van der Linden Prentice Hall 1999 Our Price 3149

Tinybookstorecom Home | C ategory | A u th o r | T itle | IbBN | Publisher D ateloRoIEage

n g Local intranet

ta

151

41 Tinytfookbtorecom - Microsoft Internet ExplorerFile gdit y iew Favorites JLools Help

1 ^ hgt a a a amp a j ri i - 3 bull a Back Forward Stop Refresh Home S earch Favorites History Mart Print Edit

lisLinteslsii Address ji^]h ttp localhost8D 8o7serv letD etailC ontent0130319336

M i

3 f^Gc

S e a r c h B o o k s

Homec a t e g o r y

Tiny Bo okStore com

Core Java 2by Cay S Horstmaun

El

ISBN 0130819336 Prentice H alil999

Reviews

This is the review of Core Java

R eader Comments

Price 2579 Availability U sually ships within 24 hours

I Add to car

S ] Done S i Local intranet

TinyBookStorecom Shopping Cart - Microsoft Internet Explorerfel11 File Eefit View Favorite l o o k H e lp

tljH|V| 4 a 3 j 09 c T J

Stop Refresh Home S e a rc h Favorites History j Mail Print

jiiLihkIi87js ^ B ie s S ij^ ] http Z localhost8080servletiddT oShoppirigC art

B I B

3= i

Shopping Cart Item s

Core Java 2Cay S Horstmaun Quantity 1

Icopy

t i l

delete

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Total 2 5 7 9

sal Local intranet

152

a TinvBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites J o o lr Fjelp

NBack

amp Id b iStop Refresh Home

ISearch Favorifes History - Mail Print Edit

Links gty I Address [ jg l httplocalhost8080servletD etailContent156592391 x d

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

T i t le

IS B N

Publisher Date

ampJ Lrl e

Tiny Bo okStore com

J a v a S erv le t Piograitmmigby Jason Hunter

a Price 1977 Availability XT sually ships within 24 hours

ISBN 15659239 lx O Refflvl998

R e N ew s

In this brand-new third edition of Java Servlet Programming author Bjame Stroustrup the creator of Java presents the full specification for the Java language and standard library a spec that will soon become the joint ISOANSI Java standard

j ~2J Local intranetm

dH T iny8ook5torecom Shopping Cart - Microsoft Internet Explorer

File pound d t y iew Favorites Io o ls HelpB H

a $ a i a a -Stop Refresh Home S ea rch Favorites Hi lory Mjl

3- lsquonr I

| j | i | H | g i | i | i d ^ | | | | l Q httplocalhost80S0servletAddToShoppirigCart J P

m

Shopping Cart Item s

Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d e le te

d e le te

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Price $ 1 9 7 7 S y b to ta l $ 1 9 7 7

Total 4 5 5 6

I O I

aiil

153

Lustomer Information - Microsoft Internet Explorerpoundite pounddit View Favorites Xoo|s Help

v- _) _ l 4 J I VB ack - Stop R efresh Home Search Favorites History Mail

Links gty] A ddress ] j i l h ttD localhost8080checkouthtm l

F -iVj ~f

l l i l i i

C u sto m er In fo rm a tio n

First name jFang

Middle initial lA

Last name fXiao

Email address jfxiao m itecnet

Account password jxxxxx

Credit card number ]1234567B91234567

Credit card type C VisaC M asterCard

C Bluebird O Fisher

Credit card holder jFang Xiao

Credit card expire date (mmddyy) jo 10102

Select shipping method c u p sC Express

NormalAbnormal

0 ] D one Local intranet

poundpound Order List - Microsoft Internet Explorer

s

Back

Li il raquo

Yiew Favorites l o o h Help

bullV Y lJ j X I T- lty S to p Refresh H o m e

amp 1 3 J - jrS earch Favorite History lt Mail Print

fcesssaampl httplocalhost8080servletCustom erlnfoProcess

Y o u r ord er reads as fo llow sE-Mail Address 6daomitecnet

Fang Xiao

ship to

Tel

Items

12345 Western PlazaOmahaNE68154(402) 123-4567

Title C ore Java 2 Qty 1 Price2579 Subtotal 2579

Tide Java Servlet ProjammingQty 1 Pnce 1977Subtotal 1977 Total4556

ffl|b ] Done kl Local intranet

154

mammmm 1

File Edit View Favorites lo o ts tieip

E=cl i u F t l H -n e -i i rdquo F j-oiilsquoiBillHistory lsquo gt1 ll Print Edit

iiiiiiiiiiiiiiiiiirsquo Links Address j-copy] http localhust 8080servletReqCollectisbn J

TinyBookStore com

Search Books

Home ISBN

Author

Title

IS B N

S e a r c h Hew C le a r Form

PubnsheuDate

Top o f PageITnjrbooksj^ore^ com Horne I C a te g o rv | ^ i t h o r | T i t Ie I ISBN | Publisher Date

- g ] http locdlho-st SOSOwelcome shtrnl

TinvBookStorecom - Microsoft Internet Exploier

poundaj Local intranetId

| File Edit View Favorites Tools Help

i -e -e u u r5_ _ _ a u ^ 4 - a a j Back Forward S top Refresh Home S earch Favorites History Hail Print Edit

Links A d d re ss ^ hitp rsquoIdcanc-stEtnSOservlltlsquoF-aqZoll-~ntispn z raquo h

TinyB o okStore com

S e a r c h B o o k s

Horne

A utho r

T itle

ISBN

P u b lish e r P a t e

fcntar ISBN

I SB H 1565922840

|sectplli||pbw||l| IliM M pifiillj

T rgU onL cirrti -nr Kini- | Cgtgpound-gg | Agithor | Title | ISBN f uhhe-rt Pete

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top o f Pag e

aipoundbull] O o n e Local intranet

155

File Edit View Favorites Tools Help

HUTinyBookStorecom - MicrosoH InternetExplorer

B ad-J J A J d -2r =3

Stop R efresh Home S e a rc h Favorites History Mail Print

Links ygt A ddress j ^ ] httpVlocalhost8080servletrsquoISBM Process

S e a r c h B o o k s

Horne

C a t e g o r y

A u th o r

T itle

IS B N

Pub l i she r D a t e

TinyB o okStore com

1 Learning Perl Usually ships m 24 hours Randal L Schwartz O Reilly 1997 Our Price 1997

T in vh ooksto re c o m H orne | C at ego tv | A u th o r | Title | ISBM | Publisher D ate

C opy rig h t a n d d isclaim ercopy 1999-2001 F a n g X iao

0 ] Done

yen

ighj Local i

TinyB ookStoiecom - Microsoft Internet Explorer

Erie Edrt View Favorites- lo o ls Help

-s pound] 4 pound1 jLl icArdquo =pound 2 S top Refresh Home S earch Favorites History Marl Print Edit

iilHI

NpBack

httpyiocalhostSOBOservleMDetailContentAI 565922840 ~T] Cm

Tiny Bo okStore com

S e a r c h B o o k s

H o m e i

C a teg o ry

A u th o r

T itle

ISBN

Publishe r D a te

Learning Perlby Randal L Schwartz

I ^

ISBN 1565922840 O Reillvl997

Price 1997 Availability U sually ships within 24 hours

Reviews

This is the review of learning Perl

Reader Comments M0 ] Done lsquofR | Local intranet

156

IHHHHHI _ I f f i x |

File E d t yiew Favorites J o e ls H elp 11v- -__ l

Back ~ rc Stop R efresh Home S earch Favorites HistoryJ rMail

HH1111Pgtnt

Links A ddress | ] http7docalhost8030servleM AddToShoppingCart 3 tgt G o

O S III

Shopping Cart Item s

Learning PeriRandal L Schwartz Quantity 1

delete

Price

Price $ 1 9 9 7 Subtota l $ 1 9 9 7

Total 1 9 9 7

s

Done Local intranet

Eg W illi 1 lttMM41 i H H p n B n 1 0 1 x i

Fite Edit View Favorites Toots Help E H

1$3 L plusmn J8ack Forward Stop Refresh Home Search Favoutes

4History i

- i V -=JMail Print

-Edit

71 Address http7localhost8080lsquoservletFleqCollecVisbn I l f i l l l

TinyBookStore com

Search Books

Home

C ateao rv

Author

Title

ISBN

Publisher D a te

Enter ISSN

i s bit [l 565921496

Search Now I Clear Form

Tinybookstore o n Home | Category | A uthor | Titb | ISBN | Publisher Dte

Copyright arid disclaimer copy 1999-2001 Fang Xiao zl amp j Done Js J Local intranet I

157

H H H r f e i x i File Edit View Favorites Lools Help

- J j j j ] JBack Stop Fiefresh Home Search

J JFavorites-

-J i C rHistory Mail Print

111111811i n

r Links wj i Address |reg] http docalhost 8080servletIS8N Process

S ea rch B ooks

Home

Category-

rdquo A u th o r

T i t l e

IS B fi

P u b l i s h e r D a ta

Tiny Bo okStore com

1 Programtning Perl Usually ships in 24 hours Larry Wall O Reilly 1997 Our Price 2397

T o o k s t o r e c o m H P in e | C a t e g o r y | A u t h o r | Till | IS B N | P -ubtu-hai D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g X ia

T o p o f P a g e

zlamp2 Done Local intranet

158

lt3 l mytfookSlorecom - Microsoft Internet ExplorerF3e Edit View FavoMes lo o ts Help

Back3 U Si S rsquo IStop Refresh Home lt Search Favorites History Mail Print Edit

httplocalhost8080servletDetailContent15S5321496 j3

Search Books

Horns

Category

Author

Title

ISBN

Publisher Date

Done

TinyB o okStore com

Programming Perlby Larry Wall

0 Price 2397 Av ail ability U sually ships within 24 hours

ISBN 1565921496 O Reillyl997

Reviews

This is the review of Programming Perl

Reader Comments

Add to cart

l or=lM

159

Tm vBookSlorecom Shopping Cart - M icrosoft Internet Explorer

i Fite Edit View Favorites lo o k Help

^ Beck R efresh Home

ampS earch Favorites History j Mail Print

E Links I Address ] pound http localhost 8080servletA ddT oShoppingCart rsquo ] O rai

i O

Shopping Cart Jlems

Learning Peri Randal L Schwartz Quantity 1 Program m ing PeriLarry W all Quantity 1

delete

d e le te

Price

Price $ 1 9 9 7 S u b to ta l $ 1 9 9 7

Price $ 2 3 9 7 S u b to ta l $ 2 3 9 7

Total 4 3 9 4

3SJ Done j | s [ Local intranet

160

m m mmmHi mmmHHHHHi1 File Edit View Favorites Tools Help

^ - J J -ih Ji - j| B a d Forward Stop Refresh Home S earch FavoritesHIH ctuv Mjl Print

IHIlllliEd

B l

MbfeifcssfjP Address httplocalhost8080servletFleqCollectpLiblisher_date_ ___ ________ ___________ _ bull bull bull bull_________________ Zi T gt 6 o

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

Title

ISBN

Publishe r P a t e

S ] Done

TinyBo okStore com

T rsquov -

Publisher

sind IPpiIs1iclaquoifciori OsifiC

jAd cl i so n-VVe oI e y Fuo C o ~

P u b l i c a t i o n D a t e 1U97

Search Now Clear Form

T inybookstore com Home | C ategory j A u tho r j I itle | ISBN | Publisher Ds

C opyright and disclaimer copy 1999-2001 F an g Xiao

T op o f Page

g a l Local intranet

161

lt|j TinyBookStoiecom - Microsoft Internet Explorerlsquo Erie Edit View Favorites lo o ls Help

v-1 Q rij - 3 rsquo- a u -=pound Ci Back s lsquoi i 1 Stop Refresh Home S earch Favorites History Mail Print i

jL inks i A ddress 0 1 http7localhost8Q80servletPublisherDateProcess

EMM

3

S e a r c h B o o k s

Home

C a t e g o r y

Author Title

ISBN

Publisher D a te

TinyBookStore com

1- Algorithm s in C Usually ships in 24 hoursRobert Sedgewick Addison-Wesley Pub Co 1997 Our Price 4495

2 The C++ P rogr amming L anguage Usually ships in 24 hourBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

3 Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

4- U M L D istilled Usually ships in 24 horn sMartin Fowler Addison-Wesley Pub Co 1997 Our Price 2995

Done | s j L ocalm

TinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorites l o o k Help

Backamp 3 $ -Q 3 3 AJStop Refresh Home S earch Favorites History Mail Print Edit

Lipikkigt7i Ajddr$esjhttpv7localhost8080-servletDetailCoriterit0201314525

m

3 rgtGc

S earch B ooks

Horne

A uthor

Title

ISBN

Publisher D a te

Tiny BookStore com

Algorithms in Cby Robert Sedgewick

S

ISBN 0201314525 Addison-Wesley Pub Co 1995

Reviews

This is the review of Algorithms in C

Reader Comments

Price 4495 Availability U sually ships within 24 hours

Add to cart

0I reg S a i t^ s a l intranet

162

File Edit View Favorites lo o ls Help

2 ^ iVi ^ ^ t j j B ack gt Stop Refresh Home S ea rch Favorites History ||

- i -Mail Print

WB0BUBSSSI B ifl

Links ygt Addrese |isect ] httpvVlocalhostSOSChservletAddToShoppingCart

Shopping Cart Item s

A lgontfim s in CRobert Sedgewick Quantity 1

0 1 D one

delete-

Price

Price $ 4 4 9 5 Subtota l $ 4 4 9 5

Total 4 4 9 5

Local intranet

163

^ l inyBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

ls31

3 bullrsquo -I- _J _jj - j i_ 3 - j rdquo -= $ ABack Forward Stop Refresh Home Search Favorites History Mail Print Edit

Links rdquo Address 6 J http Vlocalhost SOSOAervletR eqCollectpublisher_date j ^G

Search B o o k s

Home

categoryAutho r

Title

IS B N

Publi sher D a te

TinyBookStore com

liter Publisher and Publication Date

P u b l i s h e r Wrox Press Inc

P u b l i c a t i o n D a t e ]1

Search Now j Clear Form

T invbookstor ecotnHomg | Category | A uthor | Title | ISBN | Pu b lish e rP a t

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top of Page

zD one Local infra

m TinyB ookStoiecom - Microsoft Internet Explorer

R e Edit View Favorites Tools Help

- -i 13 4 St 2J amp t r - JHB-1

fff ij if P S | Address |sjpound~| httpVlocalhost8030servletPublisherDateProcess

S e a r c h B o o k s

Home

C a t e g o r y

A utho r

T itle

ISBN

Publisher D a te

0 ] Done

TinyBookStore com

1 Beginning Visual Basic 6 Database Programming Usually ships in 24 hour John Connell W rox Press Inc 1998 Our Price 3199

2 Befmiung Visual Basic 6 Usually ships in 24 hours Peter Wright Wrox Press Inc 1998 Our Price 3199

T inybookstore com H orae | C ategory | A u thor | Title | ISBN | Publisher Date

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top o f Fas

Local intranet

64

| File Edit Yiew Favorites T ook Help

i A - + - - a S 3 rsquo reg - pound J -3 Back ldquo d Stop Refresh Home Search Favorites History

- vMail Print

i

Edit

IllplBlllll________ g - M

isisfcinbsijp Addre s | g ) httplocalhost8080servletDetailCoritent1861001061 3 Gdeg

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

T itle

ISBN

Publishe r D a te

TinyBookStore com

Beginning Visual Basic 6 Database Programmingby John Connell

a Price 3199 Availability U sually ships within 24 hours

ISBN 1861001061 Wrox Press Inc 1998

Reviews

This is the review of beginning Visual Basic 6 Database Programming

Reader Comments

A d d to c a n

S] pone Local intranet

m u i

lillllEHl ^ bdquo A 3 2tl 4 t M liJ i

Back Forward Stop Refresh Home Search Favorites3

History 4 _ r

M j 1J

Print EditiSillilillllS

httplocalhost8080servletReqCollecttitle

S e a r c h B o o k s

Home

C a t e g o r y

Author

Title

ISBN

Publisher Date

TinyB o okStore com

Enter TicleYou can enter the exact title or part of title

T i t l e C++

O Exact Title Title Words

Search Now Clear Form

Example

bull Entering Java Servlet Programming in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title are related to Java _li

165

lt5 TinyBookStorecom - Microsoft Internet ExplorerFite Edit View Favorites lo o ts Help

Back Stop Refresh Home S earch Favorites History Mail Print

Links gty Addiess http-localhost8080servlet7TitleProcess

i|p1

I

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

Publi sher IS a t e

TinyBookStore com

1 The C++ Programming L anguage Usually ships in 24 hoursBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

2 Effective C+-F Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

3 Programttung Visual C-H- Usually ships in 24 hours David J Kmglinski Microsoft Press 1998 Our Price 3999

T m y h o o k s to e co m H o m e | C a te g o ry | A u th o r | T itle | ISBH | P u b lish er D ate

http iocalhost SOSOservletFleqCollectcategary

T op of P age

~hj Local intranet

bull a TlnjpBflOkStOfecom - Microsoft Internet Explorer

File Edit View Favorite Pools Help

0 3 4 S l i 3 O - J J i t of Stop Refresh Home S earch Favorites History - Mart Print Edit

HBack

i i i i lS i lB i I i f f id i l f f lH Q http Vlocalhost 8080AervletD etailContent1572318570

EEEI

J

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b lis h e r D a f t

TinyBookStore com

Programming Visual C++by David J KrngHnski

[Hj

ISBN 1572318570Microsoft Press 1998

Price 3999 Availability Usually ships within 24 hours

R e v ie w s

This is the review o f Programming Visual1

Reader Comments

Add to cart

if Local intranet

166

mm| File pounddtt View Favorites Jo o ls Help

c J J j j mdash JB ack - J Stop Refresh Home S earch Favorites History

- _ i -M u

J tPrint

t e t a f e w P A ddress | ^ ] httplocalhost8080servletAddToShoppingCart zl -lt1gtSo

Shopping Cart Item s

Programmeng Visual C + +David J Kmgbnski Quantity 1

delete-

Price

Price $ 3 0 9 0 Sub to ta l $ 3 9 9 9

Total 3 0 9 9

D one ^aj Local intranet

TinyBookStorecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

vHBack-

-J a 4 -a si fi- 3 aStop R efresh Home S earch Favorites History j Mail Print- Edit

Links gty A d d re s sL ^ ] hrtpWlocalhostSOSOservleVFIeqCollectAitle

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

ISBN

Pub l i she r Date

TinyBookStore com

Enter TitleYou can enter the exact title or part of title

Title Distil I nrfExact T itle V T itle W o rd s

Search Now | Cle ar Fo rm

Examples

rpound] Done

bull Entering Java Servlet Programming11 in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title arei date 11 j Java JZJ

167

a TlnyBA5kSioiecom - Microsoft Internet Explorergt 0e Edit ifiew Favorites Jock Jd lp

a a amp -a tii j k i Back s - Stop Refresh Home Search Favorites History Mail Print

liilP raquo httpiVlocalhostSOSOservletTitleProcess

E M 3

ldquo3 rgt-

S ea rch B ook s

Horne

C a t e d o r v

A utho r

TiUgt~ ISSN

Publi sher D a te

Tiny BookStore com

1- TJML D istilled Usually ships in 24 nowsMartin Fowler Addis on-Wesley Pub Co 1997 Our Price 2995

| C s rg g o ty | A u th o r | T itle | IStBH I P u b lis h e r D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g Xiao

-jg Local intranetS3

m n ^ i l a i i x l

File Edd View Favorites Joels- Help M Mi r J lt 3 L h f 4 - 0 lt 3

Back i t Stop Refresh Home S earch Favorites History Mail9

PrintM

Edit

Links raquo A ddress j | i ] http do ca lh o d 1030N m letDetailContenr0201325632 Mimas

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

Title

IS B N

Publisher Date

Tiny BookStore com

TJML Distilledby Martin Fowler

0

ISBN 0201325632 Addison-Weslev Pub Co 1997

Reviews

Tins is the review of The UML Distilled

Reader Comments

Price 2995 Avail abilityTJs u ally ships within 24 hours

Add to c a r t

0 3S i] Done |g^iLnealiihfrregei

TinyBookStorecom Shopping Cart Microsoft Internet ExplorerFile Edit View Favorites Jo o ls HetP

IBiiiBlll l l lHBlSglSlllllilMH MlllBliriilllgllSlIlBack - f - i - S top Refresh Home

a J i l ^ j 3 Search Favorites History 1 Mail Print liiii

3 Links ( A ddress j ig j hrtplocalhost803DservletAddToShoppingCart

Shopping Cart Herns Price

UML D istilledMartin Fowler Quantity 1Program m ing Visual C + +David J Kraglinski Quantity 1

Price $ 2 9 9 5 Subtota l $ 2 9 9 5

delete

Price $ 3 9 9 9 Subtota l $ 3 9 9 9d elete

Total 6 9 9 4

  • Electronic Commerce on Business Application
    • Recommended Citation
      • tmp1499779448pdf2JOpQ

Acknowledgements

I would like to express my sincere appreciation to my thesis advisor Professor Peter A

NG for his kind guidance time and support I would also like to say thank you to my

supervisory committee Dr Qiuming Zhu Dr Bin Chen for their suggestions help and

cooperation

Abstract

For some time now Whole size business enterprises have used electronic commerce

to conduct their business activities The On-Line store is one of a number of popular

web applications This thesis focuses on one of the emerging On-Line store

technologies which is known as Server-Side Java Application

In early 1960 private networks were dedicated for the use of electronic data

interchange (EDI) and electronic funds transfer (EFT) in banking business Recently

however with the increased awareness and popularity of the Internet electronic

commerce has come to encompass individual consumers as well as businesses of all

size For most people electronic commerce is defined as the buying and selling of

products and services over the Internet but there are many more aspects We will

discuss different definitions of electronic commerce in this paper

The most popular Web applications are the On-Line Stores Most of such applications

involve functions as searching for product information ordering products paying for

goods and services and for providing online customer service A Web server running

continuously accepts userrsquos connection gets user requests and forward requests to

business procedure retrieves data (answers to user requests) from business procedure

and sends it back to the user

An on-line store system is different from a traditional web publishing It needs a

customerrsquos interactive communication and frequent data update The traditional

HTML page does not satisfy the customerrsquos needs because all it does is simply

publish static contents More complex technologies are required in order to produce

dynamic contents

There are a few technologies that can be used for implementing the on-line stores

Common Gateway Interface (CGI) Microsoft Active Server Page (ASP) and Server-

side Java application are the most popular technologies Introducing the Server-Side

Java application is one of the latest and most exciting trends in Java programming

The Server-side Java application has many advantages over the other technologies

Table of Contents

Chapter 1 Introduction 1

Chapter 2 Electronic Commerce 2

21 What Is Electronic Commerce2

22 The Importance of Electronic Commerce3

23 Types of Electronic Commerce3

24 Why Most Internet Based Electronic Commerce Is In

The Business-To-Consumer W orld 6

25 Current State of Business-To-Consumer E-Commerce7

26 The Structure of The On-Line Store8

Chapter 3 Technologies For On-Line Store System11

31 Traditional Web Application - Common Gateway Interface(CGI) 11

32 Active Server Page 12

33 Server-Side Java Application 14

Chapter 4 Design of On-Line Bookstore Using Java Servlets

A Practical Verification18

41 The Design of Home Page of Tiny Book Store18

42 Design of Search by Different Requests27

43 Servlets Chaining To Process Requests In Different Levels28

44 Database Connectivity and Search from Database29

45 Session Tracking 35

46 Check O ut42

47 Customer Information Processing 43

Chapter 5 Future Work50

51 Connection Pooling50

52 More Object-Oriented - Better Encapsulation51

Chapter 6 Conclusion 53

Appendix A Bibliography54

Appendix B The Source Code of An On-Line Store System -

Tiny Book Store57

Appendix C Screen Display of the Test 135

List of Figure

Figure 261 The Structure of An Online Store 10

Figure 321 Handle Requests Flow Chart 13

Figure 331 HttpService of The Java Web Server Using Servlets 15

Figure 411 The Home Page of Tiny Book Store 22

Figure 412 One of The Searching by Author Pages26

Figure 441 One of The Outputs of Servlet AuthorProces 34

Figure 451 A Page Show All Information About A Book 39

Figure 452 A Page Show Items In The Shopping Cart After A User

Added Books To The Shopping Cart 40

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A

Book From The Shopping Cart42

Figure 461 A Check Out Page 43

Figure 471 An Invoice Page48

1

Chapter 1

Introduction

As we step in the year 2000 we can no longer look to the past as the guide for the

future A combination of business social and technical possibilities drives the rapid

progress in electronic commerce

Electronic commerce can offer a company both short-term and long-term benefits

Not only can it open new markets enabling a business firm to reach new customers

but it can also make it easier and faster for the firm to do business with their existing

customer base Moving business practices such as ordering invoicing and customer

support to network-based systems can also reduce the paperwork involved in

business-to-business transactions When more of the information is digitized it

allows that business firm to focus on meeting their customerrsquos needs Tracking

customer feedbacks and presenting customer solutions for their clientele are just

some of the opportunities that can stem from electronic commerce

2

Chapter 2

Electronic- Commerce

21 What Is Electronic Commerce

For some time now large business enterprises have used electronic commerce to conduct

their business-to-business transactions In early 1960 private networks were dedicated

for the use of electronic data interchange (EDI) and electronic funds transfer (EFT) in the

banking industry Recently however with the increased awareness and popularity of the

Internet electronic commerce has come to encompass individual consumers as well as

businesses of all size

To many electronic commerce is defined as the buying and selling of products and

service over the Internet But there are many other aspects Depending on whom you ask

electronic commerce has different definitions

From a communications perspective electronic commerce is the delivery of information

productsservices or payments via telephone lines computer networks or any other

means From a business process perspective electronic commerce is the application of

technology toward the automation of business transactions and workflow From a service

perspective electronic commerce is a tool that addresses the desire of firms consumers

and management to cut service costs while improving the quality of goods and increasing

3

the speed of service delivery From an online perspective electronic commerce provides

the capability of buying and selling products and information on the Internet and other

online services [16]

These definitions are valid with their perspectives It is a matter of which lens is used to

view the electronic commerce landscape Broadly speaking electronic commerce

emphasizes the generation and exploitation of new business opportunities by ldquogenerating

business valuerdquo or ldquodoing more with lessrdquo

22 The Importance of Electronic Commerce

As we approach the year 2000 we can no longer look to the past as guide to the future In

the face of strong market forces created by electronic commerce and mounting

competition corporations can no longer plod along historical tracks or seek the

preservation of the status quo Companies are discovering that old solutions do not work

with new problems The business parameters have changed and so have the risks and

payoffs

23 Types of Electronic Commerce

From a broad view there are three distinct general classes of electronic commerce

applications Inter-organizational (business-to-business) intra-organizational (within

business) and customer-to-business application [16]

4

231 Inter-Organizational Electronic Commerce

Inter-organizational electronic commerce makes business more convenient on the

following aspects

Firstly e-commerce can improve supplier management since electronic applications can

reduce the processing costs and cycle times for each purchase order and it can reduce the

number of people who work on purchase orders

Secondly e-commerce can improve inventory management since electronic applications

make the business partners can fast exchange information and easy track their documents

to ensure that they were received This not only can eliminate out-of-stock occurrences

but also can reduce inventory and improve inventory turn

Thirdly e-commerce can improve distribution management since electronic applications

can make the business partners receive the shipping documents as soon as possible and

enable better resource management by ensuring that the documents contain more accurate

data

Fourthly e-commerce can improve channel management since electronic application can

let the business partner post the information to electronic bulletin boards This can

eliminate repeated telephone calls and countless labor hours

Fifthly e-commerce can improve payment management since the business partner are

linked by network so the payments can be sent and received electronically Electronic

payment is more accurate and fast than traditional payment

232 Intra-Organizational Electronic Commerce

5

Intra-organizational electronic commerce facilities the following business applications

Workgroup communications Electronic applications enable manager to

communicate with employees using electronic mail videoconferencing and

bulletin boards

Electronic publishing Electronic applications enable companies to publish

information by using tools such as the World Wide Web On-line publishing can

show information immediately and clearly and reduce costs for printing and

distributing documentation

Sales promotion Electronic application improve the flow of information between

the production and sales forces and between the firms and customers This can

make companies have greater access to market and competitor information

Today Intranets are primarily set up to publish and access vital corporate information

Some of the most common types of information are Human Resources information

employee communications product development and project management data internal

catalogs sales support data equipment and shipment tracking and accessing corporate

database

233 Consumer-To-Business Electronic Commerce

In consumer-to-business transactions customers learn about products through electronic

publishing buy products with electronic cash and other secure payment systems and

even have information goods delivered over the network

6

From the consumerrsquos perspective there are three transactions

1 Electronic applications enable consumers to communicate with each other through

electronic mail videoconferencing and news groups

2 Electronic applications enable consumers to manage investments and personal finances

using online banking tools

3 Electronic application enable consumers to find online information about existing and

new products services

Consumers consistently demand greater convenience and lower prices Electronic

commerce provides consumers with convenient shopping methods from online catalog

ordering to phone banking both of which eliminate the costs of expensive retail

branches Electronic commerce facilitates factory orders by eliminating many

intermediary steps thereby reducing manufacturersrsquo inventory and distribution costs and

indirectly providing consumers with lower prices

24 Why Most Internet Based Electronic Commerce Is In The Business-To-

Consumer World

For the Business-to-Business e-commerce the lack of well-accepted standards is

hindering the success in promoting Business-to-Business electronic commerce

solutions[5] VAN (Value-Added Networks) EDI (Electronic Data Interchange) based

solutions are only accessible to large organizations due to the cost factor Corporate

buyers and suppliers large and small are looking for Internet based solutions to

streamline the procurement procedures and to reduce the cost of establishing trading

relationship and the trading transactions Such demands put forward some fundamental

challenge on issue like trust infrastructure on the Internet standards and inter-operability

etc

25 Current State of Business-To-Consumer E-Commerce

Business activity on the Internet is currently limited to publicizing the business

opportunity and to catalog based sales but it will rapidly expand to include the

negotiations conducted to settle the price of the goods or commodities being traded

These negotiations are currently conducted by human intermediaries through various

forms of auctions bidding systems for awarding contracts and brokerages The role of

the intermediaries can now be performed by Internet trading applications at a fraction of

the cost[4] Trading on the Internet allows a business to reach a large number of potential

customers and suppliers in a shorter time and a lower cost than possible by other modes

of communication and to settle business transaction with lower cost overhead in a shorter

time

Auctioned or brokered sales are the norm in business world for negotiating trades of large

monetary value But consumer sales and small-scale purchases have used the fixed price

mode perhaps because of the high overhead cost of using the auction or brokerage

method The new economics of the Internet will make auctions popular in consumer and

small business transactions also

Auctions are just one form of business negotiations Other examples are competitive bids

for procurement brokeragesexchangescartels and two party negotiations

Nowadays the free-market economy of software agents is in the embryonic stage But in

the near future the software agents will populate the Internet and provide trade and use

a rich variety of information goods and services in an open free-market economy In a

free-market economy of software agents information is produced traded and consumed

by vast numbers of autonomous self-motivated agents An essential task in such an

economy is the retailing or brokering of information gathering it from the right

producers and distributing it to the right consumers[10] The overall research goal is to

characterize and understand the dynamic behavior of information economies very large

open economies of automated information agents that are likely to come into existence in

the Internet

26 The Structure of The On-Line Store

9

Nowadays there are thousands of on-line stores running on the Internet A few well-

known ones are amazoncom and bookpoolcom Most of such applications involve

common functions which are as following

Searching for product information

Ordering products

Paying for goods and services

Providing online customer service

So they have a similar structure as shown in Figure 261 The system contains the

following components

1 A web server running continuously accepts userrsquos connection gets user requests and

forward requests to business procedure retrieves data (answers to user requests) from

business procedure and send it back to user

2 Business procedure usually consists of a user identification procedure like credit card

check user request analysis procedure analyzing requests calculating discomposing (if

necessary) and dispatching request to different data source component Also in some

case business procedure is responsible to compose data obtained from different data

sources into user-readable format

3 Database is the place to hold relevant data These data not only serve as a data source

describing commercial goods and prices but can be used for data mining to improve

store service quality as well Database is updated and maintained by both customersrsquo

input and system applications A customerrsquos input usually includes order information

10

Figure 261 The Structure of An Online Store

(through browser)

Databas

(through browser)client

client

serverWeb

Systemapplication

Busines

procedu

4 System applications can include a search engine running all the time and searching

relevant information from the internet data mining application deals with mining and

analyzing customer and sale data for management use database maintaining application

handles update data when product information changes Varying from system size to

system size not every system has cleardistinct boundaries between these components

The system can be 3-tired or n-tired but these systems all operate in similar ways

11

Chapter 3

Technologies For On-Line Store System

An on-line store system is different from traditional web publishing It needs customerrsquos

interactive communications and frequent data update The traditional HTML page is

insufficient because all it does is provide static content publishing Other technologies

are required in order to implement the on-line store

Currently there are three mainstream technologies which are widely used Common

Gateway Interface (CGI) Microsoft Active Server Page (ASP) and Server-side Java

application We briefly explore these technologies here

31 Traditional Web Application - Common Gateway Interface (CGI)

The common Gateway Interface normally referred to as CGI is one of the first practical

techniques for creating dynamic content With CGI a web server passes certain requests

to an external program The output of this program is then sent to the client in place of a

static file The advent of CGI makes it possible to implement all sorts of new

functionality in web pages and CGI quickly become a defacto standard implemented on

dozens of web servers Even though a CGI program can be written in almost any

language the Perl programming language is the predominant choice However CGI have

some distinct disadvantages

Firstly CGI program is transient A request is made each time to a CGI program It must

be loaded and executed by the Web server When the CGI program is complete it is

removed from memory and the results are returned to the client All program

initialization (such as connecting to a database) must be repeated each time a CGI

program is used

Secondly when a server receives a request that accesses a CGI program it must create a

new process to run the CGI program and then pass to it via environment variables and

standard input Every bit of information might be necessary to generate a response

Creating a process for every such request requires time and significant server resources

which limits the number of requests a server can handle concurrently

Thirdly a CGI program cannot interact with the web server or take the advantage of the

serverrsquos abilities once it begins execution because it is running in a separate process

32 Active Server Page

As shown in figure 321 the following list walks you step-by-step through what

happens if the client requests the page xyzasp

The client requests the page xyzasp from the server The Web server checks the file

extension to see whether a special program (such as the Active server Pages engine)

13

must be invoked to process the request If therersquos a asp extension the Web server

determines that it should invoke ASP to process this page

Figure 321 Handle Requests Flow Chart

Request

Response

WEB SERVERComponents

Databas

ns

ASP File

CLIENT

Active X Data

VBScript

If this page has never been requested before or has been changed since the last

request it must be parsed and the syntax checked and then be compiled by the Web

server Otherwise the page might be read from a cache of recently processed pages

which aids in performance During the parsing process the HTML and scripting code

14

are separated IIS (Internet Information Server) determines which scripting engine is

responsible for which part of the script and delegates the work of syntax checking and

compiling to the proper scripting engine (such as VB Script)

Now the code is executed by the scripting engine using resources from IIS which is

hosting the scripting engines All objects that the language engine cannot handle are

requested by the IIS which is also responsible for handling inputs and outputs for the

external ActiveX objects that are created and used inside the script If it is not able to

supply the object an error is generated

Script output and static HTML code in the ASP file are merged

The final HTML is sent back to the user in an HTTP response

The important point about ASP is that the Script runs entirely in a server to protect the

intellectual property by shielding it from browser which are different from the account

for when writing client-side code The entire server-side code is processed and only plain

HTML - or whatever kind of content you chose to generate - is sent to the client

33 Server-Side Java Application

The rise of server-side Java applications is one of the latest and most exciting trends in

Java programming A Servlet can be thought of as a server-side applet Servlets are

loaded and executed by a Web server in the same manner that applets are loaded and

executed by a Web browser

15

As shown in Figure 331 a servlet accepts requests from a client (via the Web server)

performs some task and returns the results

The client (mostly likely a Web browser) makes a request via HTTP The Web server

receives the request and forwards it to the servlet If the servlet has not yet been loaded

the Web server will load it into the Java virtual machine and execute it The servlet will

receive the HTTP request perform some type of process and return a response back to

the Web server The Web server will forward the response to the client

Figure 331 HttpService of The Java Web Server Using Servlets

RequestResponseRequestResponse

RequestResponse

Java Web Server

Administrative SERVLET

SERVLETHTTP

SERVLETWeb Proxy

Servlets have distinct advantages over CGI program

Servlets are persistent Servlets are loaded only once by the Web server and can

maintain services (such as a database connection) between requests

Servlets are fast since servlets only need to be loaded once

16

Servlets are platform independent Servlets are written in Java and conform to a well-

defined and widely accepted API They are highly portable across operating systems

and across server implementations A servlet can be developed on a Windows NT

machine running the Java Web Server and later can be deployed effortlessly on a

high-end Unix server running Apache

Servlet portability is not the stumbling block it so often is with applets There are two

reasons Firstly servlet portability is not mandatory Unlike applets which have to be

tested on all possible client platforms servlets have to work only in the server

machines that you are using for development and deployment Unless you are in the

business of selling your servlets you donrsquot have to worry about complete portability

Secondly servlets avoid the most error-prone and inconsistently implemented portion

of the Java language the Abstract Windowing toolkit (AWT) that forms the basis of

Java graphical user interfaces

Servlets are extendable Servlets that are written in Java brings all of the other

benefits of Java to servlet Java is a robust object-oriented programming language

which can be extended easily to suit our needs

Servlets are secure The only way to invoke a servlet from the outside world is

through a Web server This brings a high level of security especially if the Web

server is protected behind a firewall

Servlets can be used with a variety of clients

Servlets are tightly integrated with the server This integration allows a servlet to

cooperate with the server For example a servlet can use the server to translate file

paths to perform logging and to check authorization

Servlets are quite flexible An HTTP servlet can be used to generate a complete web

page it can be added to a static page using a ltSERVLETgt tag in whatrsquos know as a

server-side include and it can be used in cooperation with any number of other

servlets to filter content in something called a servlet chain

18

Chapter 4

Design of On-line Bookstore Using Java Servlets A Practical

Verification

Server-side Java application is one of the latest technologies used to implement an onshy

line store system Servlet is a set of classes that come up from Java language It is

designed to be used for server-side Java applications There are many techniques people

can use when they utilize servlet such as Server-Side Include (SSI) Servlet Chaining

Applet and Servlet communication etc We tried to use as many such techniques as

necessary in our implementation to demonstrate the advantages of servlets

The demonstration system module is same as the one we mentioned above Figure 331

We use this module to show how such system works

The system called Tiny Book Store emulates an on-line bookstore selling computer

books It has the full functionality of other on-line stores The only difference between

this system and the other on-line systems is the database size We donrsquot want to spend

much developing time for database maintaining part because this part is similar to

ordinary database maintaining and it is an independent subsystem The Tiny Book Store

mainly consists of three modules user interface business procedure and data access

19

41 The Design of Home Page of Tiny Book Store

The home page - welcome page - is designed using the Server-Side Include technique

That is embedding a servlet inside HTML file with a specific HTML tag ltSERVLETgt

In our case this servlet when invoked can run a query on database via data access

objects to retrieve most recent top 5 best-seller books and then returns the retrieved data

to the place within the page where the ltSERVLETgt tag was As long as the data in

database update timely it is guaranteed that customer will get the most recent data

The embedded servlet is invoked by Java Web Server before the page is sent back to

client Java Web Server processes any HTML file having shtml extension and invokes

the embedded servlet marked by ltSERVLETgt tags

Server-Side Includes are useful when a page is primarily static but contains a few distinct

dynamic portions One of the servlets produces the ldquo Five Hot Books ldquo which is shown in

the following example

Example 411 A Part of Code of welcomeshtml

lt P gt

lth3xstrongxf ont color= f f 6347 gtWelcome to theltigt

TinyBookStorecomltigtltfontgtltstronggtlth3 gt

20

ltstrongxbxh3gtltcentergtFive Hot

Booksltc e n t e r x h3gtltbgtltstronggt

ltbrgt

ltservlet code=EchoServletTaggt

ltservletgt

The servlet EchoServletTag searches database according to some business rule and gets

data from data access objects to produce the Five Hot Books The following example is

the sample code

Example 412 A Part of Code of The EchoServletTagjava

public void service(HttpServletRequest req

HttpServletResponse res)

throws ServletException IOException

res setContentType ( text Jhtml)

PrintWriter out = resgetWriter()

try

Statement stmt = concreateStatement()

21

ResultSet rs = stmtexecuteQuery(select from

book where

title like Programming)

int count = 1

outprintln(ltdlgt)

while (rsnext() ampamp count lt 6)

out print In ( ltdtxbgt + count + )

String isbn =

rsgetObj ect(ISBN) toString()

outprintln(lta

href=servletDetailContent + isbn +

outprintln(rsgetObj ect(Title) toString()

+ lt a x bgt )

out println ( ltddxnobrxfont color=990033gtUsuallY

ships in 24 hoursltBRxfontxnobrgt )

outprintIn(ltbrgt +

rsgetObject(Author) toString() )

outprintIn( +

r s getObject(Publisher)toString() + +

r s getObj ect(PublicationDate) toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

out println ltbrxbrgt )

22

count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()

The servelt EchoServletTag by the business mle that searching a specific table sends a

request query through data access object stmt and gets search result through another

data access object rs It then passes data to the page The content between ltservletgt and

ltservletgt tags in the HTML of home page is replaced by the search result at run time

The center part of the sample result page in Figure 411 is an example

23

Figure 411 The Home Page of Tiny Book Store

gj Search TinybookstGiecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

^ bullgt o a 4 i a a j ugt- a a Back lt7gtn Stop Refresh Home j Search Favorites History Mail Print Etfe

-Six

sfekinlfeSsI 3 Address |iS1 httpiVlocalhosLSOSCVwelcomeshtrnl Cj

f S M B l TinyBookStorecom

Search B o o k sW e l c o m e tc f l i e

HomeFive H ot Books 1 1

Category i-si

IA uthor

Title1 The C + + Programming L a n g u a g e B

Usually ships in 114 hoursISBN

k

IPublisher D a teBjame Stroustrup Addis on-Wesley Pub Co 1997Our Price 3147

m2 Programming Visual C+ +

Usually ships in 24 hours y

David J Krn^dinski Dlicrosoft Press 1998 c damp Local intranet

From this practice we know Server-Side Include not only can produce dynamic portion

of the page but also prevent from other people spy into your code Since Java servlet runs

entirely on a server thus protecting your intellectual property and shielding you from the

browser This means what the client sees can be totally different from what the server

does From the client side it is difficult to figure out how the server works

The left-hand menu items are implemented by using a characteristic of servlet - extra

path information or virtual path The extra path information can be used as a kind of

parameter passed to a servlet In general this extra path information is used to indicate a

24

file on the server that should use for something We use this feature here in an abnormal

way to manage customer requests and process these requests in a single place

Consider a traditional method When a menu item is selected by a customer it redirects

the customer to another page where it hyperlinks to If we have several ten items we

need to pre-create several ten pages This is the disadvantage of static HTML pages

However with servlet which can dynamically generate page content we can direct all the

customer requests to a central servlet and process the requests there according to some

condition (parameters) and then generate the page which customer need to see In this

way we only need one place to hold the code to save serverrsquos space And this place is

easy to maintain

The following is how it was doing for the Tiny Book Store

The Author item uses the following hyperlink

ltA

href = servlet ReqCo 11 ect author gtAuthorlt fontx AxTDgt

ltTRgt

The ReqCollect is the name of a servlet We pass the ldquoauthorrdquo in the hyperlink as a

parameter to ReqCollect When the Author item is selected ReqCollect is invoked by

lava Web Server ReqCollect generates a html page to let a user input author search

condition The ReqCollect code is listed below

25

Example 413 A part of Source Code of ReqCollectjava

public class ReqCollect extends HttpServlet

protected final String AUTHOR = author

public void service(HttpServletRequest req

HttpServletResponse res) throws ServletException

IOException

PrintWriter out = resgetWriter()

String path = reqgetPathlnfo ()

if (path == null)

error handling

else

Create standard header

CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

26

path = pathsubstring(1)

if (pathequalsIgnoreCase(CATEGORY))

Create category request collect

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

outprintln(ltfont color=CC66 0 0

face-verdana arial helvetica size = + lxbgtEnter

Authorltbgtltfontgt )

outprintln(ltbrgt You can enter

authors full name first name or last nameltpgt)

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess

id=forml name=formlgt)

outprintln(lttable border=0gt)

outprintln(lttrgt lttd valign=middle

align = lef txttgtltbgtAuthor ltbxttxtdgt )

outprintln(lttd valign=middle

align = lef txinput type = text name= author size = 40

value=x tdgt )

outprintln(lttrgt)

27

outprintln(lttrgt lttd colspan=2gt ltfont

size=-lgt)

outprintln(ltcentergt ltinput

type=radio name=author_mode value=exact

checkedgt Exact Name)

outprintln(ltinput type=radio

name=author_mode value=lastgtLast First Name (or

Initial) )

outprintln(ltcentergt)

outprintln(ltfontgt)

outprintln(lttdgt lttrgt)

outprintln(lttrgt lttd colspan=2gt ltpgt

ltbrgt lttdgt lttrgt)

outprintln(lttablegt)

outprintln(ltcentergt)

outprintln(ltinput type=submit

value=Search Now id=submitl name=submitlgt)

outprintln(cinput type=reset

value=Clear Form id=resetl name=resetlxpgt )

outprintln(ltcentergt ltformgt)

Create standard footer

28

CreateFooter(out)

outflush()

outclose()

The generated page looks like this

Figure 412 One of The Searching by Author PagesTinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorite l o o k H e lp

^ 3 4 s j ] S o zdStop Refresh Home Search Favorites History Mail Print EditBack bull

I t i h f e l f f httplocalhost8080servletReqCollectauthor

S ea rch Books

Home

C a t e g o r y

Author

Title

ISBN Publisher Date

poundj

TinyBookStore com

You can enter authors foil name first name or last name

A u t h o r jbjarne

C Exact N ame amp Last First N atne (or Initial)

Search Now | Clear Form

Taw boekstofeeoraH om e | Category | A uthor | Title | IS3M | Publisher Date

jpyright and disclaimer copy 1999-2001 F ang Xiao

ihtterteti

42 Design of Search by Different Requests

29

According to different requests the different pages should be produced There are many

common parts in the produced pages So we donrsquot need to code the common parts for

each page We can design the common parts into standard utility classes or static

functions You can simply call the standard classes or functions when you needed them

An example looks like this

CreateHeader(out)

CreateLeftMenu(out)

CreateFooter(out)

The three lines above invoke the standard functions CreateHeader() CreateFooter() and

CreateLeftMenu() which are developed in this thesis writing The CreateHeader()

function produces the top part of the pages The CreateLeftMenu() function produces the

left part of the pages The Createfooter() function produces the bottom part of the pages

You can find the source code in several servlets in Appendix

43 Servlet Chaining To Process Requests In Different Levels

A request can be handled by a sequence of servlets This system is designed to use the

first level servlets to handle the search requests If needed the first level servlets can

cooperates with the second level servlets by passing their processing result to the second

level servlets and let them to proceed the request until the final result is obtained The

final result is returned by the last servlet This is called servlet chaining The request

30

from the client browser is sent to the first servlet in the chain The response from the last

servlet in the chain is returned to the browser In between the output from each servlet is

passed as an input to the next servlet Each servlet in the chain has the option to change

or extend the content W e can see the example in the ReqCollect code

Example 431 A Part of Code of The ReqCollectjava

if (pathequalsIgnoreCase(AUTHOR))

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess id=forml

name=formlgt)

The ReqCollect servlet uses the getPathInfo() method to get the extra path information

This method returns the extra path information associated with request According to the

different extra path information the first level servlet invokes the different servlet of the

second level In this case ReqCollect invokes AuthorProcess servlet The final output

has been listed in Figure 412

31

44 Database Connectivity and Search from Database

The biggest advantage for servlets with regard to database connectivity is that the servlet

life cycle allows servlets to maintain open database connections An existing connection

can trim several seconds from a response time compared to a CGI program that has to

reestablish its connection for every invocation

Another advantage of the servlets over CGI and many other technologies is that JDBC is

database-independent JDBC is a SQL-level API - one that allows you to execute SQL

statements and retrieve the results if any The API itself is a set of interfaces and classes

designed to perform action against any database

An individual database system is accessed via a specific JDBC driver that implements the

javasqlDrivers interface Drivers exist for nearly all-popular RDBMS systems The

database connection used for Tiny Book Store uses a JDBC-ODBC bridge driver coming

along with the JDK 12 to allow access to standard ODBC data source such as the

Microsoft Access database

The first step in using a JDBC driver to get a database connection involves loading the

specific driver class into the applicationrsquos Java Virtual Machine This makes the driver

available later when we need it for opening the connection An easy way to load the

driver class is to use the ClassforNameQ method

32

ClassforName(sunj dbcodbcJdbcOdbcDriver)

When the driver is loaded into memory it registers itself with the javasqlDriverManager

class as an available database driver

The next step is to ask the DriverManager class to open a connection to a given database

where the database is specified by a specified formatted URL The method used to open

the connection is DriverManagergetConnection() It returns a class that implements the

javasqlConnection interface

Connection con =

DriverManagergetConnection(j dbcodbcsomedb

user passwd)

A JDBC URL identifies an individual database in a driver-specific manner Different

drivers may need different information in the URL to specify the host database

During the call to getConnection() the DriverManager object asks each registered driver

if it recognizes the URL If a driver says yes the driver manager uses that driver to create

the Connection object Here is an example

Example 441 A Part of Code of AuthorProcessjava

public void init() throws ServletException

try

ClassforNamesunj dbcodbcJdbcOdbcDriver)

con =

DriverManagergetConnection(j dbcodbcfxbookstore null

null)

catch (ClassNotFoundException e)

catch (SQLException e)

After we got the database connection we need to have some way to execute queries The

simplest way to execute a query is to use the javasqlStatement class Statement objects

are never instantiated directly instead a program calls the createStatement() method of

Connection to obtain a new Statement object

Statement stmt = concreateStatement()

34

A query that returns data can be executed using the executeQuery() method of Statement

This method executes the statement and returns a javasqlResultSet that encapsulates the

retrieved data

Example 442 A Part of Code of AuthorProcessjava

String sqlStmt =

if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where author= + name +II i n

else

sqlStmt = select from BOOK where author like +

name +

ResultSet rs = null

Statement stmt = concreateStatement()

rs = stmtexecuteQuery(sqlStmt)

35

A ResultSet object can be thought as a representation of the query result returned one row

at a time The next() method of ResultSet is used to move from row to row The

ResultSet interface also boasts a multitude of methods designed for retrieving data from

the current row The getStringO and getObject() methods can be used for retrieving

column values

Example 443 A Part of Code of AuthorProcessjava

while (rsnextO )

count++

outprintln(ltdtgtltbgt + count + )

String isbn = rsgetObject(ISBN)toString()

outprintln(lta href=servletDetailContent + isbn +

gt )

outprintln(rsgetObj ect(Title) toString() +

ltagtltbgt)

outprintln (ltnobrxfont color=990033gtUsually ships

in 24 hoursltBRgtltfontxnobrgt)

outprintln(ltddgt +

rsgetObj ect(Author) toString() )

36

outprintln( +

rs getOb j ect ( Publisher) toString () + +

rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

outprintln(ltbrgtltbrgt)

One of the outputs of servlet AuthorProcess is show in Figure 421 and Figure 441

Figure 441 One of The Outputs of Servlet AuthorProcess

37

File Edit View Favorites lo o k - Help M i

T 1 bdquo - 0 L Q 4 pound $ L L lBack r s Stop Refresh Home S earch Favorites History

A - Mail Print

Links rdquo Address | jyen j http7ocalhost808O$ervletAuthorProcess 3

Search B ooks

Home

CategoryA uthor

Title

ISBN

P u b l i sh e r D a te

Tiny Bookstore com

1 The C++ Prograitmuitg Language Usually ships in 24 hour Bjame Stroustrup Addison-Wesley Pub Co i 1997 Our Price 3147

T in yb o oks to re c om H ora e | Category | A uthor | Till | ISBN | Publisher P a t

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top of Page

gk j Local intranet

45 Session Tracking

Session Tracking is one of the most important techniques for any on-line store systems

This is because that HTTP protocol is a stateless protocol A HTTP server sees only a

series of requests and it by itself has no way to know exactly who is making the request

This means that when a customer puts a book in his shopping cart and then goes to other

pages to find more books next time when he puts another book in his shopping cart there

is no guarantee that he puts the book in the same cart It is very possible that he uses

another customerrsquos shopping cart at this time

38

To solve this problem session-tracking is introduced Traditional techniques used by

CGI include hidden form fields URL rewriting user authorization and persistent cookies

For server-side Java applications a built-in class supplied servlet can be used easily to

handle such tasks

When a user first accesses the site web server assigns a new HttpSession object and a

unique session ID to the user The session ID identifies the user and is used to match the

user with the HttpSession object in subsequent requests Usually the session ID is saved

on the client in a cookie or sent as part of a rewritten URL The Tiny Book Store uses this

technique

The Tiny Book Store is a classic shopping cart application A client can put items in his

virtual cart accumulating them until he checks out several page requests later How to

make sure a userrsquos shopping items will be put in his shopping cart or delete from his

shopping cart The Java Servlet API provide built in session tracking to handle this

problem Every user of a site is associated with a javaxservlethttpHttpSession object

that servlets can use to store or retrieve information about that user We can save any set

of arbitrary Java objects in a session object For example a userrsquos session object provides

a convenient location for a servlet to store the userrsquos shopping cart contents An example

shows below

Example 451 A Part of Code of AddToShoppingCartjava

39

1 Get current session object create one if necessary

2 HttpSession session = reqgetSession(true)

3 m_cart = (ShoppingCart)sessiongetValue(cart)

4 if (ra_cart == null) need new cart

5 create a shopping cart

6 m_cart = new ShoppingCart()

7 add to current session

8 sessionputValue(cart m_cart)

9

10

11 try

12 Statement stmt = m_concreateStatement()

13 ResultSet rs = stmtexecuteQuery(select from

book where ISBN= + isbn +)

14 if (rsnext())

15 book - new

BookDetails(rsgetObj ect(ISBN) toString()

16 rsgetObject(Title)toString()

rsgetObj ect(Authorrdquo) toString()

17 rsgetDouble(Price)

rsgetObj ect(PublicationDate) toString() )

18

40

1 9

2 0 catch (SQLException e)

21 e printStackTrace()

22

23 m_cartadd(bookgetlSBN() book)

The servlet uses its request objectrsquos getSession() method to retrieve the current

httpSession object

public HttpSession HttpServeltRequestgetSession (boolean create)

This method returns the current session associated with the user making the request If

the user has no current valid session this method creates one if create is true or return

null if create is false To ensure the session is properly maintained this method must be

called at least once before any output is written to the response Please look at the line 2

in the example 451

If you want to add data to an HttpSession object you can use the putValueQ method

public void HttpSessionputValue(String name Object value)

41

This method binds the specified object value under the specified name Any existing

binding with the same name is replaced This specifies at line 8 of the example 451

If you want to retrieve an object from a session you can use getValue() method

public Object HttpSessiongetValue(String name)

This method specified at line 3 of example 451 returns the object bound under the

specified name or null if there is no binding

From line 4 to line 9 the servlet checks whether the user already has a shopping cart If

the user didnrsquot have a shopping cart the servlet assigns a shopping cart to this user and

add the shopping cart to the current session to keep tracking The ShoppingCartjava class

is developed in this thesis writing code is provided in the appendix

From line 10 to line 21 the servlet knows the user already has a shopping cart m_con is

a data member of AddtoShoppingCart class Lines 12-13 have been discussed in the

previous section Lines 16-20 get some information of the book which the user selected

The information will be the data members of the ldquobookrdquo object that is an instance object

of BookDetailsjava class BookDetailsjava class is developed in this thesis writing the

source code is provided in the Appendix

Line 25 puts the book which is selected by the user into the shopping cart

42

Please see a set of pages are shown below

Figure 451 A Page Show All Information About A Book

TinjiRnfikStnre com - M inrnsnfl Interned Explnrpr

File Edit View Favorites Tools Help-

^ O 4 4 1 f i tStop Refresh Home I Search Favorites History Mail Print Edit

I Link gtgt Address [gl hgtplocalhos9l]IBrit-rvetDetailConetit-Ll20183l)544

S e a r c h B o o k s

Home-

C a t e g o r y

Author

Title

ISSNPublisher Pate

TinyBookStore com

The C++ Programming Languageby Bjarne Stroustrup

aISBN 0201889544 Addison-Wesley Pub Co 1997

Price 3147 Availability U sually ships within 24 hours

Add to cart

Done

R ev iew s

In tins brand-new third edition of The C + + Programming Language author Bjame Stroustrup the creator of C++ presents the full specification for the C++ language and standard library a spec that will soon become the joint ISOANSI C++ standard

g ig L o ca l in tranet

43

Figure 452 A Page Show Items In The Shopping Cart after A User Added Books To The Shopping Cart

H H I H I - I I

j File Edit View Favorites l o o k Help I f

| S ack Stop Refresh Home Search FavoritesJ V

History Wail Print

j Links Address |S1 http7localhost8O80servletAddToShoppingCart i i i i a i i i

( O ldquo ii

Shopping Cart Item s Price

An Introduction to fen e tic Algorithm sMelanie MteheU Quantity 1 Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

drle trgt

delete

delete

Price $ 2 2 0 Subtotal $ 2 2 0

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 6 7 5 6

|euro

rfuj Local intranet

44

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A Book From The Shopping Cart

^ A m a z o n c o m Shopping Cart - Microsoft Internet Explorer

- J A l 4Stop Refresh Home

gtH bdquo ] Back bdquo

httplocalhost8080servletDeleteFromShoppingCartitemgetltem()getlSBN()

Ji _J 3Search Favorites History

j - JMarl Print

~U ccdeg

Shopping Cart Item s

Core Java 2Cay S Horstrnaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d elete

delete

Price

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 4 5 5 6

rsquo0 1 Done gSsfLocat intranet

46 Check Out

This part is designed only using the HTML It collects all information from a user The

information will be written into the database

An important line in this HTML file is shown below

45

ltform method=POST

action=httplocalhost808 0servletCustomerlnfoProcessgt

This line will invoke the servlet CustomerlnfoProcess that will process all data collected

from the user This servlet will discuss in the next section The check out page shows in

Figure 461

Figure 461 A Check Out Page

M M iH M M M i M MmmrnfrnM File Edit View Favorites too ls Help

^ gt a 3 A hi -ltamp f V j HISllll mmB ack S lop R efresh H em e S earch 1 i l lie History M 1 Print Edit

^Links A ddrecs j ig ] h ltp localhostSO SO checkouth tm l i i i l a s

Custom er Information

First name (Fang

Middle initial |a

Last name [Xiao

Email address |fgtdaomitecnet

Account password Jxxxxx

C red it card num ber jl 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7

Credit card type ttV isa O BluebirdO MasterCard O Fisher

Credit card holder jFarig Xiao

Credit card expire date (tnmddyy) joi 0102 ~

Select shipping method t UPS 0 NormalO Express C Abnormal

| | ] Dorraquo raquo f j^ I o c a l intranet

47 Customer Information Processing

The customer information processing is handled by a servlet CustomerlnfoProces Its

source code is provided in the appendix

46

All information collected from the user should be written into the database therefore we

have to open a connection to a given database at first Example 461 is given for this

purpose

Example 471 A Part of Code of CustomerlnfoProcessjava

public void init() throws ServletException

try

ClassforName(sunjdbcodbcJdbcOdbcDriver)

m_con = riverManagergetConnection(jdbcodbcfxbookstore

null null)

catch (ClassNotFoundException e)

e printStackTrace()

catch (SQLException e)

e printStackTrace( )

There is a PO ST request in the check out page The servlet CustomerlnfoProcess will

handle the PO ST request by doPost function which is demonstrated in the following

example

47

Example 472 A Part of Source Code of CustomerlnfoProcessjava

public void doPost (HttpServletRequest req HttpServletResponse res)

throws ServletException IOException

ressetContentType(texthtml)

PrintWriter out = resgetWriter()

get information

String[] values = reqgetParameterValues(firstname)

if (values = null)

firstname = values[0]

values = reqgetParameterValues(middleinit)

if (values = null)

middleinit = values[0]

In the example the HttpServletRequest object res will get each data which was input by

the user by the getParameterValues() function

If the user is a returned user we donrsquot need open a new account again If the returned user

use the same credit card as previous we also donrsquot need to insert the credit card

48

information into the CREDITCARD table Otherwise we should insert all related

information into related table This is shown in the following example

Example 473 A Part of Source Code of CustomerlnfoProcessjava

Statement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where EmailAddress= +

email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext())

sql = insert into CUSTOMERACCOUNT (emailaddress password

firstname middleinit lastname) values ( + + email +

password + + firstname + + middleinit + lastname +

)

stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber= + creditcard

+

rs = stmtexecuteQuery (sql)

if (rsnext())

49

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype

HolderName ExpirationDate) values( + + creditcard + +

cardtype + + cardholder + 11 + expiredate + )

stmtexecute (sql)

All information related the books selected by the user can be obtained from the

shopping cart as shown in the following example

Example 474 A Part of Source Code of CustomerlnfoProcessjava

BookDetails book = null

ShoppingCartltern bookAndQuantity = null

Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getltems()

int aQuantity =0

String alSBN = null

while (itemshasMoreElements())

insert into Orderltems

bookAndQuantity = (ShoppingCartItem)itemsnextElement()

book = bookAndQuantitygetltem()

50

aQuantity = bookAndQuantitygetQuantity()

alSBN = book getISBN()

sql = insert into ORDERITEMS (shoppingCartID ISBN quantity)

values ( + + m_cartID + + aISBN + + aQuantity + )

stmtexecute (sql)

After all information inserted into related tables the servlet CustomerlnfoProcess will

produce invoice page The example page shows in Figure 471

51

Figure 471 An Invoice Page 3 Order List Microsoft Internet Explorer

is File Edit View Favorites Tools Help

J J J U r PS to p Refresh Hom e i -S earch Favorites History s Mai Print

Links Address iff 1 httpVlocalhostBOSOservletCustomerlnfoProcess 3

s5al Local intranet

Y ou r order reads as fo llow sE-MailAddress fiiiaomitecnet

ship to

Tel

Items

F ang Xiao12345 Western Plaza 23OmahaNE68154(402)123-4567

TitleCore Java 2Qtyl Price2579Subtotal2579

TitleJava Servlet PrograrnmingQtyl Price 1977 Sub total 1977 Total4556

i|51 D one

52

Chapter 5

Future Work

In this chapter we discuss two major problems for our future work They are the

Connection Pooling and Object-Oriented for better encapsulation

51 Connection Pooling

After we have used JDBC for a short time it will become evident that the major

performance bottleneck often comes right at the beginning when you are opening a

database connection This is because that opening a connection might involve a series of

low level communications between network protocols and database connection protocols

such as TCPIP ODBC etc

Servlet life cycle allows for extremely fast database access Servlet is loaded into Web

server only once Once it is loaded it can hold a connection to database all its life cycle

Every time it receives a request to read from or write data to database it can just use the

connection to do this

Here comes a problem however Suppose that a customer comes to the on-line store

During the period of selecting some items from the store he leaves his desktop and do

something else leaving this connection to database idling This will waste the precious

resource on the database From database port of view the connection to the database will

assign a space to hold corresponding status and to cache data For example Microsoft

SQL-Servertrade assigns about 36K bytes for each of its connection Resource on the

53

database is limited and idling connection causes such resource unable to be reused for

other users

To solve this problem we can use the technique called connection pooling Essentially a

connection pool is an object holding connections to backend database and managing the

number and status of connections For example if a connection in the pool idles over a

certain time of period the pool can terminate this connection if the requests are not the

same size of the connection pool the pool can dynamically shrink or expand the size of

itself A connection pool can run on a separate thread and is initialized when the server

starts or when a request to database is arrived

To implement a connection pool is pretty straight-forward Because of time constraint

however we did not do it in this paper and leave it as a possible future improvement

52 More Object-Oriented - Better Encapsulation

Another improvement might be done in the future is to create a HTML-related utility

class We have seen in this thesis that there are some duplicated code processing HTML

output such as ldquoout printIn ( lttbxtrgt lttrxtbgt)rdquo All these HTML-

related processes right now are used in a raw way That is they are not encapsulated A

better way to do this is to create a utility class or classes to deal with all HTML-related

processes and hide all HTML tags and format inside the class or classes For example

suppose that we create a Table class then we can use it in a way like

Table table = new Table()

54

table(somerow somecol contents)

table(somerow somecol some_image)

In this way we do not need to use HTML tags in our program and concentrate on the

programming logic The implementation is enriched with more object-oriented property

and therefore it is easy to maintain

55

Chapter 6

Conclusion

The increased awareness and popularity of the Internet make all kinds of electronic

commerce grow vigorously The most popular Web applications are the on-line stores

An on-line store system usually contains four components Web server business

procedure Database system application An on-line store system is different from web

publishing Currently there are three mainstream technologies which are widely used to

develop the on-line store systems CGI Microsoft ASP and Server-side Java application

Introducing the server-side Java application is one of the latest and most exciting trends

in Java programming We have discussed this technology in detail in this thesis The

server-side Java applications have many distinct advantages over CGI and other

technologies We present plenty of examples and figures to analysis the characteristics of

the server-side Java application

As a glance into the future electronic commerce will continue to grow driven by

purchases of home computers and other Web-enabled devices as well as new business

opportunities Electronic commerce is changing whole business procedures The future of

electronic commerce will be exciting and full of opportunities

56

APPENDIX A

Bibliography

57

[1] Karl Moss 1998 Java Servlets Mcgraw-Hill

[2] Jason Hunter William Crawford 1998 Java Servlet Programming O rsquoReilly

[3] Manoj Kumar Anand Rangachari Anant Jhingran Rakesh Mohan 1998 Sales Promitions on the Internet h ttpwwwibmcomiactech-paperhtml

[4] Manoj Kumar Stuart I Feldman 1998 Business Negotiations on the Internet httpwwwibmcomiactech-paperhtml

[5] Manoj Kumar Stuart I Feldman 1998 Internet Auction httpwwwibmcomiactech-paperhtml

[6] Shiwa Fu Jen-Yao Chung Walter Dietrich Vibby Gottemukkala Mitchell Cohen Shyhkwei Chen 1999 A Practical Approach to Web-Based Internet EDI httpwwwibmcomiacpapersicdcsws99indexhtml

[7] Zhong Tian Leo Y Liu Jing Li Jen-Yao Chung Vibby Guttemukkala 1999 Business-to-Business e-Commerce with Open Buying on the Internethttpw w w ibm comi acpapersobi -paperindex html

[8] Gerald J Tesauro Jeffrey O Kephart 1998 Foresight-Based Pricing Algorithms in an Economy os Software Agents http wwwi bm comi actech - paper html

[10] Jeffrey O Kephart James E Hanson Jakka Sairamesh 1998 Price and Niche Wars in a Free-Market Economy o f Software Agents httpwwwibmcomiactech-paperhtml

[11] Jeffrey O Kephart James E Hanson David W Levine Benjamin N Grosof Jakka Sairamesh Richard B Segal Steve R White 1998 Dynamics o f an Information-filtering Economy httpwwwibmcomiactech-paperhtml

[12] James E Hanson Jeffrey O Kephart 1998 Spontaneous Specialization in a Free-Market Economy os Agents httpwwwibmcomiactech-paperhtml

[13] Jakka Sairamesh Jeffrey O Kephart 1998 Price Dynamics o f Vertically differentiated Information Markets httpwwwibmcomiactech-paperhtml

[14] David Kosiur 1997 Understanding Electronic Commerce Microsoft Press

[15] Gunther Birznieks Selena Sol 1997 CGI fo r Commerce MampT Books - A Division of MIS Pres

58

[16] Ravi Kalakota Andrew B Whinston 1997 Electronic Commerce Addison Wesley

[17] Alex Fedorov Richard Harrison Dave Sussman Brian Francis Stephen Wood 1998 Profession Active Server Page 20 Wrox Press

[18] Calvin Austin Minica Pawlan 1999 Writing Advanced Application for the Java PlatformhttpVdeveloper iavasuncomdeveloperonlineTrainingProgrammin gJDCBooki ndexhtml

59

APPENDIX B

The Source Code of An On-Line Store System - Tiny Book Store

60

1 welcomeshtml

lthtmlgtltheadgtlttitlegtSearch Tinybookstorecomlttitlegtltheadgtltbodygt

lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=eeeeccgtlttrgtlttd rowspan=2 align=left valign=top width=15 cellspacing=0 cellpadding=0xIM G border=0 hspace=0 id=IMGl src=flowergif gtlttdgtlttd rowspan=2 align=left valign=centergtltstronggtlth2gtltigtTinyBookStorecomltigtlth2gtltstrongxtdgtlt trx tab legt

lttable border=0 width=100 cellspacing=0 cellpadding=0gtlttrgtlttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtltPgt

lttable width=100 cellspacing=0 cellpadding=5 border=0gtltTRgt ltTDgt ltTDgt ltTD colspan=2gt ltFONT FACE=verdanaarialhelvetica SIZE=-1 gtampnbsp ltFONTgt ltTDgt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD co lsp an = 2 x stro n g x fo n t face=verdanaarialhelvetica size=-lgtSearch B ooksltfontxstronggt ltTDgt ltTRgtltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt ltTD x f o n t face=verdanaarialhelvetica size=-l gt

lta href=w elcom eshtm lgtH om eltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt c T D x fo n t face=verdanaarialhelvetica size=-1 gt

lt A href= servletReqC ol 1 ec tc ategory gtC ate gory ltf o n tx A x T D gtltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollectauthorgtA uthorltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollecttitlengtTitleltorfo n tx A x T D gt ltTRgt

61

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectisbngtISBN ltA xfontxTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectpublisher_dategtPublisherD a telt A x fo n tx T D gtltTRgtlt tab lex p gtlttdgt

lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgtlttd valign=top align=leftgt

ltbr clear=allgtltPgtlt h 3 x s tro n g x fo n t color=ff6347gtWelcome to theltigt T in y B o o k S to rex o m lt ix fo n tx s tro n g x h 3 gt

ltbrgtlt s tro n g x b x h 3 x c e n te rgt F iv e Hot B o o k slt cen te rx h 3 x B x s tro n g gt

ltbrgtltservlet code=EchoServetTag myArgI=myValuel myArg2=myValue2gt ltparam name=myParm 1 value=Hellogtltparam name=myParml value=Worldgtltparam name=myParm2 value=myParmValue2gtltservletgt

lt td x trgt

lttablegt

ltTABLE width=100gtltTRgt ltTD width=50 valign=top align=Ieftgt ltTDgtltTD width=50 valign=top align=rightgtltfont size=-lgtltA href=topgtTop of P ag elt A x fo n tx T D gt ltTRgt

62

ltTABLEgt

ltcentergtltfont size=-lgtltA href=indexhtml gtTinybookstorecom HomeltAgt ampnbsplampnbsp ltA href=categoryhtml gtCategoryltAgt ampnbsplampnbspltA href= author html gtAuthorltAgt ampnbsplampnbspltA href= title html gtTitleltAgt ampnbsplampnbspltA href=7isbnhtml gtISBNltAgt ampnbsplampnbspltA href=publisherhtmrgtPublisher DateltAgtltpgtltfontgtltcentergt

ltPgtltcentergtlt b rx fo n t size=-lgtltA href=copyrighthtml gtCopyright and disclaimerltAgt copy 1999-2001 Fang Xiao ltfontgtltcentergt

ltbodygtlthtmlgt

63

2 AddToShoppingCartjava

ltpgt AddToShoppingCart is the servlet that process the action of adding item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javasql import javautil import javaxservlet import javaxservlethttp

public class AddToShoppingCart extends HttpServlet

protected Connection m_con = null protected ShoppingCart m_cart protected BookDetails book

public void initQ throws ServletException try

Class forName( sunj dbc odbc JdbcOdbcDriver)m_con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintstackTrace ()catch (SQLException e)

e prints tackT race ()

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

String[] params = reqgetParameterValues(isbn)

64

String isbn = get isbn from extra path infomationif (params = null)

isbn = params [0]

Get current session object create one if necessary HttpSession session = reqgetSession(true) m_cart = (ShoppingCart)sessiongetValue(cart)

if (m_cart == null) need new cart create a shopping cart m_cart = new ShoppingCart() add to current session sessionputValue(cart m_cart)

try Statement stmt = m_concreateStatement()ResultSet rs = stmtexecuteQuery(select from book where

ISBN=rsquo + isbn + rsquo)

if (rsnext()) book = new BookDetails(rsgetObject(ISBN)toString()

rsgetObject(TitIe)toStringOrsgetObject( Author) toStringO

rsgetDouble( Price) rs getObj ect( PublicationDate) toStringO)

catch (SQLException e)

eprintStackTrace()m_cartadd(bookgetISBN() book)

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lt h tm lxheadx titlegt T inyB ookS tore com S hopping

Cartlttitlexheadgt)outprintln(ltbody bgcolor=FFFFFF lmk=003399

alink=FF9933 vlink=996633 text=000000ngt)outprintln(lta nam e= topxmdashTop of Pagemdashx a gt )

65

outprin tln(ltpxa href=httplocalhost8080checkouthtmlximg src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=cccc99 gt)ou tp rin tln (lt tdxbrx tdgt )ou tp rin tln (lt tdxbrx tdgt )o u tp rin tln (lt tdxbrx tdgt )outprintln(lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=2xfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=left valign=topxfont

face=verdanaaria lhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=cccc99gt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lt td x b rx td gt ) outprintln(lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantityQ

outprintln(lttr bgcolor=FFFFFFgt) ou tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt )outprintln(ltbrgt + item getltem() get Author()) outprintln(ltbrgtQuantity + itemgetQuantityO) outprintln( ltbrgt) outprintln(lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=POST

action=7servletDeleteFromShoppingCartitemgetItem()getISBN()gt)

66

outprintln(ltpgt cinput type=hidden name=isbn value= + itemgetItem()getISBN())

outprintln(ltpgt ltinput type=submit name=ditemvalue=deletegt)

outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelve tica color=000000gt)

outprintln(ltNOBRgtltbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fon tx bx N O B R gt ltbrgt )

outprintln(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantity() + lt fo n tx b x N O B R x b rgt )

outprintln(ltfontgt) out println( lttdgt)

out printl n( lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)out println( lt fo n tx fo n tgt )outprintln(lttdxtrgt)outprintln(lttablegt)outprin tln(ltpxa href=httplocalhost8080checkouthtmlYximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)outprintln(ltbodygt lthtmlgt)

outflush()outclose()

67

3 AuthorProcessjava

bull ltpgt AuthorProcessbull This is the servlet that process the Author-search request and generatebull search resultbull Author Fang Xiao Purpose Thesis project Copyrightcopy Fang Xiao 1999-2001

import javaxservlet import jav ax servlet http import javaio import javasql

public class AuthorProcess extends HttpServlet protected final String EXACT = ldquoexactrdquo protected final String OTHERS = ldquolastrdquo

protected Connection con = null

public void init() throws ServletException try

ClassforName(ldquosunjdbcodbcJdbcOdbcDriverrdquo)con = DriverManagergetConnection(ldquojdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(ldquotexthtmlrdquo)PrintWriter out = resgetWriterQ

68

String[] valuesString name =

values = reqgetParameterValues(ldquoauthorrdquo) if (values = null)

name = values [0]

String mode = ldquordquovalues = reqgetParameterValues(ldquoauthor_moderdquo) if (values = null)

mode = values [0]

String sqlStmt = ldquordquo if (modeequalsIgnoreCase(EXACT))

sqlStmt = ldquoselect from BOOK where author=rsquordquo + name +else

sqlStmt = ldquoselect from BOOK where author like lsquordquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

ldquoYour Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ldquoltdlgtrdquo) 11 start Glossary List

while (rsnext()) count++outprintln(ldquolt d tx b gt rdquo + count + ldquo ldquo)String isbn = rsgetObject(ldquoISBNrdquo)toString()

69

outprintln(ldquolta href=servletDetailContentrdquo + isbn+

outprintln(rsgetObject(ldquoTitlerdquo)toString() +ldquolt a x b gt rdquo)

outprintln(ldquolt n o b rx fo n t color=990033gtUsually ships in 24 h o u rslt B R x fo n tx n o b rgt rdquo)

outprintln(ldquoltddgtrdquo +rsgetObject(ldquoAuthorrdquo)toString())

outprintln(ldquo ldquo +rsgetObject(ldquoPublisherrdquo)toString() + ldquo ldquo + rsgetObject(ldquoPublicationDaterdquo)toString())

outprintln(ldquoltbrgt Our Price ldquo +rsgetObject(ldquoPrice)toString())

outprintln(ldquolt b rx b rgt rdquo)

if (count == 0) outprintln(ldquoltdtgt No matched data foundrdquo)

outprintln(ldquoltdlgtrdquo) end Glossary List

catch (SQLException e) create footer here outprintln(ldquolttdgt lttrgtrdquo) outprintln(ldquolttablegtrdquo)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(ldquolthtmlgtrdquo) outprintln(ldquoltheadgtrdquo) outprintln(ldquolttitlegt TinyBookStorecom lttitlegtrdquo) outprintln(ldquoltheadgtrdquo)

outprintln(ldquoltbodygtrdquo)

70

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspacing=0 cellpadding=0 bgcolor=rdquoEEEECCYrsquogtrdquo)

outprintln(ldquolttrgtrdquo)outprintln(ldquolttd align=left valign=top width=90 gtrdquo) outprintln(ldquoltIMG border=0 hspace=0 id=IMGl

src=rdquodJavaWebServer20public_htmlflowergifrdquogtlttdgtrdquo) outprintln (ldquolttd width=30gtlttdgtrsquorsquo) outprintln(ldquolttd align=left valign=center width=300gtrdquo)

outprintln(ldquolt stro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x s tro n g x td gt rdquo) outprintln(ldquolttd align=right valign=centergtrdquo) outprintln(ldquolttdgtrdquo) outprintln(ldquolttd w id th= 20x tdgt rdquo) out pri ntln (ldquolttrgtrsquo rsquo) outprintln(ldquolttablegtrdquo)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ldquolttable width= 100gtrdquo)outprintln(ldquolttrgt lttd width=50 valign=top align=leftgt lttdgtrdquo) outprintln(ldquolttd width=50 valign=top align=rightgtrdquo) outprintln(ldquoltfont s iz e = - lx a href=rdquotoprdquogtTop of P agelt ax fon tgt rdquo) outprintln(ldquolttrgtrdquo) outprintln(ldquolttablegtrdquo)

outprintln(ldquoltcentergtrdquo) outprintln(ldquoltfont size=-lgtrdquo) outprintln(ldquolta

href=rdquohttplocalhost 8080welcomeshtmlrdquogtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080$ervletReqCollectcategoryrdquogtCategoryltagtampnbsplampnbsprdquo)

outprintln(ldquoltahref=Yhttplocalhost8080servletReqCollectauthorrdquogtAuthorltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_daterdquogtPublisheramp44Dateltagtrdquo)

outprintln(ldquoltpgtrdquo)

71

outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltpgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquolt b rx fo n t size=-lgtrdquo)outprintln(ldquoltA href=Y7copyrighthtmlrdquogtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiaordquo)outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltbodygtrdquo) outprintln(ldquolthtmlgtrdquo)

i

protected void CreateLeftMenu(PrintWriter out) System out println(ldquoLeftMenurdquo)

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspaeing=0 cellpadding=0gtrdquo)

outprintln(ldquolttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtrdquo)

outprintln(ldquoltpgtrdquo)

outprintln(ldquolttable width=rdquo 100rdquo cellspaeing=0 cellpadding=5border=0gtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquoltfont face=verdanaarialhelvetica SIZE=rdquo- l rdquogtampnbsp

ltfontgtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquolt strongxfon t face=verdanaarialhelvetica size=rdquo-

1 rdquogtSearch B ooksltfontxstronggtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd ldquo) outprintln(ldquoltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080welcomeshtmlYgt H o m elt fo n tx ax td gt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=rdquo-1rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080servletReqColIectcategoryrdquogt C ateg o ry lt fo n tx ax td gtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

72

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectauthorrdquogtAuthorltfontgtltagtlttdgtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width-2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l W rsquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltfontgtltagtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo-lYgtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_dateVrsquogtPublisher Dateltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolt tab lex p gt rdquo)

outprintln(lsquolsquolttdgtrdquo)outprintln(ldquolttd rowspan=4 width=5gtampnbspampnbspltbrgtlttdgtrdquo) outprintln(ldquolttd valign=top align=leftgtrdquo) outprintln(ldquoltbr clear=allgtrdquo)

73

4 BookTeatailsjava

ltpgt This is the class describing a book item in shopping cart

Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class BookDetails private String m_isbn = null private String m_title = null private String m_author = null private double m_price = 00 private String m_year = null

public BookDetails(String isbn String title String author double price String year)

thism_isbn = isbn thism_title = title thism_author = author thism_price = price thism_year = year

public String getISBN() return m_isbn

public String getTitle() return m_title

public String getAuthor() return m_author

public double getPrice() return m_price

ipublic String getYearQ

return m_year

75

5 CategoryProcessjava

ltpgt CategoryProcess This is the servlet that process the Category-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql import javautil

public class CategoryProcess extends FlttpServlet protected final String EXACT = exactprotected final String OTF1ERS = last

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

76

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentType( texthtml)Print Writer out = resgetWriterQ

String[] values String name = String sqlStmt =

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

else

path = pathsubstring(l) if (pathequalsIgnoreCase(cO 1))

sqlStmt = select from BOOK wherecategoryid=rsquo + cOl +

else if (pathequalsIgnoreCase(c02))sqlStmt = select from BOOK where

categoryid=rsquo + c02 +else if (pathequalsIgnoreCase(c03))

sqlStmt = select from BOOK wherecategoryid=rsquo + c03 +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftM enu(out)

Your Book Search Results try

77

if (con = null) Statement stmt = concreateStatement() rs = stmt executeQuery (sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn

+outprintln(rsgetObject(Title)toString() +

lt ax bgt )outprintln(ltnobrxfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltddgt +

rsgetObject( Author)toStringO)outprintln( +

rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)outprintln(ltbrgt Our Price +

rsgetObject( Price) toStringO) ltfont color=990000gtYou Save $1100

(20)ltfontgtoutprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

78

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)out println( lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20publicbdquohtmlflowergifgtlttdgt) outprintln(lttd width=3 0gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln( lt s tro n g x h 2 x igt T inyB ookS to re com lt ix h2x s tro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlngtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

79

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYrsquogtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln( ltfontgt)outprintln(ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rOwspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt)

outprintln(lttablewidth= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=Y2Ygt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y-1 Yrsquogtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2Yrsquogt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=Y-

lYrsquogtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=Y-lYgt)

80

outprintln(ltahref=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqColIectcategorygtCategoryltfontxagtlttdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(nltahref=httplocalhost8080servletReqCollectauthorVrsquogt A u th o rlt fo n tx ax td gtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httpIocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

6 CustomerlnfoProcessjava

ltpgt CustomerlnfoProcessThis servlet is responsible to process userrsquos information when heshe check out

Author Fang Xiao

Purpose Thesis projectCopyright (C) Fang Xiao 1999-2001

import javasql import javaio import j avau til import javaxservlet import javaxservlethttp

public class CustomerlnfoProcess extends HttpServlet protected Connection m_con = null protected HttpSession m_session = null protected static int m_cartID = 1 protected String firstname =protected String middleinit =protected String lastname =protected String email =protected String password =protected String creditcard =protected String cardtype =protected String cardholder =protected String expiredate =protected String shipping =protected String receiver =protected String address =protected String city =protected String state =protected String zipcode =protected String phone =

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)

82

m_con = DriverManagergetConnection(jdbcodbcfxbookstorenull null)

catch (ClassNotFoundException e)

eprintStackTrace()catch (SQLException e)

eprintStackTrace()i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

get informationString[] values = reqgetParameterValues(firstname) if (values = null)

firstname = values [0]

values = reqgetParameterValues(middleinit) if (values = null)

middleinit = values [0]

values = reqgetParameterValues(lastnameM) if (values = null)

lastname = values [0]

values = reqgetParameterValues(email) if (values = null)

email = values [0]

values = reqgetParameterValues(password) if (values = null)

password = values [0]

values = reqgetParameterValues(creditcard)

if (values = null) (creditcard = values [0]

values = reqgetParameterValues(cardtype) if (values = null)

cardtype = values [0]

values = reqgetParameterValues(cardholder) if (values = null) (

cardholder = values [0]

values = reqgetParameterValues(expiredate) if (values 1= null)

expiredate = values [0]

values = reqgetParameterValues(shippingrdquo) if (values = null)

shipping = values [0]

values = reqgetParameter Values (receiver) if (values = null)

receiver = values [0]

values = reqgetParameterValues(address) if (values = null)

address = values [0]

values = reqgetParameterValues(city) if (values = null) (

city = values [0])

values = reqgetParameterValues(state) if (values = null) (

state = values [0]

84

values = reqgetParameterValues(zipcode) if (values = null) (

zipcode = values [0]

values = reqgetParameterValues(phone) if (values = null)

phone = values[0]i

get session object m_session = reqgetSessionQ

try update databaseStatement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where Email Address=rsquo + email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext()) Systemoutprintln(insert customeraccount)

sql = insert into CUSTOMERACCOUNT (emailaddress password firstname middleinit lastname) values ( +

+ email + + password + + firstname +V + middleinit + + lastname + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber=rsquo +creditcard +

rs = stmtexecuteQuery (sql)

if (rsnext()) Systemoutprintln(insert creditcart)

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype HolderName ExpirationDate) values( +

+ creditcard + + cardtype + +cardholder + + expiredate + rdquo)

Systemoutprintln(sql)stmtexecute (sql)

i

85

sql = insert into SHOPPINGCART (ShoppingCartIDEmail Address CreditCardNumber ShippingType ReceiverName ReceiverAddress ReceiverCity ReceiverState ReceiverZipcode ReceiverPhone) values ( + m_cartID + V + email + Vrdquo +

creditcard + V + shipping + + receiver ++ address + V +

city + V + state + V + zipcode + V + phone +gt gt

Systemoutprintln(sql)stmtexecute (sql)

BookDetails book = nullShoppingCartltem bookAndQuantity = null Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

int aQuantity =0 String alSBN = null

while (itemshasMoreElementsO) insert into Orderltems bookAndQuantity =

(ShoppingCartItem)itemsnextElement()book = bookAndQuantitygetItem()

aQuantity = bookAndQuantitygetQuantity() alSBN - book getISBN()

Systemoutprintln(insert Orderltems)sql = insert into ORDERITEMS (shoppingCartED ISBN

quantity) values ( + m_cartID + +alSBN + + aQuantity + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

im_cartID++ must increase by one

86

catch (SQLException e) eprintS tackTrace()

printOrder(out)

public void printOrder(PrintWriter out) outprintln( lthtmlgt ltheadgt lttitlegt Order List lttitlegt ltheadgt) outprintln( ltbodygt)outprintln(lthlgt Your order reads as follows lthlgt)outprintln(lttablegt)outprintln( lttrgt)outprintln( lttdgtE-Mail Addres s lttdgt) outprintln(lttdgt+ em ail+lttdxtrgt) outprintln(lttrgt) outprintln(lttdgtship tolttdgt) outprintln(lttdgt+ receiver +ltbrgt) outprintln(address +ltbrgt) outprintln(city +ltbrgt) outprintln(state +ltbrgt) outprintln(zipcode + lt b rx td x trgt ) outprintln(lttrgt) outprintln( lttdgtTel lttdgt) outprintln(lttdgt+ phone +lttdxtrgt) outprintln(lttrgt) outprintln( lttdgtItems lttdgt)

BookDetails book = nullShoppingCartltem bookAndQuantity = nullEnumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

double total = 00

while (itemshasMoreElements()) bookAndQuantity = (ShoppingCartItem)itemsnextElement()

total += bookAndQuantitygetItem()getPrice() bookAndQuantitygetQuantityO

book = bookAndQuantitygetltem()

87

outprintln(lttdgtTitle+ bookgetTitle() + Qty + bookAndQuantitygetQuantity() + ltbrgt)

outprintln(Price + bookgetPrice() + Subtotal + bookAndQuantitygetQuantityO bookgetPrice() +ltbrgt)

outprintln(Total + total )outprintln(lttdxtrgt)outprintln(lttablegt)outflush()outclose()

7 DeleteFromShoppingCartjava

ltpgt DeleteFromShoppingCart is the servlet that process the action of deleting item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javautil import javaxservlet imp ort j avax servlet http

public class DeleteFromShoppingCart extends HttpServlet

protected ShoppingCart m_cart protected BookDetails book

public void doPost(HttpServletRequest req FIttpServletResponse res) throws ServletException IOException res setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String[] params = reqgetParameterValues(isbnrsquo) String isbn = get isbn hidden fieldif (params = null)

isbn = params [0]

Systemoutprintlnfisbn = + isbn)

Get current session objectHttpSession session = reqgetSession()m_cart = (ShoppingCart)sessiongetValue(carf)

m_cartremove(isbn)

89

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lthtm lgtltheadxtitlegtAm azoncom Shopping

C artlt titlexheadgt)out pri ntln ( ltb ody bgcolor=FFFFFF link=003399

alink=FF9933 vlink=Yrsquo996633Y text=rdquo000000rdquogtrdquo)outprintln(lta nam e= top xmdashTop of Pagemdashx a gt ) ou tp rin tln (lt pxa href=httplocalhost8080checkouthtmlximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=Yrsquocccc99Yrsquo gt)ou tp rin tln (lt tdxbrx tdgt )out pri ntln ( lt td x b r x td gt )outprintln( lt td x b r x td gt )out println (rsquo1 lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=Y2Yxfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=YleftY valign=YtopYxfont

face=verdanaarialhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=Ycccc99Yrsquogt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantity()

outprintln(lttr bgcolor=FFFFFFgt) o u tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt)outprintln(ltbrgt + itemgetItem()getAuthor())

90

outprintln(ltbrgtQuantity + itemgetQuantityO)outprintln(ltbrgt)outprintln( lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=VPOST

action=7servletDeleteFromShoppingCartVgt)outprintln(ltpgt ltinput type=hidden name=isbn value= +

itemgetItem()getISBN())outprintln(ltpgt cinput type=submit name=ditem

value=Y rsquo deletegt rsquo rsquo)outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelvetica color=000000gt)

outprintln(ltNOBRxbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fo n tx b x N O B R x b rgt )

outprintin(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantityO + lt fo n tx b x N O B R x b rgt )

outprintln( ltfontgt) outprintln( lttdgt)

i

outprintln(lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)outprintln(ltfontxfontgt)outprintln( lt td x trgt ) outprintln(lttablegt)ou tp rin tln (lt pxa href=Yhttplocalhost8080checkouthtmlYximg

src=YdYJavaWebServer20servletsimageproceed-to-checkoutgifYxagt)outprintln(ltbodygt lthtmlgt)

outflushOoutcloseQ

91

8 Detailcontentjava

ltpgt DetailContent is the servlet responsible for generating detailed information page for a book The book is identified by its ISBN Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaio import javasql import jav ax servlet import javaxservlethttp

public class DetailContent extends FIttpServlet protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String isbn = reqgetPathInfo()isbn = isbnsubstring(l) skip over rsquo rsquo

92

try String sql = select from book where ISBN=rsquo + isbn +

Statement stmt = concreateStatement()ResultSet rs = stmtexecuteQuery(sql)

create header here CreateHeader(out)

create left menu here CreateLeftMenu(out)

outprintlnfctd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintlnfctd valign=top align=leftgt)

cellpadding=0gt)

outprintln(ltbrgt)

create detailcontent here while (rsnext())

String strlSBN = rsgetObject(ISBN)toString() outprintln(lttable width=100 border=0 cellspacing=0

+ltbgtlttdxtrgt)

+ lt tdx trgt)

outprintln(lttrgt lttd colspan=3 align=leftxbgt) outprintln( rsgetObject(Title)toString()

outprin tln(lt trxtd colspan=3 align= leftxbgt by ltbgt) out println( rs getObj ec t( Author) toS tringQ

cellpadding=0gt)

outprin tln(lt trx td x i m g src=xtdgt) outprintln( lttd valign=topgt) outprintln( lttable border=0 cellspacing=0

outprintln( lt t r x td valign=topxbgtPrice )outprintln(

rsgetObject(Price)toString() + lt b x td x trgt ) outprintln(

lt trx td x b gt A v ailab ility lt b gt U su a lly lt td x trx b rgt )outprintln( lt t r x td vlign=topgtships within 24

hou rs lt td x trgt )outprintln( lt tab lextdgt)

93

outprintln( lttd align=rightgt) outprintln( lttable border=0 cellspacing=0

cellpadding=0gt)outprintln( lt trx td gt )outprintln( ltform

method=POST action=httplocalhost8080servletAddToShoppingCartgt)outprintln( ltinput

type=hidden name=isbn value= + strlSBN +outprintln( cinput

type=submit value=Add to cart )outprintln( lt tdx trgt )

outprintln( lt tab lex tdgt ) outprintln(rdquolttrgt)outprintln(lttrgt lttd clospan=3 align=leftgt ISBN ) outprintln( strlSBN +lttdxtrgt)outprintln(lttrgt lttd clospan=3 align=leftgt) outprintln( rsgetObject(Publisher)toString()

+rsgetObject(PublicationDate)toString() + lt tdx trgt )outprintln(lttablegt)outprintln(ltbrgt)outprintln(ltbrgt)

output reviewString review = rsgetObject(BookReview)toString() if (review = null)

review =DJavaWebServer20servletsreview + review

outprintln(ltbgtReviewsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(review))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprin tin (thisLine) ou t println( ltpgt)

)

icatch (IOException e)

need do something here eprintstackTrace ()

94

outprintln(ltbrgt)String comment =

rsgetObject(BookComment)toString()if (comment = null) comment = DJavaWebServer20servletscomment +

commentoutprintln(ltbgtReader Commentsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(comment))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprintln(thisLine) outprintln(ltpgt)

catch (IOException e)

need do something here eprintstackTrace ()

ou t pri ntln ( ltb rgt)

catch (SQLException e)

need to do something here

add table end tab outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt)

95

ou t pri ntln ( lthe adgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=YTOO cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d J avaW eb S erver 2 Opublic_htmlflo wer gif gtlttdgt) outprintln(lttd width=30gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyBookStorecomltigtlth2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln( lttd width=20gtlttdgt) out pri ntln ( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-1 gt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

96

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsptampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out prin tin ( ltcen tergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

eellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=Yhttplocalhost8080Avelcom eshtm lgtHom eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-1gt)

97

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=http7localhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref-httpIocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lVgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

98

9 EchoServlettagjava

import javaio import j avasql import javaxservlet import javaxservlethttp

public class EchoServletTag extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintStackTrace ()catch (SQLException e)

eprintStackTrace()

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

try Statement stmt = concreateStatementQResultSet rs = stmtexecuteQuery(select from book where title

like rsquoProgrammingrsquo)int count = 1outprintln(ltdlgt)while (rsnext() ampamp count lt 6)

outprintln(ltdtxbgt + count + )

99

String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn + outprintln(rsgetObject(Title)toString() + lt ax bgt ) outprintln(ltddxnobrgtltfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltbrgt + rs getObject( Author) toStringO) outprintln( + rsgetObject(Publisher)toStringO +

+ rsgetObject(PublicationDate)toStringO)outprintIn(ltbrgt Our Price +

rsgetObject(Price)-toStringO)

out println( lt b rx b rgt ) count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()outprintln(lttdgt lttrgt) outprintln(lttablegt) outflush() outcloseO

ii

100

10 ISBNProcessjava

ltpgt ISBNProcess This is the servlet that process the ISBN-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javax servlet import javaxservlethttp import javaio import j a vasql

public class ISBNProcess extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forN ame( sun j dbc odbc J dbcOdbcDri ver)con = DriverManagergetConnection(j dbc odbc fxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s s e tC on te n tTy pe ( tex th tm l)PrintWriter out = resgetWriter()

String[] values

String alSBN =

values = reqgetParameterValues(isbn) if (values = null)

alSBN = values [0]

String sqlStmt = select from BOOK where ISBN= + alSBN

ResultSet rs = null int count = 0

create header here bullCreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject( IS BN) toStringO

outprintln(lta href=servletDetailContent + isbn+ gt)

outprintln(rsgetObject(Title)toStringO +lt ax bgt )

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toStringO)

outprintln( +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

102

outprintln(ltbrgt Our Price +rsgetObject(rdquoPrice) toStringO)

outprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width= 100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d Uava WebS erver2 Opubhc_htmlflo wer gif gtlttdgt) outprintln(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS tore com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt)

103

out println( lttdgt) outprintln(lttd w id th= 20x tdgt ) out pri ntln( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)out pri ntln (lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) out pri ntln ( lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsp1ampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out println( ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

104

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 eellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Books lt fontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocaihost8080servletReqCollectcategorygtCategoryltfontxaxtdgt lttr gt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

105

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lttablegtltpgt)

o u t println( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

ii

106

11 PublisherDataProcessjava

ltpgt AuthorProcess This is the servlet that process the PublisherampDate-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql

public class PublisherDateProcess extends FIttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbc odbc JdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentT ype ( texthtml)PrintWriter out = resgetWriterQ

String[] valuesString namel =

107

values = reqgetParameterValues(publisher) if (values = null)

nam el = values [0]

String name2 =values = reqgetParameterValues(rdquopublication_date) if (values = null)

name2 = values [0]

String sqlStmt =sqlStmt = select from BOOK where publisher=rsquo + namel + rsquoand

publicationdate=rsquo +name2

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprin tln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toStringO outprintln(lta href=servletDetailContent + isbn

+ gt)outprintln(rsgetObject(Title)toString() + (

lt ax bgt )

108

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rs getObj ect( Author) toS tring())

outprintln(V +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

outprintln(ltbrgt Our Price +rsgetObject( Price) toStringO)

outprintln( lt b rx b rgt )

if (count == 0) (outprintln(ltdtgt No matched data found)

outprintln(rdquoltdlgt) end Glossary List

catch (SQLException e) ( create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 celipadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt)

109

outprintln(ltIMG border=0 hspace=0 id=IM Gl src=dJavaW ebServer20public_htmlflowergifxtdgt)

outprintln(lttd width=3 0 x td gt ) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS to re com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ctable w idths 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt) outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) ou t println( ltcentergt)

no

outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaim er^A gt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) out pri ntln ( lthtml gt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-1 gtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=V-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-1gt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

I l l

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitleYrsquogt T itle lt fo n tx a x td gt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(nltahref=Yhttplocalhost8080servletReqCollectisbnY gtISBNltaxfontxtdgt lttrgt)

outprindn(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdana arial helvetica size=Y -1 gt)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYgtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

1 12

12 ReqCollectjava

ltpgt This is a servlet responsible for generating search request collection page It read extra path information from URL and then according to the extra path information it generates corresponding page format Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001import javaxservlet import javaxservlethttp import javautil import javaio

public class ReqCollect extends HttpServlet

protected final String CATEGORY = categoryrdquo protected final String AUTHOR = author protected final String TITLE = titlerdquo protected final String ISBN = isbnprotected final String PUBLISHER_DATE = publisher_date

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentType( texthtml)PrintWriter out = resgetWriter()

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

)else

Create standard header CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

path = pathsubstring(l) if (pathequalsIgnoreCase(CATEGORY))

I I Create category request collect

outprintln(ltpgt)outprintln(lth3xstronggtProgrammingltstronggtlth3gt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc01gtAlgorithmsltagt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc02gtCampC++ltagt)outprintln( Delphi) outprintln(lta

href=httplocalhost8080servletCategoryProcessc03gtJavaltagt)outprintln( MFC Perl)

outprintln(software Design UML Visual Basic More)

outprintln(lth3xstronggtW eb Developm entltstrongxh3gt) outprintln(ASP Commercem Cyberculture HTML

JavaScript)

outprintln(Security Web Design XML more)

outprintln(lth3xstronggtGraphics amp Softwareltstrongxh3gt) outprintln(Asobe CAD Desktop Publishing Graphics)

outprintln(Microsoft More)

outprintln(lth3xstronggtNetW orking amp O Sltstrongxh3gt) outprintln(Linux Macs Oracle PCs SAp R3 SQL)

outprintln(TCPIP Unix WindowsampDOS W indowsNT)

out println( More)

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

1 14

outprintln(ltfont color-CC6600 face=verdana arial helvetic a size=+1 gtltbgtEnter Authorltbgtltfontgt)

outprintln(ltbrgt You can enter authorrsquos full name firstname or last nameltpgt)

outprintln(ltform method=POST action=httplocalhost 8080servletAuthorProcessY id=form 1 name=form 1 gt)

outprintln( lttable border=0gt) outprintln(lttrgt lttd valign=middle

ahgn= leftx ttx b gt A u th o rlt b gt lt ttx td gt )outprintln(lttd valign=middle align= leftx input

type=YtextY name=author size=40 value=YYxtdgt)outprintln(lttrgt)outprintln(lttrgt lttd colspan=2gt ltfont size=-lgt) outprintln(ltcentergt ltinput type=radio

name=Yauthor_modeY value=YexactY checkedgt Exact Name)outprintln(ltinput type=radio name=author_mode

value=lastgtLast First Name (or Initial))outprintln(ltcentergt) outprintln(ltfontgt) outprintln(lttdgt lttrgt)outprintln(lttrgt lttd colspan=2gt ltpgt ltbrgt lttdgt lttrgt)outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search NowY

id=submitl name=submitlgt)outprintln(cinput type=reset value=YClear Form

id=resetl nam e= rese tlxpgt )outprintln(ltcentergt ltformgt)

else if (pathequalsIgnoreCase(TITLE))

Create title request collect

outprintln(ltfont color=CC6600 face=verdanaarialhelvetica s ize= + lxbgt E n ter T itlelt bxfontgt)lsquo

outprintln(ltbrgtYou can enter the exact title or part oftitleltPgt)

outprintln(ltform method=YPOSTY action=Yhttplocalhost8080servletTitleProcessY id=form l name=formlgt)

outprintln(lttable border=0gt) outprintln(lt trxtd valign=middle

a lig n = le ftx ttx b gt T itle lt b x t tx td gt )

115

outprintln(lttd valign=middle align= leftx input type=text name=title size=40 value=xtdgt)

outprintln(lttrgt) outprintln(lttrgt) outprintln( lttd colspan=2gt) outprintln( ltfont size=-lgt) outprintln( ltcentergt)outprintln( ltinput type=radio name=title-mode

outprintln(value=exact checkedgt) outprintln( Exact Title)outprintln( ltinput type=radio name=title-mode

outprintln( value=titlewords gt ) outprintln( Title Words )outprintln(ltcentergt ltfontgt lttdgt lttrgt)outprin tln(lt trxtd c o ls p a n = 2 x p x b r x td x tr gt ) outprintln(lttablegt)

outprintln(ltcentergt)outprintln( ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln( ltinput type=reset value=Clear Form

id=resetl nam e= resetlxP gt )outprintln(ltcentergt) ou t println ( ltformgt)

outprintln(lthr noshade size=lgt)

outprintln(ltBgtExamplesltBgt)outprintln(ltULgt)outprintln(ltLIgtEntering ltbgtampquotJava Servlet

Programmingampquotltbgt in the title field )outprintln(and choosing ltemgtExact Titleltemgt finds the

book without also finding the many books)

outprintln(ltLIgtEntering ltbgtampquotJavaampquotltbgt in the Title field and choosing ltemgtTitle Wordsltemgt)

outprintln( finds all books whose title are related toltigtJavaltigt)

outprintln(ltULgt)

out printl n( lttdgtlttrgt) outprintln(lttablegt)

ielse if (pathequalsIgnoreCase(ISBN))

Create isbn request collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n ter ISBN ltbxfontgt)outprintln(ltbrgt) outprintln(ltform method=POSTY

action=httplocalhost8080servletISBNProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

a lig n = le ftx ttx b gt IS B N lt b x t tx td gt ) outprintln(lttd valign=middle a lign= leftx input

type=text name=isbn size=40 value=xtdgt)outprintln(lttrgt)

outprin tln(lt trxtd c o ls p a n = 2 x p x b rx td x trgt ) outprintln(lttablegt)

out println( ltcentergt)outprintln(ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln(ltinput type=reset value=Clear

FormV id=resetl nam e= resetlxP gt )outprintln(ltcentergt)outprintln(ltformgt)

outprintln(lthr noshade size=lgt)

outpiintln(ltULgtrdquo)outprintln(lttdxtrgt)outprintln(lttablegt)

else if (pathequalsIgnoreCase(PUBLISHER_DATE))

Create publisher date collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n te r Publisher and Publication D ate ltb gtltfontgt)

1 17

outprintln( ltbrgt) outprintln(ltform method=POST

action=httplocalhost8080servletPublisherDateProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

align=leftgtlt ttxbgt P ub lisher lt b x t t x t d gt )outprintln(lttd valign=middle align= leftx input

type=text name=publisher size=40 value=xtdgt)outprintln(lttrgt) outprintln(lttrgt lttd valign=middle

a lign= leftx ttxbgt P ub lica tion D a te lt b x ttx td gt )outprintln(lttd valign=middle align= leftx input

type=text name=publication_date size=40 value=xtdgt)outprintln(lttrgt)outprintln( c t r x td c o l s p a n = 2 x p x b r x td x t r gt )outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search Now

id=submitl name=submitlgt)outprintln(ltinput type=reset value=VClear FormYrsquo

id=resetl nam e= resetlxpgt )outprintln(ltcentergt) outprintln(ltformgt) outprintln(lthr noshade size=lgt)

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush()outclose()

)

protected void CreateHeader(PrintWriter out) outprintln(lthtmigt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding bgcolor=EEEECCgt)

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20pubiic_htmlflowergifgtlttdgt) outprindn(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(lt s tro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x stro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt)outprintln(lttd w idth=20xtdgt) ou t println ( rsquo lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

out pri ntln ( ltfon tgt) outpri ntln( ltcentergt ) out pri ntln ( ltpgt) outprintln(ltcentergt) outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)out pri ntln ( ltf on tgt) outprintln(irltcentergt) out println ( ltbodygt) out pri ntln( lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

cellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=YT00 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE= -lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

1 gtS earch B ookslt fontx stronggt)outprintln(lttdgt lttrgt)out pri ntln (lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=l-lgt)

outpri ntln(ltahref=httplocalhost8080servletReqCoilectauthorgtA uthorltfontxaxtdgtlttrgt)

120

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprindn(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=V-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln(lttablexpgt)outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

121

13 ShoppingCartjava

ltpgt This is the definition for ShoppingCart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import Javautil

public class ShoppingCart Hashtable items = null int numberOfltems = 0

public ShoppingCart() items = new Hashtable()

add BookDetails to cart param bookID isbn param book book need to be added to cart copyreturn void

public void add(String bookld BookDetails book) if(itemscontainsKey(bookId))

ShoppingCartltem scitem = (ShoppingCartltem)itemsget(bookld) scitemincrementQuantity ()

else ShoppingCartltem newltem = new ShoppingCartltem(book) itemsput(bookId newltem)

numberOftems++

param bookld isbn

public void remove(String bookld) if(itemscontainsKey(bookd))

items remove (bookld) numberOfltems - -

public Enumeration getltems() return itemselements()

protected void finalize() throws Throwable items clear()

public int getNumberOfItems() return numberOfltems

public void clear() items clear() numberOfltems = 0

123

14 ShoppingCartltemjava

ltpgt This is the definition for the shoppingcart item Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class ShoppingCartltem BookDetails item int quantity

public ShoppingCartItem(BookDetails anltem) this item = anltem this quantity = 1

public void decrementQuantity() if (quantity gt 0)

quantitymdash

public void incrementQuantity() thisquantity++

i

public BookDetails getltem() return thisitem

public int getQuantity() ( return thisquantity

i

124

15 StandardFooterjava

package servlets

import j avax servlet

ltpgt This is a server side include servlet that will format the TinyBookStore HTML footer

public class StandardFooter extends GenericServlet

ltpgtPerform the servlet service

param req The request from the client param res The response from the servlet public void service (ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the response javaioPrintW riter out = new

javaioPrintWriter(resgetOutputStream())

Format the standard footeroutprintln(ctable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(rdquoltfont s iz e = - lx a href=topgtTop of

P agelt ax fon tgt )outprintln(lttrgt) out println( lttablegt) outprintln(ltcentergt) outprintln(rsquoltfont size=-lgt)outprintln(lta href=7welcomeshtmlYgtTinybookstorecom

Homeltagt ampnbsplampnbsp)outprintln(lta href=categoryhtmlgtCategoryltagt

ampnbsplampnbsp)outprintln(lta href-authorhtmlgtAuthorltagt

ampnbsplampnbsp)outprintln(lta href=titlehtmlrdquogtTitleltagt ampnbsplampnbsp)

125

outprintln(lta href=isbnhtmlgtISBNltagt ampnbsplampnbsp) outprintln(lta href=7publisherhtmlgtPublisheramp44

Dateltagt)outprintln(ltpgt)outprintln(ltfontgt)ou t println ( ltcen tergt)outprintln(ltpgt)out println (ltcentergt )outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and

disclaim er^A gt ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln( ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

outflush()outclose()

126

16 StandardHeaderjava

package servlets

import javaxservlet

ltpgt This is a server side include servlet that will format the standard TinyBookStore HTML header The Title of the page will be set to the value of the title property

public class StandardHeader extends Generic Servlet

ltpgt Performs the servlet service param req The request from the client param res The response from the servlet

public void service(ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the responsejavaioPrintWriter out = new javaioPrintWriter(resgetOutputStream())

Get the title of the page Set to empty string if no title parameter was givenString titles[] = reqgetParameterValues(title)String title = if (titles = null)

if (titleslength gt 0) title = titles [0]

outprintln(lthtmlgt) outprintln(ltheadgt) outprintln(lttitlegt + title + lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=T00 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)

127

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src=dJavaWebS erver2 Opublic_htmlflower gi A gtlttdgt) out println(lttd width=3 O x td gt ) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyB ookStorecom ltigtlth2xstrongxtdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) out printl n ( lttd width=20gtlttdgt) out printl n( lttrgt) outprintln(lttablegt)

outflush()outclose()

128

17 TitleProcessjava

ltpgt TltleProcess This is the servlet that process the Tltle-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import j avax servlet import javaxservlethttp import javaio import j avasql

public class TitleProcess extends HttpServlet protected final String EXACT = exact protected final String OTFIERS = titleWords

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

129

String[] valuesString name =

values = reqgetParameterValues(title) if (values = null)

name = values [0]

String mode =values = reqgetParameterValues(title_mode) if (values = null)

mode = values [0]

String sqlStmt =if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where title=rdquo + name +else

sqlStmt = select from BOOK where title like rsquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString()

130

outprintln(lta href=servletDetailContent + isbn+

outprintln(rsgetObject(Title)toString() +ltagtltbgt)

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toString())

outprintln( +rsgetObject(Publisher)toString() + + rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +rsgetObject(Price)toString())

outprintln(ltbrxbrgt)i

if (count == 0) outprintln(ltdtgt No matched data found)

ioutprintln(ltdlgt) II end Glossary List

catch (SQLException e) i create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

131

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=EEEECCgt)

outprintln(rdquolttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaW ebServer20public_htmlflowergifxtdgt) outprintln(lttd w idth=30xtdgt) outprintln(rdquolttd align=left valign=center width=300gt)

outprintln(ltstronggtlth2gtltigtTinyBookStorecomltixh2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(rdquolttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln( lttrgt)outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(rdquolta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(rdquoltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

132

out println( ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) outprintln( ltcentergt) outprin tln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disciaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) S y s te m out println( LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt )

outprintln(lttable width= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y- lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost 8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

133

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lt tab lex pgt )

ou t pri ntl n ( lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

134

18 checkouthtml

lthtmlgtltheadgt lttitlegtCustomer Informationlttitlegt ltheadgtltbodygt

lt hlgt ltcentergt ltbgt Customer Information ltbgt ltcentergt lt hlgt

ltform method=POST action=httplocalhost8080servletCustomerInfoProcessgt lttable border=0gt

lttrgtlttd align=rightgtFirst namelttdgtlttd colspan=2 align= leftx input type=text name=firstname size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtMiddle initiallttdgtlttd colspan=2 align= leftx input type-text name=middleinit s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtLast namelttdgtlttd colspan=2 align= leftx input type-text name=lastname size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtEmail addresslttdgtlttd colspan=2 align= leftx input type=text name=email s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgt Account pass word lttdgtlttd colspan=2 align= leftx input type=text name=password s ize= 40x tdgt

lttrgtlttrgt

lthrgtlttrgt

lttablegtltbrgt

ctable border=0gtlttrgt

lttd align=rightgtCredit card numberlttdgtlttd colspan=2 align= leftx input type=text name=creditcard s ize= 40x tdgt

lttrgtlttr valign=topgt

135

lttd align=rightgtCredit card typelttdgtlttd align=leftgtltinput type=radio name=cardtype value=visagtVisaltbrgtltinput type=radio name=cardtype value= mastercard gtMasterCardltbrgt lttdgtlttd align=leftgtltinput type=radio name=cardtype value=bluebirdgtBluebirdltbrgtltinput type=radio name=cardtype value=fishergtFisherltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtCredit card holderlttdgtlttd colspan=2 a lign= leftx input type=text name=cardholder s ize= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCredit card expire date (mmddyy)lttdgtlttd colspan=2 align= leftx inpu t type=text name=expiredate size= 40x tdgt

lttrgtlt trx trgtlt trx trgtlttr valign=topgt

lttd align=rightgtSelect shipping methodlttdgtlttd align=leftgtltinput type=radio name=shipping value=upsgtUPSltbrgtltinput type=radio name=shipping value=expressgtExpressltbrgtlttdgtlttd align=leftgtcinput type=radio name=shipping value=normalgtNormalltbrgtltinput type=radio name=shipping value=abnormalgtAbnormalltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtReceiver Namelttdgtlttd col span=2 a lign= leftx inpu t type=text name=receiver size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtAddresslttdgtlttd colspan=2 align= leftx input type=text name=address size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCitylttdgtlttd colspan=2 align= leftx inpu t type=text name=city size= 4 0 x td gt

lttrgtlttrgt

136

lttd align=rightgtStatelttdgtlttd colspan=2 align= leftx inpu t type=text name=state s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtZipcodelttdgtlttd colspan=2 align= leftx inpu t type=text name=zipcode size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtPhonelttdgtlttd colspan=2 align= leftx input type=text name=phone size= 40x tdgt

lttrgtlttablegtlt b rx b rgtcinput type=submit value=Process name=actiongt

ltformgt

ltbodygtlthtmlgt

137

APPENDIX C

Screen Display of the Test

138

mmm File Edit View Favorites T o d s Help

^ Jit j j ^ LJ U 3) ~ pound=J _Am Back - S top Refresh Home j Search Favorites History Mait Print Edit

Links gtgt Address |4S ] httDVIocalhost808QAvdcorne shtml

TinyBookStore com

Welcome to the TJnyBoakStoro com

F i v e H o t B o o k s

1 T h e C + + Programming LanguageU s u a l l y s h i p s i n 24 h o u r s

B j a r n e S t r o u s t r u p A d d i s o n - W e s l e y Pub Co 1997 Our P r i c e 31 47

2 - P r o g r a m m i n g V i s u a l C + +U s u a l l y s h i p s i n 24 h ou r I I

Local intranet

Search BooksHorne

Category

Author

Title

ISBNPublisherDate

3 iigt60

3 1 S earch T inybooksloiecom - Microsoft Internet Explorer

139

T inyB ookStorecom - Microsoft Internet Explorer

j File Edit View Favorites lo o k Help

q a a H 3 1 d B ack S top R efresh Home S earch Favorite History j M aJ Print

Links gtgt A ddress httpV localhost 308QoryleV PetailCorterV 020i8SC l4

MM

Edit

Search Books

Home

Category

Author

Title

ISBN

PublisherDate

TinyBookStore com

The C++ Programming Languageby B j a r n e S t r o u s t r u p

0

ISBN 0 2 0 1 8 8 9 5 4 4 A d d i s o n - W e s 1e y P ub Co 199 7

Reviews

P r i c e 31 47A v a i 1ab i 1i t y U s u a l 1 ys h i p s w i t h i n 24h o u r s

Aic t o c a r t

ijgJ Local intranet

140

^ | I myBook5torecom Shopping Cart - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

[v] I ^ -J JB ack - Stop R efresh Home S earch Favorites History lsquo Mail Print

Links A ddress 0 1 h ttp localhost8080servetA ddT oShoppingCart ~3 ltGdeg

Shopping Cart Item s Price

The C++ Programmi ng LanguageB j a r n e S t r o u s t r u p Q u a n t i 1 7 1

Price $ 3 1 4 7 Subtotal $ 3 1 4 7

d e l e t e

Total 31 47

Customer Information Microsoft Internet Explorer

File Edit View Favorites lo o ls Help bull _

bullgt 3i 4 n j j d a 31Back ~-j Stop- R efresh Home S earch Favorites History j Mail Print Edit

Link gtgt j Address ] j j h ttplocalhost SOSOcheekoot html

EMH1

~3

Customer Information

First name jFang

Middle initial |a

Last name Xiao

Email address fxiaomitecnet

Account password pooooc

0 1 Done

Credit card number 1234567891234567

Credit card type VisaC MasterCard

C Bluebir d C Fisher

Credit card holder jr ong Xiao

ard expire date (mmddyy) J010102

Select shipping method UPSO Express

O Normal C Abnormal

J |sect Local intranet

141

lt2] Order List - Microsoft Internet ExplorerFile |d i t View Fayotites lo o t Help

^ 3 ^ S i l S - j S tep R efresh Home Search Favorite History Mail Print h-

HFte-LLinks A ddress I g ] httplocalhost8030servletCustemeilrifoProcess 3 ^Go

Your order reads as followsE - M a i l A d d r e s s f x i a o

F a n g X i a o

ship to

T e l

11 e m s

pound] Pc

10821 W e s t e r n P l a z aOmahaME6 8 1 5 4

( 4 0 2 ) 4 9 6 - 7 5 7 0T i t l e T h e C++ P r o g r a m m i n g L a n g u a g e Q t y 1 P r i c e 31 47 S u b t o t a l 31 47

| a [ Local intianet rsquo

l i

T inyB ookSloiecom - Microsoft Internet Explorer

T 7 ~ J iii 4 a i t Vi 1+ a Si

5 E

P r i te i+ A d d ie r I ig l httplocalhot8080ervletReqCollectauthor

S e a r c h B o o k s

Horne

Ca t e g o r y

A u th o r

Title

ISBN

P ublishe r Date

jS 1 D one

TinyBookStore com

fc t i t e r l i t n o rYou can enter authors full name first name or last name

A u t h o r |sCOtt

O ExactName amp Last F irst Name (or Initial)

T itiv b o o k s to re c o m H o a e | C a te g o ry | A u th o r | T itle | ISBN | P u b lish e r D ate

C opyright and disclaim ercopy 1999-2001 F an g Xiao

T op o f P f

|sect g j Local intranet

142

linyBookStore^com- MiciosoFUnteinet ExplorerFite Edit View Favorites Tools Ftelp

IIl4 rsquojO IjjlI - 3 -Upraquo 8 a c k ltbullltbullbullltlaquo Stop R efresh Home S earch Favorites History Mail Print 1

| Links 1 Address j raquo 3 http7localhost8CI80servletAuthorProcess

l - i f l |x |

S e a r c h B o o k s

Home

C a t e g o r y

Ti t le

ISBN

P ublishe r D a te

D o n e-

TinyB o okStore com

1- Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

I G aleampory I A utho t | I jt te | ISBN | PubH shei^D atg

i t and disclaim erreg 1999-2001 F ang Xiao

Top of

l i Local intranet

j T iny8ookStorecom - M icrosoft Internet Explorer

Fite Edit View Favorites Tools Help

4- 5 ni M m ~ltpound C r =gt 2f|L i p | | | | | iAdiiill|^Thttp7localhost8080seivletD etailContent0201924889

U 3

S e a r c h B o o k s

H ome

C a t e g o r y

A u th o r

Title

ISBN

P u b lish e r P a te

TinyB o okStore com

Effective C++b y Scott Meyers

ISBN 0201924889 Addison-Wesley Pub Co 1995

R eviews

This is the review of Effective C++

R eader Comments

Price 3795 Availability U sually ships within 24 hours

Add to iosil

IIH LdcSiiihttahdt

143

l inyBookStorecom Shopping Cart - Microsoft Internet Explorer

4- -- _ t lS M JJ ltpound I 7 r mdash2--I or- Stop R efiesh Home S ea rch Favorites History Wait PrintBach

Links Y 1^ddtessj-^1 httDvVlocalliostiBOBOyservletMddToShoppinqCart 73 ^

0

Shopping Cart Item s

Effective C + +Scott Meyers Quantity 1

0 1 Done

delete

Price

Price $ 3 7 9 5 Su b to ta l $ 3 7 9 5

Total 3 7 9 5

IB~ht Locai intranet

bull 3 TinyBooKGIoFooom M icrosoft Internet Cxplorcr

Fite Edit View Favorites Tools Help

4- -4gt Lfl 4 r amp J J lt$ i icirsquo s J ~lAB ack Ti(^poundprV aTdV iS^Stop-T SfSjefre^ptr I i - M t s s j r y rvlih- i JPopSnr -JE

i i i l l l P I I I ^ I i l l ] httplocalhost8080servletR eqC ollectauthor

G3SJ

7 ^ Go

S e a r c h B o o k s

H om e

C a t e g o ry

A u th o r

Title

ISBN

Eytoiisiier Date

101 D one

T i n y B o o k S t o r e c o m

E n te r AuthorYou can enter authors full name first narne or last name

A u t h o r jCraig Larmen

E Exact N ante O Last F irst N ame (or Initial)

Search Now 1 Clear Form

I C ategory | A u th o r | j j t l s | ISBN |

C opyright and ctiiclali[er copy 1999-2001 F an g Xiao

T o p o fP ag e

^tDpcafihttangfe-

144

gj TinyBbokSlorecom - Microsoft Internet ExplorerFile Edit View F a v o n te s - Pools

4-1 4 gt_poundj Q Jl3S top R efresh Home S ea rch Favorites History Mail PrintCacl-

lsquo Unko A ddress j ig ] httplocalhostSOSCiservletAuthorProces 71

S e a r c h B o o k s

Home

C a t e o o r v

A u th o r

Tit le

ISBN

P ub l i she r D a t e

Titty Bo okStore com

1 Applying UM L and Pattern Usually ships in 24 hours Craig Larmen Prentice Hall 1997 Our Price 450

T im booksto re com Home | C ateg o ry | A u th o r | Title | I3BM | Publisher P a ts

C opyrigh t and disclaimer copy 1999-2001 F an g X iao IIg ] http7localhost 8080eopyright html Local intranet

7 j T inyBookStorecom - Microsoft Internet Explorer

^ 03 4 31 0 i -_r _j _T B ack ~j~ S top R efresh Hom e Search Favorites History Mail Print Edit

I Links Addiess AocalhcistiiiOciOserv-letCctailConfent0137488S07

u m m

S e a r c h B o o k s

HorneC a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r Date

Tiny Bo okStore com

Applying LOVIL and Patternby Craig Larmen

0 Price 450 Availability TJ sually ships within 24 hours

ISBN 013748880 Prentice Halil 997

R ev iew s

Tins is the review o f Applying UML and Pattern

R ea d er Com ments

Add to cart

01ll iPdSSIihirSdety

145

3 TinyBookStorecom Shopping Cart bull Microsoft internet ExplorerFile Edit View Favorites Tools Help

vJBeck

JStop Refresh

4Home

H Si - iS- -=dSearch Favorites History Mail Pnnt

Links rdquo Address jlti] httpVlocalhostBOSOservletAddToShoppingCart 3 ^ Gc

r o 1

Shopping Cirt J toms Price

A pplying UML and PatternCraig Larmen Quantity 1 Effective C++Scott Meyers Quantity 1

l i l le t e

delete

Price $ 4 5 0 Subtotal $45 0

Price $ 3 7 9 5 Subtotal $ 3 7 9 5

Total 82 95

d f g a j Local intranet

146

lt3 TinyBookStoiecom - Microsoft Internet ExplorerFile Edit View Favorites Io o ls Help

gt j i 4 a - a i [j JB ack Forward Stop Refresh Home S earch Favorites Histeiy Mail Print Edit

Links Address ] pound ] hiipVonahost803CeerveirsquoReqColectlsquoauthor

0 1 i

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r D a te

Tiny Bo okStore com

You can enter authors full name first name or last name

A u t h o r jJeff

O Exact N ame Last First N ame (or Initial)

Search Now i Clear Form

T inybookstorecotti H oinf | Category | A trthor | Title j ISBN | Publisher Date

Copyright and disclaimer copy 1999-2001 Fang Xiao

Top of Page

M Local intraZl

m TinyBook Stote com - Microsoft Internet Explorer

Fife Edit View Favorites Joo ls Help

ISregBack Stop Refresh Home S earch Favorites History Marl Print c

Lirrks Address samp] httplocalhost8080servletAuthorProcess ~z ^ Gc

S e a r c h B o o k s

H ome

CategoryA u th o r

Title

ISBN

P u b lishe r D a te

i M

TinyBookStore com

1 Progi aimning Windows bullwith M FC Usually slaps in 24 hours JeffProsise Microsoft P ress 1999 Our Price 4799

jnybo-okstorscom Homo | Category | A u th or | Title | ISBN | Publisher P a h

C opyright and disclaijRief copy 1999-liOO1 FangX iao

Loccii intranet

147

148

m I myUookSlorecom - Microsoft Internet ExplorerFile- pound d it View Favorite T ools Help

^ J ] 4 U J j j =jgt Stop R efresh Home S e a rc h Favorites History i Mail Print EditBack

Links AddressilaquojigThttplocalhost5 i380ser4eM D etailContent157231 pound350

rfgKxi

ldquo3 gt6deg

S e a r c h B o o k s

HorneC a teg o ry

A u th o r

Ti tle

ISBN

P ub l i she r D a t e

TinyBookStorecom

Programming Windows with M FCby JeffProsise

0

ISB N 1572316950 Micro s oft Pre s s 19 9 9

Price 4799 Availability Usually ships within 24 hours

R e N ew s

This is the review of Programming Windows with MFC

R eader Comments

A dd to cart

D one i jh j Local intranet

lt 3 TjryBook S tore com Shop p in g Cart - M icrosoft Internet Exolorer

File Edit View f a nute T ools Help

r 1B ack

J 3 Q 0J amp poundlr - Jlilip isS h lA ld rS s httpy |ocalhost8U 80AervletA ddToShoppingCait TSIIlli

Shopping Cart Item s

Program m ing W indow s w ith M F CJeffProsise Quantity 1A pplying UML a n d PatternCraig Larmen Quantity 1 E ffective C++Scott Meyers Quantity 1

d e le te

d elete

d elete

Price

Price $ 4 7 9 9 S u b to ta l $ 4 7 9 9

P rice $ 4 5 0 S u b to ta l $ 4 5 0

Price $ 3 7 9 5 S u b to ta l $ 3 7 9 5

Total 1 3 0 9 4

^ h W h e iM

S s i Local intranet

149

File Edit View Favorites lo o ls Help n4- -0 iS - M L U

Back Stop Refresh Home Search FavoritesJ

History I3 H H H B H H H BMail Pm Edit

Links rdquo Addrecs |s] hHplocalhogt5t8080servletReqCollectcategorii ^_____ bulllt bullbull llilltllll

Search Books

Home

Category

Author

Title

ISBNPublisherDate

TinyBookStore com

P r o g r a m m in g

AI g o r i t Lins CampC++ D e l p h i J a v a MFC P e r l s o f t w a r e D e s i g n UML V i s u a l B a s i c M o r e

Done

Web D e v e lo p m e n t

ASP Commercem C y b e r c u l t u r e HTML J a v a S c r i p t S e c u r i t y Web D e s ig n XML more

G r a p h i c s amp S o f t w a r e

Asobe CAD D es k t op P u b l i s h i n g G r a p h i c s M i c r o s o f t More

I J J ig Local intranet

150

finvBookStorecom - Microsoil Internet Explorer - j g j x

j Fite Edit Jfiew Favorites lo o ts Help

bull j 5 a i B ack lsquolti S top Refresh Home S e a tc h Favorites History Mail Print Edit

Links 1 Address |ltg] hitpVocalhostl-i030seryletCateciofyPreceigtVc03 ^ | g

S e a r c h B o o k s

Home CategoQ

A u th o r

Title

ISBN

Publishe r D a te

TinyBookStore com

1 Core Ja v a 2 Usually ships in 24 hoursCay S Horstmaun Prentice Hall 1999 Our Price 2579

2 Ja v a S erv let Programm itig Usually ships in 24 hoursJason Hunter i O Reilly 1993 Our Price 1977

3 Ju st J a v a 2 Usually ships in 24 hoursPerter van der Linden Prentice Hall 1999 Our Price 3149

Tinybookstorecom Home | C ategory | A u th o r | T itle | IbBN | Publisher D ateloRoIEage

n g Local intranet

ta

151

41 Tinytfookbtorecom - Microsoft Internet ExplorerFile gdit y iew Favorites JLools Help

1 ^ hgt a a a amp a j ri i - 3 bull a Back Forward Stop Refresh Home S earch Favorites History Mart Print Edit

lisLinteslsii Address ji^]h ttp localhost8D 8o7serv letD etailC ontent0130319336

M i

3 f^Gc

S e a r c h B o o k s

Homec a t e g o r y

Tiny Bo okStore com

Core Java 2by Cay S Horstmaun

El

ISBN 0130819336 Prentice H alil999

Reviews

This is the review of Core Java

R eader Comments

Price 2579 Availability U sually ships within 24 hours

I Add to car

S ] Done S i Local intranet

TinyBookStorecom Shopping Cart - Microsoft Internet Explorerfel11 File Eefit View Favorite l o o k H e lp

tljH|V| 4 a 3 j 09 c T J

Stop Refresh Home S e a rc h Favorites History j Mail Print

jiiLihkIi87js ^ B ie s S ij^ ] http Z localhost8080servletiddT oShoppirigC art

B I B

3= i

Shopping Cart Item s

Core Java 2Cay S Horstmaun Quantity 1

Icopy

t i l

delete

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Total 2 5 7 9

sal Local intranet

152

a TinvBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites J o o lr Fjelp

NBack

amp Id b iStop Refresh Home

ISearch Favorifes History - Mail Print Edit

Links gty I Address [ jg l httplocalhost8080servletD etailContent156592391 x d

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

T i t le

IS B N

Publisher Date

ampJ Lrl e

Tiny Bo okStore com

J a v a S erv le t Piograitmmigby Jason Hunter

a Price 1977 Availability XT sually ships within 24 hours

ISBN 15659239 lx O Refflvl998

R e N ew s

In this brand-new third edition of Java Servlet Programming author Bjame Stroustrup the creator of Java presents the full specification for the Java language and standard library a spec that will soon become the joint ISOANSI Java standard

j ~2J Local intranetm

dH T iny8ook5torecom Shopping Cart - Microsoft Internet Explorer

File pound d t y iew Favorites Io o ls HelpB H

a $ a i a a -Stop Refresh Home S ea rch Favorites Hi lory Mjl

3- lsquonr I

| j | i | H | g i | i | i d ^ | | | | l Q httplocalhost80S0servletAddToShoppirigCart J P

m

Shopping Cart Item s

Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d e le te

d e le te

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Price $ 1 9 7 7 S y b to ta l $ 1 9 7 7

Total 4 5 5 6

I O I

aiil

153

Lustomer Information - Microsoft Internet Explorerpoundite pounddit View Favorites Xoo|s Help

v- _) _ l 4 J I VB ack - Stop R efresh Home Search Favorites History Mail

Links gty] A ddress ] j i l h ttD localhost8080checkouthtm l

F -iVj ~f

l l i l i i

C u sto m er In fo rm a tio n

First name jFang

Middle initial lA

Last name fXiao

Email address jfxiao m itecnet

Account password jxxxxx

Credit card number ]1234567B91234567

Credit card type C VisaC M asterCard

C Bluebird O Fisher

Credit card holder jFang Xiao

Credit card expire date (mmddyy) jo 10102

Select shipping method c u p sC Express

NormalAbnormal

0 ] D one Local intranet

poundpound Order List - Microsoft Internet Explorer

s

Back

Li il raquo

Yiew Favorites l o o h Help

bullV Y lJ j X I T- lty S to p Refresh H o m e

amp 1 3 J - jrS earch Favorite History lt Mail Print

fcesssaampl httplocalhost8080servletCustom erlnfoProcess

Y o u r ord er reads as fo llow sE-Mail Address 6daomitecnet

Fang Xiao

ship to

Tel

Items

12345 Western PlazaOmahaNE68154(402) 123-4567

Title C ore Java 2 Qty 1 Price2579 Subtotal 2579

Tide Java Servlet ProjammingQty 1 Pnce 1977Subtotal 1977 Total4556

ffl|b ] Done kl Local intranet

154

mammmm 1

File Edit View Favorites lo o ts tieip

E=cl i u F t l H -n e -i i rdquo F j-oiilsquoiBillHistory lsquo gt1 ll Print Edit

iiiiiiiiiiiiiiiiiirsquo Links Address j-copy] http localhust 8080servletReqCollectisbn J

TinyBookStore com

Search Books

Home ISBN

Author

Title

IS B N

S e a r c h Hew C le a r Form

PubnsheuDate

Top o f PageITnjrbooksj^ore^ com Horne I C a te g o rv | ^ i t h o r | T i t Ie I ISBN | Publisher Date

- g ] http locdlho-st SOSOwelcome shtrnl

TinvBookStorecom - Microsoft Internet Exploier

poundaj Local intranetId

| File Edit View Favorites Tools Help

i -e -e u u r5_ _ _ a u ^ 4 - a a j Back Forward S top Refresh Home S earch Favorites History Hail Print Edit

Links A d d re ss ^ hitp rsquoIdcanc-stEtnSOservlltlsquoF-aqZoll-~ntispn z raquo h

TinyB o okStore com

S e a r c h B o o k s

Horne

A utho r

T itle

ISBN

P u b lish e r P a t e

fcntar ISBN

I SB H 1565922840

|sectplli||pbw||l| IliM M pifiillj

T rgU onL cirrti -nr Kini- | Cgtgpound-gg | Agithor | Title | ISBN f uhhe-rt Pete

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top o f Pag e

aipoundbull] O o n e Local intranet

155

File Edit View Favorites Tools Help

HUTinyBookStorecom - MicrosoH InternetExplorer

B ad-J J A J d -2r =3

Stop R efresh Home S e a rc h Favorites History Mail Print

Links ygt A ddress j ^ ] httpVlocalhost8080servletrsquoISBM Process

S e a r c h B o o k s

Horne

C a t e g o r y

A u th o r

T itle

IS B N

Pub l i she r D a t e

TinyB o okStore com

1 Learning Perl Usually ships m 24 hours Randal L Schwartz O Reilly 1997 Our Price 1997

T in vh ooksto re c o m H orne | C at ego tv | A u th o r | Title | ISBM | Publisher D ate

C opy rig h t a n d d isclaim ercopy 1999-2001 F a n g X iao

0 ] Done

yen

ighj Local i

TinyB ookStoiecom - Microsoft Internet Explorer

Erie Edrt View Favorites- lo o ls Help

-s pound] 4 pound1 jLl icArdquo =pound 2 S top Refresh Home S earch Favorites History Marl Print Edit

iilHI

NpBack

httpyiocalhostSOBOservleMDetailContentAI 565922840 ~T] Cm

Tiny Bo okStore com

S e a r c h B o o k s

H o m e i

C a teg o ry

A u th o r

T itle

ISBN

Publishe r D a te

Learning Perlby Randal L Schwartz

I ^

ISBN 1565922840 O Reillvl997

Price 1997 Availability U sually ships within 24 hours

Reviews

This is the review of learning Perl

Reader Comments M0 ] Done lsquofR | Local intranet

156

IHHHHHI _ I f f i x |

File E d t yiew Favorites J o e ls H elp 11v- -__ l

Back ~ rc Stop R efresh Home S earch Favorites HistoryJ rMail

HH1111Pgtnt

Links A ddress | ] http7docalhost8030servleM AddToShoppingCart 3 tgt G o

O S III

Shopping Cart Item s

Learning PeriRandal L Schwartz Quantity 1

delete

Price

Price $ 1 9 9 7 Subtota l $ 1 9 9 7

Total 1 9 9 7

s

Done Local intranet

Eg W illi 1 lttMM41 i H H p n B n 1 0 1 x i

Fite Edit View Favorites Toots Help E H

1$3 L plusmn J8ack Forward Stop Refresh Home Search Favoutes

4History i

- i V -=JMail Print

-Edit

71 Address http7localhost8080lsquoservletFleqCollecVisbn I l f i l l l

TinyBookStore com

Search Books

Home

C ateao rv

Author

Title

ISBN

Publisher D a te

Enter ISSN

i s bit [l 565921496

Search Now I Clear Form

Tinybookstore o n Home | Category | A uthor | Titb | ISBN | Publisher Dte

Copyright arid disclaimer copy 1999-2001 Fang Xiao zl amp j Done Js J Local intranet I

157

H H H r f e i x i File Edit View Favorites Lools Help

- J j j j ] JBack Stop Fiefresh Home Search

J JFavorites-

-J i C rHistory Mail Print

111111811i n

r Links wj i Address |reg] http docalhost 8080servletIS8N Process

S ea rch B ooks

Home

Category-

rdquo A u th o r

T i t l e

IS B fi

P u b l i s h e r D a ta

Tiny Bo okStore com

1 Programtning Perl Usually ships in 24 hours Larry Wall O Reilly 1997 Our Price 2397

T o o k s t o r e c o m H P in e | C a t e g o r y | A u t h o r | Till | IS B N | P -ubtu-hai D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g X ia

T o p o f P a g e

zlamp2 Done Local intranet

158

lt3 l mytfookSlorecom - Microsoft Internet ExplorerF3e Edit View FavoMes lo o ts Help

Back3 U Si S rsquo IStop Refresh Home lt Search Favorites History Mail Print Edit

httplocalhost8080servletDetailContent15S5321496 j3

Search Books

Horns

Category

Author

Title

ISBN

Publisher Date

Done

TinyB o okStore com

Programming Perlby Larry Wall

0 Price 2397 Av ail ability U sually ships within 24 hours

ISBN 1565921496 O Reillyl997

Reviews

This is the review of Programming Perl

Reader Comments

Add to cart

l or=lM

159

Tm vBookSlorecom Shopping Cart - M icrosoft Internet Explorer

i Fite Edit View Favorites lo o k Help

^ Beck R efresh Home

ampS earch Favorites History j Mail Print

E Links I Address ] pound http localhost 8080servletA ddT oShoppingCart rsquo ] O rai

i O

Shopping Cart Jlems

Learning Peri Randal L Schwartz Quantity 1 Program m ing PeriLarry W all Quantity 1

delete

d e le te

Price

Price $ 1 9 9 7 S u b to ta l $ 1 9 9 7

Price $ 2 3 9 7 S u b to ta l $ 2 3 9 7

Total 4 3 9 4

3SJ Done j | s [ Local intranet

160

m m mmmHi mmmHHHHHi1 File Edit View Favorites Tools Help

^ - J J -ih Ji - j| B a d Forward Stop Refresh Home S earch FavoritesHIH ctuv Mjl Print

IHIlllliEd

B l

MbfeifcssfjP Address httplocalhost8080servletFleqCollectpLiblisher_date_ ___ ________ ___________ _ bull bull bull bull_________________ Zi T gt 6 o

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

Title

ISBN

Publishe r P a t e

S ] Done

TinyBo okStore com

T rsquov -

Publisher

sind IPpiIs1iclaquoifciori OsifiC

jAd cl i so n-VVe oI e y Fuo C o ~

P u b l i c a t i o n D a t e 1U97

Search Now Clear Form

T inybookstore com Home | C ategory j A u tho r j I itle | ISBN | Publisher Ds

C opyright and disclaimer copy 1999-2001 F an g Xiao

T op o f Page

g a l Local intranet

161

lt|j TinyBookStoiecom - Microsoft Internet Explorerlsquo Erie Edit View Favorites lo o ls Help

v-1 Q rij - 3 rsquo- a u -=pound Ci Back s lsquoi i 1 Stop Refresh Home S earch Favorites History Mail Print i

jL inks i A ddress 0 1 http7localhost8Q80servletPublisherDateProcess

EMM

3

S e a r c h B o o k s

Home

C a t e g o r y

Author Title

ISBN

Publisher D a te

TinyBookStore com

1- Algorithm s in C Usually ships in 24 hoursRobert Sedgewick Addison-Wesley Pub Co 1997 Our Price 4495

2 The C++ P rogr amming L anguage Usually ships in 24 hourBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

3 Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

4- U M L D istilled Usually ships in 24 horn sMartin Fowler Addison-Wesley Pub Co 1997 Our Price 2995

Done | s j L ocalm

TinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorites l o o k Help

Backamp 3 $ -Q 3 3 AJStop Refresh Home S earch Favorites History Mail Print Edit

Lipikkigt7i Ajddr$esjhttpv7localhost8080-servletDetailCoriterit0201314525

m

3 rgtGc

S earch B ooks

Horne

A uthor

Title

ISBN

Publisher D a te

Tiny BookStore com

Algorithms in Cby Robert Sedgewick

S

ISBN 0201314525 Addison-Wesley Pub Co 1995

Reviews

This is the review of Algorithms in C

Reader Comments

Price 4495 Availability U sually ships within 24 hours

Add to cart

0I reg S a i t^ s a l intranet

162

File Edit View Favorites lo o ls Help

2 ^ iVi ^ ^ t j j B ack gt Stop Refresh Home S ea rch Favorites History ||

- i -Mail Print

WB0BUBSSSI B ifl

Links ygt Addrese |isect ] httpvVlocalhostSOSChservletAddToShoppingCart

Shopping Cart Item s

A lgontfim s in CRobert Sedgewick Quantity 1

0 1 D one

delete-

Price

Price $ 4 4 9 5 Subtota l $ 4 4 9 5

Total 4 4 9 5

Local intranet

163

^ l inyBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

ls31

3 bullrsquo -I- _J _jj - j i_ 3 - j rdquo -= $ ABack Forward Stop Refresh Home Search Favorites History Mail Print Edit

Links rdquo Address 6 J http Vlocalhost SOSOAervletR eqCollectpublisher_date j ^G

Search B o o k s

Home

categoryAutho r

Title

IS B N

Publi sher D a te

TinyBookStore com

liter Publisher and Publication Date

P u b l i s h e r Wrox Press Inc

P u b l i c a t i o n D a t e ]1

Search Now j Clear Form

T invbookstor ecotnHomg | Category | A uthor | Title | ISBN | Pu b lish e rP a t

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top of Page

zD one Local infra

m TinyB ookStoiecom - Microsoft Internet Explorer

R e Edit View Favorites Tools Help

- -i 13 4 St 2J amp t r - JHB-1

fff ij if P S | Address |sjpound~| httpVlocalhost8030servletPublisherDateProcess

S e a r c h B o o k s

Home

C a t e g o r y

A utho r

T itle

ISBN

Publisher D a te

0 ] Done

TinyBookStore com

1 Beginning Visual Basic 6 Database Programming Usually ships in 24 hour John Connell W rox Press Inc 1998 Our Price 3199

2 Befmiung Visual Basic 6 Usually ships in 24 hours Peter Wright Wrox Press Inc 1998 Our Price 3199

T inybookstore com H orae | C ategory | A u thor | Title | ISBN | Publisher Date

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top o f Fas

Local intranet

64

| File Edit Yiew Favorites T ook Help

i A - + - - a S 3 rsquo reg - pound J -3 Back ldquo d Stop Refresh Home Search Favorites History

- vMail Print

i

Edit

IllplBlllll________ g - M

isisfcinbsijp Addre s | g ) httplocalhost8080servletDetailCoritent1861001061 3 Gdeg

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

T itle

ISBN

Publishe r D a te

TinyBookStore com

Beginning Visual Basic 6 Database Programmingby John Connell

a Price 3199 Availability U sually ships within 24 hours

ISBN 1861001061 Wrox Press Inc 1998

Reviews

This is the review of beginning Visual Basic 6 Database Programming

Reader Comments

A d d to c a n

S] pone Local intranet

m u i

lillllEHl ^ bdquo A 3 2tl 4 t M liJ i

Back Forward Stop Refresh Home Search Favorites3

History 4 _ r

M j 1J

Print EditiSillilillllS

httplocalhost8080servletReqCollecttitle

S e a r c h B o o k s

Home

C a t e g o r y

Author

Title

ISBN

Publisher Date

TinyB o okStore com

Enter TicleYou can enter the exact title or part of title

T i t l e C++

O Exact Title Title Words

Search Now Clear Form

Example

bull Entering Java Servlet Programming in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title are related to Java _li

165

lt5 TinyBookStorecom - Microsoft Internet ExplorerFite Edit View Favorites lo o ts Help

Back Stop Refresh Home S earch Favorites History Mail Print

Links gty Addiess http-localhost8080servlet7TitleProcess

i|p1

I

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

Publi sher IS a t e

TinyBookStore com

1 The C++ Programming L anguage Usually ships in 24 hoursBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

2 Effective C+-F Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

3 Programttung Visual C-H- Usually ships in 24 hours David J Kmglinski Microsoft Press 1998 Our Price 3999

T m y h o o k s to e co m H o m e | C a te g o ry | A u th o r | T itle | ISBH | P u b lish er D ate

http iocalhost SOSOservletFleqCollectcategary

T op of P age

~hj Local intranet

bull a TlnjpBflOkStOfecom - Microsoft Internet Explorer

File Edit View Favorite Pools Help

0 3 4 S l i 3 O - J J i t of Stop Refresh Home S earch Favorites History - Mart Print Edit

HBack

i i i i lS i lB i I i f f id i l f f lH Q http Vlocalhost 8080AervletD etailContent1572318570

EEEI

J

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b lis h e r D a f t

TinyBookStore com

Programming Visual C++by David J KrngHnski

[Hj

ISBN 1572318570Microsoft Press 1998

Price 3999 Availability Usually ships within 24 hours

R e v ie w s

This is the review o f Programming Visual1

Reader Comments

Add to cart

if Local intranet

166

mm| File pounddtt View Favorites Jo o ls Help

c J J j j mdash JB ack - J Stop Refresh Home S earch Favorites History

- _ i -M u

J tPrint

t e t a f e w P A ddress | ^ ] httplocalhost8080servletAddToShoppingCart zl -lt1gtSo

Shopping Cart Item s

Programmeng Visual C + +David J Kmgbnski Quantity 1

delete-

Price

Price $ 3 0 9 0 Sub to ta l $ 3 9 9 9

Total 3 0 9 9

D one ^aj Local intranet

TinyBookStorecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

vHBack-

-J a 4 -a si fi- 3 aStop R efresh Home S earch Favorites History j Mail Print- Edit

Links gty A d d re s sL ^ ] hrtpWlocalhostSOSOservleVFIeqCollectAitle

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

ISBN

Pub l i she r Date

TinyBookStore com

Enter TitleYou can enter the exact title or part of title

Title Distil I nrfExact T itle V T itle W o rd s

Search Now | Cle ar Fo rm

Examples

rpound] Done

bull Entering Java Servlet Programming11 in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title arei date 11 j Java JZJ

167

a TlnyBA5kSioiecom - Microsoft Internet Explorergt 0e Edit ifiew Favorites Jock Jd lp

a a amp -a tii j k i Back s - Stop Refresh Home Search Favorites History Mail Print

liilP raquo httpiVlocalhostSOSOservletTitleProcess

E M 3

ldquo3 rgt-

S ea rch B ook s

Horne

C a t e d o r v

A utho r

TiUgt~ ISSN

Publi sher D a te

Tiny BookStore com

1- TJML D istilled Usually ships in 24 nowsMartin Fowler Addis on-Wesley Pub Co 1997 Our Price 2995

| C s rg g o ty | A u th o r | T itle | IStBH I P u b lis h e r D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g Xiao

-jg Local intranetS3

m n ^ i l a i i x l

File Edd View Favorites Joels- Help M Mi r J lt 3 L h f 4 - 0 lt 3

Back i t Stop Refresh Home S earch Favorites History Mail9

PrintM

Edit

Links raquo A ddress j | i ] http do ca lh o d 1030N m letDetailContenr0201325632 Mimas

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

Title

IS B N

Publisher Date

Tiny BookStore com

TJML Distilledby Martin Fowler

0

ISBN 0201325632 Addison-Weslev Pub Co 1997

Reviews

Tins is the review of The UML Distilled

Reader Comments

Price 2995 Avail abilityTJs u ally ships within 24 hours

Add to c a r t

0 3S i] Done |g^iLnealiihfrregei

TinyBookStorecom Shopping Cart Microsoft Internet ExplorerFile Edit View Favorites Jo o ls HetP

IBiiiBlll l l lHBlSglSlllllilMH MlllBliriilllgllSlIlBack - f - i - S top Refresh Home

a J i l ^ j 3 Search Favorites History 1 Mail Print liiii

3 Links ( A ddress j ig j hrtplocalhost803DservletAddToShoppingCart

Shopping Cart Herns Price

UML D istilledMartin Fowler Quantity 1Program m ing Visual C + +David J Kraglinski Quantity 1

Price $ 2 9 9 5 Subtota l $ 2 9 9 5

delete

Price $ 3 9 9 9 Subtota l $ 3 9 9 9d elete

Total 6 9 9 4

  • Electronic Commerce on Business Application
    • Recommended Citation
      • tmp1499779448pdf2JOpQ

Abstract

For some time now Whole size business enterprises have used electronic commerce

to conduct their business activities The On-Line store is one of a number of popular

web applications This thesis focuses on one of the emerging On-Line store

technologies which is known as Server-Side Java Application

In early 1960 private networks were dedicated for the use of electronic data

interchange (EDI) and electronic funds transfer (EFT) in banking business Recently

however with the increased awareness and popularity of the Internet electronic

commerce has come to encompass individual consumers as well as businesses of all

size For most people electronic commerce is defined as the buying and selling of

products and services over the Internet but there are many more aspects We will

discuss different definitions of electronic commerce in this paper

The most popular Web applications are the On-Line Stores Most of such applications

involve functions as searching for product information ordering products paying for

goods and services and for providing online customer service A Web server running

continuously accepts userrsquos connection gets user requests and forward requests to

business procedure retrieves data (answers to user requests) from business procedure

and sends it back to the user

An on-line store system is different from a traditional web publishing It needs a

customerrsquos interactive communication and frequent data update The traditional

HTML page does not satisfy the customerrsquos needs because all it does is simply

publish static contents More complex technologies are required in order to produce

dynamic contents

There are a few technologies that can be used for implementing the on-line stores

Common Gateway Interface (CGI) Microsoft Active Server Page (ASP) and Server-

side Java application are the most popular technologies Introducing the Server-Side

Java application is one of the latest and most exciting trends in Java programming

The Server-side Java application has many advantages over the other technologies

Table of Contents

Chapter 1 Introduction 1

Chapter 2 Electronic Commerce 2

21 What Is Electronic Commerce2

22 The Importance of Electronic Commerce3

23 Types of Electronic Commerce3

24 Why Most Internet Based Electronic Commerce Is In

The Business-To-Consumer W orld 6

25 Current State of Business-To-Consumer E-Commerce7

26 The Structure of The On-Line Store8

Chapter 3 Technologies For On-Line Store System11

31 Traditional Web Application - Common Gateway Interface(CGI) 11

32 Active Server Page 12

33 Server-Side Java Application 14

Chapter 4 Design of On-Line Bookstore Using Java Servlets

A Practical Verification18

41 The Design of Home Page of Tiny Book Store18

42 Design of Search by Different Requests27

43 Servlets Chaining To Process Requests In Different Levels28

44 Database Connectivity and Search from Database29

45 Session Tracking 35

46 Check O ut42

47 Customer Information Processing 43

Chapter 5 Future Work50

51 Connection Pooling50

52 More Object-Oriented - Better Encapsulation51

Chapter 6 Conclusion 53

Appendix A Bibliography54

Appendix B The Source Code of An On-Line Store System -

Tiny Book Store57

Appendix C Screen Display of the Test 135

List of Figure

Figure 261 The Structure of An Online Store 10

Figure 321 Handle Requests Flow Chart 13

Figure 331 HttpService of The Java Web Server Using Servlets 15

Figure 411 The Home Page of Tiny Book Store 22

Figure 412 One of The Searching by Author Pages26

Figure 441 One of The Outputs of Servlet AuthorProces 34

Figure 451 A Page Show All Information About A Book 39

Figure 452 A Page Show Items In The Shopping Cart After A User

Added Books To The Shopping Cart 40

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A

Book From The Shopping Cart42

Figure 461 A Check Out Page 43

Figure 471 An Invoice Page48

1

Chapter 1

Introduction

As we step in the year 2000 we can no longer look to the past as the guide for the

future A combination of business social and technical possibilities drives the rapid

progress in electronic commerce

Electronic commerce can offer a company both short-term and long-term benefits

Not only can it open new markets enabling a business firm to reach new customers

but it can also make it easier and faster for the firm to do business with their existing

customer base Moving business practices such as ordering invoicing and customer

support to network-based systems can also reduce the paperwork involved in

business-to-business transactions When more of the information is digitized it

allows that business firm to focus on meeting their customerrsquos needs Tracking

customer feedbacks and presenting customer solutions for their clientele are just

some of the opportunities that can stem from electronic commerce

2

Chapter 2

Electronic- Commerce

21 What Is Electronic Commerce

For some time now large business enterprises have used electronic commerce to conduct

their business-to-business transactions In early 1960 private networks were dedicated

for the use of electronic data interchange (EDI) and electronic funds transfer (EFT) in the

banking industry Recently however with the increased awareness and popularity of the

Internet electronic commerce has come to encompass individual consumers as well as

businesses of all size

To many electronic commerce is defined as the buying and selling of products and

service over the Internet But there are many other aspects Depending on whom you ask

electronic commerce has different definitions

From a communications perspective electronic commerce is the delivery of information

productsservices or payments via telephone lines computer networks or any other

means From a business process perspective electronic commerce is the application of

technology toward the automation of business transactions and workflow From a service

perspective electronic commerce is a tool that addresses the desire of firms consumers

and management to cut service costs while improving the quality of goods and increasing

3

the speed of service delivery From an online perspective electronic commerce provides

the capability of buying and selling products and information on the Internet and other

online services [16]

These definitions are valid with their perspectives It is a matter of which lens is used to

view the electronic commerce landscape Broadly speaking electronic commerce

emphasizes the generation and exploitation of new business opportunities by ldquogenerating

business valuerdquo or ldquodoing more with lessrdquo

22 The Importance of Electronic Commerce

As we approach the year 2000 we can no longer look to the past as guide to the future In

the face of strong market forces created by electronic commerce and mounting

competition corporations can no longer plod along historical tracks or seek the

preservation of the status quo Companies are discovering that old solutions do not work

with new problems The business parameters have changed and so have the risks and

payoffs

23 Types of Electronic Commerce

From a broad view there are three distinct general classes of electronic commerce

applications Inter-organizational (business-to-business) intra-organizational (within

business) and customer-to-business application [16]

4

231 Inter-Organizational Electronic Commerce

Inter-organizational electronic commerce makes business more convenient on the

following aspects

Firstly e-commerce can improve supplier management since electronic applications can

reduce the processing costs and cycle times for each purchase order and it can reduce the

number of people who work on purchase orders

Secondly e-commerce can improve inventory management since electronic applications

make the business partners can fast exchange information and easy track their documents

to ensure that they were received This not only can eliminate out-of-stock occurrences

but also can reduce inventory and improve inventory turn

Thirdly e-commerce can improve distribution management since electronic applications

can make the business partners receive the shipping documents as soon as possible and

enable better resource management by ensuring that the documents contain more accurate

data

Fourthly e-commerce can improve channel management since electronic application can

let the business partner post the information to electronic bulletin boards This can

eliminate repeated telephone calls and countless labor hours

Fifthly e-commerce can improve payment management since the business partner are

linked by network so the payments can be sent and received electronically Electronic

payment is more accurate and fast than traditional payment

232 Intra-Organizational Electronic Commerce

5

Intra-organizational electronic commerce facilities the following business applications

Workgroup communications Electronic applications enable manager to

communicate with employees using electronic mail videoconferencing and

bulletin boards

Electronic publishing Electronic applications enable companies to publish

information by using tools such as the World Wide Web On-line publishing can

show information immediately and clearly and reduce costs for printing and

distributing documentation

Sales promotion Electronic application improve the flow of information between

the production and sales forces and between the firms and customers This can

make companies have greater access to market and competitor information

Today Intranets are primarily set up to publish and access vital corporate information

Some of the most common types of information are Human Resources information

employee communications product development and project management data internal

catalogs sales support data equipment and shipment tracking and accessing corporate

database

233 Consumer-To-Business Electronic Commerce

In consumer-to-business transactions customers learn about products through electronic

publishing buy products with electronic cash and other secure payment systems and

even have information goods delivered over the network

6

From the consumerrsquos perspective there are three transactions

1 Electronic applications enable consumers to communicate with each other through

electronic mail videoconferencing and news groups

2 Electronic applications enable consumers to manage investments and personal finances

using online banking tools

3 Electronic application enable consumers to find online information about existing and

new products services

Consumers consistently demand greater convenience and lower prices Electronic

commerce provides consumers with convenient shopping methods from online catalog

ordering to phone banking both of which eliminate the costs of expensive retail

branches Electronic commerce facilitates factory orders by eliminating many

intermediary steps thereby reducing manufacturersrsquo inventory and distribution costs and

indirectly providing consumers with lower prices

24 Why Most Internet Based Electronic Commerce Is In The Business-To-

Consumer World

For the Business-to-Business e-commerce the lack of well-accepted standards is

hindering the success in promoting Business-to-Business electronic commerce

solutions[5] VAN (Value-Added Networks) EDI (Electronic Data Interchange) based

solutions are only accessible to large organizations due to the cost factor Corporate

buyers and suppliers large and small are looking for Internet based solutions to

streamline the procurement procedures and to reduce the cost of establishing trading

relationship and the trading transactions Such demands put forward some fundamental

challenge on issue like trust infrastructure on the Internet standards and inter-operability

etc

25 Current State of Business-To-Consumer E-Commerce

Business activity on the Internet is currently limited to publicizing the business

opportunity and to catalog based sales but it will rapidly expand to include the

negotiations conducted to settle the price of the goods or commodities being traded

These negotiations are currently conducted by human intermediaries through various

forms of auctions bidding systems for awarding contracts and brokerages The role of

the intermediaries can now be performed by Internet trading applications at a fraction of

the cost[4] Trading on the Internet allows a business to reach a large number of potential

customers and suppliers in a shorter time and a lower cost than possible by other modes

of communication and to settle business transaction with lower cost overhead in a shorter

time

Auctioned or brokered sales are the norm in business world for negotiating trades of large

monetary value But consumer sales and small-scale purchases have used the fixed price

mode perhaps because of the high overhead cost of using the auction or brokerage

method The new economics of the Internet will make auctions popular in consumer and

small business transactions also

Auctions are just one form of business negotiations Other examples are competitive bids

for procurement brokeragesexchangescartels and two party negotiations

Nowadays the free-market economy of software agents is in the embryonic stage But in

the near future the software agents will populate the Internet and provide trade and use

a rich variety of information goods and services in an open free-market economy In a

free-market economy of software agents information is produced traded and consumed

by vast numbers of autonomous self-motivated agents An essential task in such an

economy is the retailing or brokering of information gathering it from the right

producers and distributing it to the right consumers[10] The overall research goal is to

characterize and understand the dynamic behavior of information economies very large

open economies of automated information agents that are likely to come into existence in

the Internet

26 The Structure of The On-Line Store

9

Nowadays there are thousands of on-line stores running on the Internet A few well-

known ones are amazoncom and bookpoolcom Most of such applications involve

common functions which are as following

Searching for product information

Ordering products

Paying for goods and services

Providing online customer service

So they have a similar structure as shown in Figure 261 The system contains the

following components

1 A web server running continuously accepts userrsquos connection gets user requests and

forward requests to business procedure retrieves data (answers to user requests) from

business procedure and send it back to user

2 Business procedure usually consists of a user identification procedure like credit card

check user request analysis procedure analyzing requests calculating discomposing (if

necessary) and dispatching request to different data source component Also in some

case business procedure is responsible to compose data obtained from different data

sources into user-readable format

3 Database is the place to hold relevant data These data not only serve as a data source

describing commercial goods and prices but can be used for data mining to improve

store service quality as well Database is updated and maintained by both customersrsquo

input and system applications A customerrsquos input usually includes order information

10

Figure 261 The Structure of An Online Store

(through browser)

Databas

(through browser)client

client

serverWeb

Systemapplication

Busines

procedu

4 System applications can include a search engine running all the time and searching

relevant information from the internet data mining application deals with mining and

analyzing customer and sale data for management use database maintaining application

handles update data when product information changes Varying from system size to

system size not every system has cleardistinct boundaries between these components

The system can be 3-tired or n-tired but these systems all operate in similar ways

11

Chapter 3

Technologies For On-Line Store System

An on-line store system is different from traditional web publishing It needs customerrsquos

interactive communications and frequent data update The traditional HTML page is

insufficient because all it does is provide static content publishing Other technologies

are required in order to implement the on-line store

Currently there are three mainstream technologies which are widely used Common

Gateway Interface (CGI) Microsoft Active Server Page (ASP) and Server-side Java

application We briefly explore these technologies here

31 Traditional Web Application - Common Gateway Interface (CGI)

The common Gateway Interface normally referred to as CGI is one of the first practical

techniques for creating dynamic content With CGI a web server passes certain requests

to an external program The output of this program is then sent to the client in place of a

static file The advent of CGI makes it possible to implement all sorts of new

functionality in web pages and CGI quickly become a defacto standard implemented on

dozens of web servers Even though a CGI program can be written in almost any

language the Perl programming language is the predominant choice However CGI have

some distinct disadvantages

Firstly CGI program is transient A request is made each time to a CGI program It must

be loaded and executed by the Web server When the CGI program is complete it is

removed from memory and the results are returned to the client All program

initialization (such as connecting to a database) must be repeated each time a CGI

program is used

Secondly when a server receives a request that accesses a CGI program it must create a

new process to run the CGI program and then pass to it via environment variables and

standard input Every bit of information might be necessary to generate a response

Creating a process for every such request requires time and significant server resources

which limits the number of requests a server can handle concurrently

Thirdly a CGI program cannot interact with the web server or take the advantage of the

serverrsquos abilities once it begins execution because it is running in a separate process

32 Active Server Page

As shown in figure 321 the following list walks you step-by-step through what

happens if the client requests the page xyzasp

The client requests the page xyzasp from the server The Web server checks the file

extension to see whether a special program (such as the Active server Pages engine)

13

must be invoked to process the request If therersquos a asp extension the Web server

determines that it should invoke ASP to process this page

Figure 321 Handle Requests Flow Chart

Request

Response

WEB SERVERComponents

Databas

ns

ASP File

CLIENT

Active X Data

VBScript

If this page has never been requested before or has been changed since the last

request it must be parsed and the syntax checked and then be compiled by the Web

server Otherwise the page might be read from a cache of recently processed pages

which aids in performance During the parsing process the HTML and scripting code

14

are separated IIS (Internet Information Server) determines which scripting engine is

responsible for which part of the script and delegates the work of syntax checking and

compiling to the proper scripting engine (such as VB Script)

Now the code is executed by the scripting engine using resources from IIS which is

hosting the scripting engines All objects that the language engine cannot handle are

requested by the IIS which is also responsible for handling inputs and outputs for the

external ActiveX objects that are created and used inside the script If it is not able to

supply the object an error is generated

Script output and static HTML code in the ASP file are merged

The final HTML is sent back to the user in an HTTP response

The important point about ASP is that the Script runs entirely in a server to protect the

intellectual property by shielding it from browser which are different from the account

for when writing client-side code The entire server-side code is processed and only plain

HTML - or whatever kind of content you chose to generate - is sent to the client

33 Server-Side Java Application

The rise of server-side Java applications is one of the latest and most exciting trends in

Java programming A Servlet can be thought of as a server-side applet Servlets are

loaded and executed by a Web server in the same manner that applets are loaded and

executed by a Web browser

15

As shown in Figure 331 a servlet accepts requests from a client (via the Web server)

performs some task and returns the results

The client (mostly likely a Web browser) makes a request via HTTP The Web server

receives the request and forwards it to the servlet If the servlet has not yet been loaded

the Web server will load it into the Java virtual machine and execute it The servlet will

receive the HTTP request perform some type of process and return a response back to

the Web server The Web server will forward the response to the client

Figure 331 HttpService of The Java Web Server Using Servlets

RequestResponseRequestResponse

RequestResponse

Java Web Server

Administrative SERVLET

SERVLETHTTP

SERVLETWeb Proxy

Servlets have distinct advantages over CGI program

Servlets are persistent Servlets are loaded only once by the Web server and can

maintain services (such as a database connection) between requests

Servlets are fast since servlets only need to be loaded once

16

Servlets are platform independent Servlets are written in Java and conform to a well-

defined and widely accepted API They are highly portable across operating systems

and across server implementations A servlet can be developed on a Windows NT

machine running the Java Web Server and later can be deployed effortlessly on a

high-end Unix server running Apache

Servlet portability is not the stumbling block it so often is with applets There are two

reasons Firstly servlet portability is not mandatory Unlike applets which have to be

tested on all possible client platforms servlets have to work only in the server

machines that you are using for development and deployment Unless you are in the

business of selling your servlets you donrsquot have to worry about complete portability

Secondly servlets avoid the most error-prone and inconsistently implemented portion

of the Java language the Abstract Windowing toolkit (AWT) that forms the basis of

Java graphical user interfaces

Servlets are extendable Servlets that are written in Java brings all of the other

benefits of Java to servlet Java is a robust object-oriented programming language

which can be extended easily to suit our needs

Servlets are secure The only way to invoke a servlet from the outside world is

through a Web server This brings a high level of security especially if the Web

server is protected behind a firewall

Servlets can be used with a variety of clients

Servlets are tightly integrated with the server This integration allows a servlet to

cooperate with the server For example a servlet can use the server to translate file

paths to perform logging and to check authorization

Servlets are quite flexible An HTTP servlet can be used to generate a complete web

page it can be added to a static page using a ltSERVLETgt tag in whatrsquos know as a

server-side include and it can be used in cooperation with any number of other

servlets to filter content in something called a servlet chain

18

Chapter 4

Design of On-line Bookstore Using Java Servlets A Practical

Verification

Server-side Java application is one of the latest technologies used to implement an onshy

line store system Servlet is a set of classes that come up from Java language It is

designed to be used for server-side Java applications There are many techniques people

can use when they utilize servlet such as Server-Side Include (SSI) Servlet Chaining

Applet and Servlet communication etc We tried to use as many such techniques as

necessary in our implementation to demonstrate the advantages of servlets

The demonstration system module is same as the one we mentioned above Figure 331

We use this module to show how such system works

The system called Tiny Book Store emulates an on-line bookstore selling computer

books It has the full functionality of other on-line stores The only difference between

this system and the other on-line systems is the database size We donrsquot want to spend

much developing time for database maintaining part because this part is similar to

ordinary database maintaining and it is an independent subsystem The Tiny Book Store

mainly consists of three modules user interface business procedure and data access

19

41 The Design of Home Page of Tiny Book Store

The home page - welcome page - is designed using the Server-Side Include technique

That is embedding a servlet inside HTML file with a specific HTML tag ltSERVLETgt

In our case this servlet when invoked can run a query on database via data access

objects to retrieve most recent top 5 best-seller books and then returns the retrieved data

to the place within the page where the ltSERVLETgt tag was As long as the data in

database update timely it is guaranteed that customer will get the most recent data

The embedded servlet is invoked by Java Web Server before the page is sent back to

client Java Web Server processes any HTML file having shtml extension and invokes

the embedded servlet marked by ltSERVLETgt tags

Server-Side Includes are useful when a page is primarily static but contains a few distinct

dynamic portions One of the servlets produces the ldquo Five Hot Books ldquo which is shown in

the following example

Example 411 A Part of Code of welcomeshtml

lt P gt

lth3xstrongxf ont color= f f 6347 gtWelcome to theltigt

TinyBookStorecomltigtltfontgtltstronggtlth3 gt

20

ltstrongxbxh3gtltcentergtFive Hot

Booksltc e n t e r x h3gtltbgtltstronggt

ltbrgt

ltservlet code=EchoServletTaggt

ltservletgt

The servlet EchoServletTag searches database according to some business rule and gets

data from data access objects to produce the Five Hot Books The following example is

the sample code

Example 412 A Part of Code of The EchoServletTagjava

public void service(HttpServletRequest req

HttpServletResponse res)

throws ServletException IOException

res setContentType ( text Jhtml)

PrintWriter out = resgetWriter()

try

Statement stmt = concreateStatement()

21

ResultSet rs = stmtexecuteQuery(select from

book where

title like Programming)

int count = 1

outprintln(ltdlgt)

while (rsnext() ampamp count lt 6)

out print In ( ltdtxbgt + count + )

String isbn =

rsgetObj ect(ISBN) toString()

outprintln(lta

href=servletDetailContent + isbn +

outprintln(rsgetObj ect(Title) toString()

+ lt a x bgt )

out println ( ltddxnobrxfont color=990033gtUsuallY

ships in 24 hoursltBRxfontxnobrgt )

outprintIn(ltbrgt +

rsgetObject(Author) toString() )

outprintIn( +

r s getObject(Publisher)toString() + +

r s getObj ect(PublicationDate) toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

out println ltbrxbrgt )

22

count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()

The servelt EchoServletTag by the business mle that searching a specific table sends a

request query through data access object stmt and gets search result through another

data access object rs It then passes data to the page The content between ltservletgt and

ltservletgt tags in the HTML of home page is replaced by the search result at run time

The center part of the sample result page in Figure 411 is an example

23

Figure 411 The Home Page of Tiny Book Store

gj Search TinybookstGiecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

^ bullgt o a 4 i a a j ugt- a a Back lt7gtn Stop Refresh Home j Search Favorites History Mail Print Etfe

-Six

sfekinlfeSsI 3 Address |iS1 httpiVlocalhosLSOSCVwelcomeshtrnl Cj

f S M B l TinyBookStorecom

Search B o o k sW e l c o m e tc f l i e

HomeFive H ot Books 1 1

Category i-si

IA uthor

Title1 The C + + Programming L a n g u a g e B

Usually ships in 114 hoursISBN

k

IPublisher D a teBjame Stroustrup Addis on-Wesley Pub Co 1997Our Price 3147

m2 Programming Visual C+ +

Usually ships in 24 hours y

David J Krn^dinski Dlicrosoft Press 1998 c damp Local intranet

From this practice we know Server-Side Include not only can produce dynamic portion

of the page but also prevent from other people spy into your code Since Java servlet runs

entirely on a server thus protecting your intellectual property and shielding you from the

browser This means what the client sees can be totally different from what the server

does From the client side it is difficult to figure out how the server works

The left-hand menu items are implemented by using a characteristic of servlet - extra

path information or virtual path The extra path information can be used as a kind of

parameter passed to a servlet In general this extra path information is used to indicate a

24

file on the server that should use for something We use this feature here in an abnormal

way to manage customer requests and process these requests in a single place

Consider a traditional method When a menu item is selected by a customer it redirects

the customer to another page where it hyperlinks to If we have several ten items we

need to pre-create several ten pages This is the disadvantage of static HTML pages

However with servlet which can dynamically generate page content we can direct all the

customer requests to a central servlet and process the requests there according to some

condition (parameters) and then generate the page which customer need to see In this

way we only need one place to hold the code to save serverrsquos space And this place is

easy to maintain

The following is how it was doing for the Tiny Book Store

The Author item uses the following hyperlink

ltA

href = servlet ReqCo 11 ect author gtAuthorlt fontx AxTDgt

ltTRgt

The ReqCollect is the name of a servlet We pass the ldquoauthorrdquo in the hyperlink as a

parameter to ReqCollect When the Author item is selected ReqCollect is invoked by

lava Web Server ReqCollect generates a html page to let a user input author search

condition The ReqCollect code is listed below

25

Example 413 A part of Source Code of ReqCollectjava

public class ReqCollect extends HttpServlet

protected final String AUTHOR = author

public void service(HttpServletRequest req

HttpServletResponse res) throws ServletException

IOException

PrintWriter out = resgetWriter()

String path = reqgetPathlnfo ()

if (path == null)

error handling

else

Create standard header

CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

26

path = pathsubstring(1)

if (pathequalsIgnoreCase(CATEGORY))

Create category request collect

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

outprintln(ltfont color=CC66 0 0

face-verdana arial helvetica size = + lxbgtEnter

Authorltbgtltfontgt )

outprintln(ltbrgt You can enter

authors full name first name or last nameltpgt)

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess

id=forml name=formlgt)

outprintln(lttable border=0gt)

outprintln(lttrgt lttd valign=middle

align = lef txttgtltbgtAuthor ltbxttxtdgt )

outprintln(lttd valign=middle

align = lef txinput type = text name= author size = 40

value=x tdgt )

outprintln(lttrgt)

27

outprintln(lttrgt lttd colspan=2gt ltfont

size=-lgt)

outprintln(ltcentergt ltinput

type=radio name=author_mode value=exact

checkedgt Exact Name)

outprintln(ltinput type=radio

name=author_mode value=lastgtLast First Name (or

Initial) )

outprintln(ltcentergt)

outprintln(ltfontgt)

outprintln(lttdgt lttrgt)

outprintln(lttrgt lttd colspan=2gt ltpgt

ltbrgt lttdgt lttrgt)

outprintln(lttablegt)

outprintln(ltcentergt)

outprintln(ltinput type=submit

value=Search Now id=submitl name=submitlgt)

outprintln(cinput type=reset

value=Clear Form id=resetl name=resetlxpgt )

outprintln(ltcentergt ltformgt)

Create standard footer

28

CreateFooter(out)

outflush()

outclose()

The generated page looks like this

Figure 412 One of The Searching by Author PagesTinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorite l o o k H e lp

^ 3 4 s j ] S o zdStop Refresh Home Search Favorites History Mail Print EditBack bull

I t i h f e l f f httplocalhost8080servletReqCollectauthor

S ea rch Books

Home

C a t e g o r y

Author

Title

ISBN Publisher Date

poundj

TinyBookStore com

You can enter authors foil name first name or last name

A u t h o r jbjarne

C Exact N ame amp Last First N atne (or Initial)

Search Now | Clear Form

Taw boekstofeeoraH om e | Category | A uthor | Title | IS3M | Publisher Date

jpyright and disclaimer copy 1999-2001 F ang Xiao

ihtterteti

42 Design of Search by Different Requests

29

According to different requests the different pages should be produced There are many

common parts in the produced pages So we donrsquot need to code the common parts for

each page We can design the common parts into standard utility classes or static

functions You can simply call the standard classes or functions when you needed them

An example looks like this

CreateHeader(out)

CreateLeftMenu(out)

CreateFooter(out)

The three lines above invoke the standard functions CreateHeader() CreateFooter() and

CreateLeftMenu() which are developed in this thesis writing The CreateHeader()

function produces the top part of the pages The CreateLeftMenu() function produces the

left part of the pages The Createfooter() function produces the bottom part of the pages

You can find the source code in several servlets in Appendix

43 Servlet Chaining To Process Requests In Different Levels

A request can be handled by a sequence of servlets This system is designed to use the

first level servlets to handle the search requests If needed the first level servlets can

cooperates with the second level servlets by passing their processing result to the second

level servlets and let them to proceed the request until the final result is obtained The

final result is returned by the last servlet This is called servlet chaining The request

30

from the client browser is sent to the first servlet in the chain The response from the last

servlet in the chain is returned to the browser In between the output from each servlet is

passed as an input to the next servlet Each servlet in the chain has the option to change

or extend the content W e can see the example in the ReqCollect code

Example 431 A Part of Code of The ReqCollectjava

if (pathequalsIgnoreCase(AUTHOR))

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess id=forml

name=formlgt)

The ReqCollect servlet uses the getPathInfo() method to get the extra path information

This method returns the extra path information associated with request According to the

different extra path information the first level servlet invokes the different servlet of the

second level In this case ReqCollect invokes AuthorProcess servlet The final output

has been listed in Figure 412

31

44 Database Connectivity and Search from Database

The biggest advantage for servlets with regard to database connectivity is that the servlet

life cycle allows servlets to maintain open database connections An existing connection

can trim several seconds from a response time compared to a CGI program that has to

reestablish its connection for every invocation

Another advantage of the servlets over CGI and many other technologies is that JDBC is

database-independent JDBC is a SQL-level API - one that allows you to execute SQL

statements and retrieve the results if any The API itself is a set of interfaces and classes

designed to perform action against any database

An individual database system is accessed via a specific JDBC driver that implements the

javasqlDrivers interface Drivers exist for nearly all-popular RDBMS systems The

database connection used for Tiny Book Store uses a JDBC-ODBC bridge driver coming

along with the JDK 12 to allow access to standard ODBC data source such as the

Microsoft Access database

The first step in using a JDBC driver to get a database connection involves loading the

specific driver class into the applicationrsquos Java Virtual Machine This makes the driver

available later when we need it for opening the connection An easy way to load the

driver class is to use the ClassforNameQ method

32

ClassforName(sunj dbcodbcJdbcOdbcDriver)

When the driver is loaded into memory it registers itself with the javasqlDriverManager

class as an available database driver

The next step is to ask the DriverManager class to open a connection to a given database

where the database is specified by a specified formatted URL The method used to open

the connection is DriverManagergetConnection() It returns a class that implements the

javasqlConnection interface

Connection con =

DriverManagergetConnection(j dbcodbcsomedb

user passwd)

A JDBC URL identifies an individual database in a driver-specific manner Different

drivers may need different information in the URL to specify the host database

During the call to getConnection() the DriverManager object asks each registered driver

if it recognizes the URL If a driver says yes the driver manager uses that driver to create

the Connection object Here is an example

Example 441 A Part of Code of AuthorProcessjava

public void init() throws ServletException

try

ClassforNamesunj dbcodbcJdbcOdbcDriver)

con =

DriverManagergetConnection(j dbcodbcfxbookstore null

null)

catch (ClassNotFoundException e)

catch (SQLException e)

After we got the database connection we need to have some way to execute queries The

simplest way to execute a query is to use the javasqlStatement class Statement objects

are never instantiated directly instead a program calls the createStatement() method of

Connection to obtain a new Statement object

Statement stmt = concreateStatement()

34

A query that returns data can be executed using the executeQuery() method of Statement

This method executes the statement and returns a javasqlResultSet that encapsulates the

retrieved data

Example 442 A Part of Code of AuthorProcessjava

String sqlStmt =

if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where author= + name +II i n

else

sqlStmt = select from BOOK where author like +

name +

ResultSet rs = null

Statement stmt = concreateStatement()

rs = stmtexecuteQuery(sqlStmt)

35

A ResultSet object can be thought as a representation of the query result returned one row

at a time The next() method of ResultSet is used to move from row to row The

ResultSet interface also boasts a multitude of methods designed for retrieving data from

the current row The getStringO and getObject() methods can be used for retrieving

column values

Example 443 A Part of Code of AuthorProcessjava

while (rsnextO )

count++

outprintln(ltdtgtltbgt + count + )

String isbn = rsgetObject(ISBN)toString()

outprintln(lta href=servletDetailContent + isbn +

gt )

outprintln(rsgetObj ect(Title) toString() +

ltagtltbgt)

outprintln (ltnobrxfont color=990033gtUsually ships

in 24 hoursltBRgtltfontxnobrgt)

outprintln(ltddgt +

rsgetObj ect(Author) toString() )

36

outprintln( +

rs getOb j ect ( Publisher) toString () + +

rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

outprintln(ltbrgtltbrgt)

One of the outputs of servlet AuthorProcess is show in Figure 421 and Figure 441

Figure 441 One of The Outputs of Servlet AuthorProcess

37

File Edit View Favorites lo o k - Help M i

T 1 bdquo - 0 L Q 4 pound $ L L lBack r s Stop Refresh Home S earch Favorites History

A - Mail Print

Links rdquo Address | jyen j http7ocalhost808O$ervletAuthorProcess 3

Search B ooks

Home

CategoryA uthor

Title

ISBN

P u b l i sh e r D a te

Tiny Bookstore com

1 The C++ Prograitmuitg Language Usually ships in 24 hour Bjame Stroustrup Addison-Wesley Pub Co i 1997 Our Price 3147

T in yb o oks to re c om H ora e | Category | A uthor | Till | ISBN | Publisher P a t

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top of Page

gk j Local intranet

45 Session Tracking

Session Tracking is one of the most important techniques for any on-line store systems

This is because that HTTP protocol is a stateless protocol A HTTP server sees only a

series of requests and it by itself has no way to know exactly who is making the request

This means that when a customer puts a book in his shopping cart and then goes to other

pages to find more books next time when he puts another book in his shopping cart there

is no guarantee that he puts the book in the same cart It is very possible that he uses

another customerrsquos shopping cart at this time

38

To solve this problem session-tracking is introduced Traditional techniques used by

CGI include hidden form fields URL rewriting user authorization and persistent cookies

For server-side Java applications a built-in class supplied servlet can be used easily to

handle such tasks

When a user first accesses the site web server assigns a new HttpSession object and a

unique session ID to the user The session ID identifies the user and is used to match the

user with the HttpSession object in subsequent requests Usually the session ID is saved

on the client in a cookie or sent as part of a rewritten URL The Tiny Book Store uses this

technique

The Tiny Book Store is a classic shopping cart application A client can put items in his

virtual cart accumulating them until he checks out several page requests later How to

make sure a userrsquos shopping items will be put in his shopping cart or delete from his

shopping cart The Java Servlet API provide built in session tracking to handle this

problem Every user of a site is associated with a javaxservlethttpHttpSession object

that servlets can use to store or retrieve information about that user We can save any set

of arbitrary Java objects in a session object For example a userrsquos session object provides

a convenient location for a servlet to store the userrsquos shopping cart contents An example

shows below

Example 451 A Part of Code of AddToShoppingCartjava

39

1 Get current session object create one if necessary

2 HttpSession session = reqgetSession(true)

3 m_cart = (ShoppingCart)sessiongetValue(cart)

4 if (ra_cart == null) need new cart

5 create a shopping cart

6 m_cart = new ShoppingCart()

7 add to current session

8 sessionputValue(cart m_cart)

9

10

11 try

12 Statement stmt = m_concreateStatement()

13 ResultSet rs = stmtexecuteQuery(select from

book where ISBN= + isbn +)

14 if (rsnext())

15 book - new

BookDetails(rsgetObj ect(ISBN) toString()

16 rsgetObject(Title)toString()

rsgetObj ect(Authorrdquo) toString()

17 rsgetDouble(Price)

rsgetObj ect(PublicationDate) toString() )

18

40

1 9

2 0 catch (SQLException e)

21 e printStackTrace()

22

23 m_cartadd(bookgetlSBN() book)

The servlet uses its request objectrsquos getSession() method to retrieve the current

httpSession object

public HttpSession HttpServeltRequestgetSession (boolean create)

This method returns the current session associated with the user making the request If

the user has no current valid session this method creates one if create is true or return

null if create is false To ensure the session is properly maintained this method must be

called at least once before any output is written to the response Please look at the line 2

in the example 451

If you want to add data to an HttpSession object you can use the putValueQ method

public void HttpSessionputValue(String name Object value)

41

This method binds the specified object value under the specified name Any existing

binding with the same name is replaced This specifies at line 8 of the example 451

If you want to retrieve an object from a session you can use getValue() method

public Object HttpSessiongetValue(String name)

This method specified at line 3 of example 451 returns the object bound under the

specified name or null if there is no binding

From line 4 to line 9 the servlet checks whether the user already has a shopping cart If

the user didnrsquot have a shopping cart the servlet assigns a shopping cart to this user and

add the shopping cart to the current session to keep tracking The ShoppingCartjava class

is developed in this thesis writing code is provided in the appendix

From line 10 to line 21 the servlet knows the user already has a shopping cart m_con is

a data member of AddtoShoppingCart class Lines 12-13 have been discussed in the

previous section Lines 16-20 get some information of the book which the user selected

The information will be the data members of the ldquobookrdquo object that is an instance object

of BookDetailsjava class BookDetailsjava class is developed in this thesis writing the

source code is provided in the Appendix

Line 25 puts the book which is selected by the user into the shopping cart

42

Please see a set of pages are shown below

Figure 451 A Page Show All Information About A Book

TinjiRnfikStnre com - M inrnsnfl Interned Explnrpr

File Edit View Favorites Tools Help-

^ O 4 4 1 f i tStop Refresh Home I Search Favorites History Mail Print Edit

I Link gtgt Address [gl hgtplocalhos9l]IBrit-rvetDetailConetit-Ll20183l)544

S e a r c h B o o k s

Home-

C a t e g o r y

Author

Title

ISSNPublisher Pate

TinyBookStore com

The C++ Programming Languageby Bjarne Stroustrup

aISBN 0201889544 Addison-Wesley Pub Co 1997

Price 3147 Availability U sually ships within 24 hours

Add to cart

Done

R ev iew s

In tins brand-new third edition of The C + + Programming Language author Bjame Stroustrup the creator of C++ presents the full specification for the C++ language and standard library a spec that will soon become the joint ISOANSI C++ standard

g ig L o ca l in tranet

43

Figure 452 A Page Show Items In The Shopping Cart after A User Added Books To The Shopping Cart

H H I H I - I I

j File Edit View Favorites l o o k Help I f

| S ack Stop Refresh Home Search FavoritesJ V

History Wail Print

j Links Address |S1 http7localhost8O80servletAddToShoppingCart i i i i a i i i

( O ldquo ii

Shopping Cart Item s Price

An Introduction to fen e tic Algorithm sMelanie MteheU Quantity 1 Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

drle trgt

delete

delete

Price $ 2 2 0 Subtotal $ 2 2 0

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 6 7 5 6

|euro

rfuj Local intranet

44

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A Book From The Shopping Cart

^ A m a z o n c o m Shopping Cart - Microsoft Internet Explorer

- J A l 4Stop Refresh Home

gtH bdquo ] Back bdquo

httplocalhost8080servletDeleteFromShoppingCartitemgetltem()getlSBN()

Ji _J 3Search Favorites History

j - JMarl Print

~U ccdeg

Shopping Cart Item s

Core Java 2Cay S Horstrnaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d elete

delete

Price

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 4 5 5 6

rsquo0 1 Done gSsfLocat intranet

46 Check Out

This part is designed only using the HTML It collects all information from a user The

information will be written into the database

An important line in this HTML file is shown below

45

ltform method=POST

action=httplocalhost808 0servletCustomerlnfoProcessgt

This line will invoke the servlet CustomerlnfoProcess that will process all data collected

from the user This servlet will discuss in the next section The check out page shows in

Figure 461

Figure 461 A Check Out Page

M M iH M M M i M MmmrnfrnM File Edit View Favorites too ls Help

^ gt a 3 A hi -ltamp f V j HISllll mmB ack S lop R efresh H em e S earch 1 i l lie History M 1 Print Edit

^Links A ddrecs j ig ] h ltp localhostSO SO checkouth tm l i i i l a s

Custom er Information

First name (Fang

Middle initial |a

Last name [Xiao

Email address |fgtdaomitecnet

Account password Jxxxxx

C red it card num ber jl 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7

Credit card type ttV isa O BluebirdO MasterCard O Fisher

Credit card holder jFarig Xiao

Credit card expire date (tnmddyy) joi 0102 ~

Select shipping method t UPS 0 NormalO Express C Abnormal

| | ] Dorraquo raquo f j^ I o c a l intranet

47 Customer Information Processing

The customer information processing is handled by a servlet CustomerlnfoProces Its

source code is provided in the appendix

46

All information collected from the user should be written into the database therefore we

have to open a connection to a given database at first Example 461 is given for this

purpose

Example 471 A Part of Code of CustomerlnfoProcessjava

public void init() throws ServletException

try

ClassforName(sunjdbcodbcJdbcOdbcDriver)

m_con = riverManagergetConnection(jdbcodbcfxbookstore

null null)

catch (ClassNotFoundException e)

e printStackTrace()

catch (SQLException e)

e printStackTrace( )

There is a PO ST request in the check out page The servlet CustomerlnfoProcess will

handle the PO ST request by doPost function which is demonstrated in the following

example

47

Example 472 A Part of Source Code of CustomerlnfoProcessjava

public void doPost (HttpServletRequest req HttpServletResponse res)

throws ServletException IOException

ressetContentType(texthtml)

PrintWriter out = resgetWriter()

get information

String[] values = reqgetParameterValues(firstname)

if (values = null)

firstname = values[0]

values = reqgetParameterValues(middleinit)

if (values = null)

middleinit = values[0]

In the example the HttpServletRequest object res will get each data which was input by

the user by the getParameterValues() function

If the user is a returned user we donrsquot need open a new account again If the returned user

use the same credit card as previous we also donrsquot need to insert the credit card

48

information into the CREDITCARD table Otherwise we should insert all related

information into related table This is shown in the following example

Example 473 A Part of Source Code of CustomerlnfoProcessjava

Statement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where EmailAddress= +

email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext())

sql = insert into CUSTOMERACCOUNT (emailaddress password

firstname middleinit lastname) values ( + + email +

password + + firstname + + middleinit + lastname +

)

stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber= + creditcard

+

rs = stmtexecuteQuery (sql)

if (rsnext())

49

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype

HolderName ExpirationDate) values( + + creditcard + +

cardtype + + cardholder + 11 + expiredate + )

stmtexecute (sql)

All information related the books selected by the user can be obtained from the

shopping cart as shown in the following example

Example 474 A Part of Source Code of CustomerlnfoProcessjava

BookDetails book = null

ShoppingCartltern bookAndQuantity = null

Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getltems()

int aQuantity =0

String alSBN = null

while (itemshasMoreElements())

insert into Orderltems

bookAndQuantity = (ShoppingCartItem)itemsnextElement()

book = bookAndQuantitygetltem()

50

aQuantity = bookAndQuantitygetQuantity()

alSBN = book getISBN()

sql = insert into ORDERITEMS (shoppingCartID ISBN quantity)

values ( + + m_cartID + + aISBN + + aQuantity + )

stmtexecute (sql)

After all information inserted into related tables the servlet CustomerlnfoProcess will

produce invoice page The example page shows in Figure 471

51

Figure 471 An Invoice Page 3 Order List Microsoft Internet Explorer

is File Edit View Favorites Tools Help

J J J U r PS to p Refresh Hom e i -S earch Favorites History s Mai Print

Links Address iff 1 httpVlocalhostBOSOservletCustomerlnfoProcess 3

s5al Local intranet

Y ou r order reads as fo llow sE-MailAddress fiiiaomitecnet

ship to

Tel

Items

F ang Xiao12345 Western Plaza 23OmahaNE68154(402)123-4567

TitleCore Java 2Qtyl Price2579Subtotal2579

TitleJava Servlet PrograrnmingQtyl Price 1977 Sub total 1977 Total4556

i|51 D one

52

Chapter 5

Future Work

In this chapter we discuss two major problems for our future work They are the

Connection Pooling and Object-Oriented for better encapsulation

51 Connection Pooling

After we have used JDBC for a short time it will become evident that the major

performance bottleneck often comes right at the beginning when you are opening a

database connection This is because that opening a connection might involve a series of

low level communications between network protocols and database connection protocols

such as TCPIP ODBC etc

Servlet life cycle allows for extremely fast database access Servlet is loaded into Web

server only once Once it is loaded it can hold a connection to database all its life cycle

Every time it receives a request to read from or write data to database it can just use the

connection to do this

Here comes a problem however Suppose that a customer comes to the on-line store

During the period of selecting some items from the store he leaves his desktop and do

something else leaving this connection to database idling This will waste the precious

resource on the database From database port of view the connection to the database will

assign a space to hold corresponding status and to cache data For example Microsoft

SQL-Servertrade assigns about 36K bytes for each of its connection Resource on the

53

database is limited and idling connection causes such resource unable to be reused for

other users

To solve this problem we can use the technique called connection pooling Essentially a

connection pool is an object holding connections to backend database and managing the

number and status of connections For example if a connection in the pool idles over a

certain time of period the pool can terminate this connection if the requests are not the

same size of the connection pool the pool can dynamically shrink or expand the size of

itself A connection pool can run on a separate thread and is initialized when the server

starts or when a request to database is arrived

To implement a connection pool is pretty straight-forward Because of time constraint

however we did not do it in this paper and leave it as a possible future improvement

52 More Object-Oriented - Better Encapsulation

Another improvement might be done in the future is to create a HTML-related utility

class We have seen in this thesis that there are some duplicated code processing HTML

output such as ldquoout printIn ( lttbxtrgt lttrxtbgt)rdquo All these HTML-

related processes right now are used in a raw way That is they are not encapsulated A

better way to do this is to create a utility class or classes to deal with all HTML-related

processes and hide all HTML tags and format inside the class or classes For example

suppose that we create a Table class then we can use it in a way like

Table table = new Table()

54

table(somerow somecol contents)

table(somerow somecol some_image)

In this way we do not need to use HTML tags in our program and concentrate on the

programming logic The implementation is enriched with more object-oriented property

and therefore it is easy to maintain

55

Chapter 6

Conclusion

The increased awareness and popularity of the Internet make all kinds of electronic

commerce grow vigorously The most popular Web applications are the on-line stores

An on-line store system usually contains four components Web server business

procedure Database system application An on-line store system is different from web

publishing Currently there are three mainstream technologies which are widely used to

develop the on-line store systems CGI Microsoft ASP and Server-side Java application

Introducing the server-side Java application is one of the latest and most exciting trends

in Java programming We have discussed this technology in detail in this thesis The

server-side Java applications have many distinct advantages over CGI and other

technologies We present plenty of examples and figures to analysis the characteristics of

the server-side Java application

As a glance into the future electronic commerce will continue to grow driven by

purchases of home computers and other Web-enabled devices as well as new business

opportunities Electronic commerce is changing whole business procedures The future of

electronic commerce will be exciting and full of opportunities

56

APPENDIX A

Bibliography

57

[1] Karl Moss 1998 Java Servlets Mcgraw-Hill

[2] Jason Hunter William Crawford 1998 Java Servlet Programming O rsquoReilly

[3] Manoj Kumar Anand Rangachari Anant Jhingran Rakesh Mohan 1998 Sales Promitions on the Internet h ttpwwwibmcomiactech-paperhtml

[4] Manoj Kumar Stuart I Feldman 1998 Business Negotiations on the Internet httpwwwibmcomiactech-paperhtml

[5] Manoj Kumar Stuart I Feldman 1998 Internet Auction httpwwwibmcomiactech-paperhtml

[6] Shiwa Fu Jen-Yao Chung Walter Dietrich Vibby Gottemukkala Mitchell Cohen Shyhkwei Chen 1999 A Practical Approach to Web-Based Internet EDI httpwwwibmcomiacpapersicdcsws99indexhtml

[7] Zhong Tian Leo Y Liu Jing Li Jen-Yao Chung Vibby Guttemukkala 1999 Business-to-Business e-Commerce with Open Buying on the Internethttpw w w ibm comi acpapersobi -paperindex html

[8] Gerald J Tesauro Jeffrey O Kephart 1998 Foresight-Based Pricing Algorithms in an Economy os Software Agents http wwwi bm comi actech - paper html

[10] Jeffrey O Kephart James E Hanson Jakka Sairamesh 1998 Price and Niche Wars in a Free-Market Economy o f Software Agents httpwwwibmcomiactech-paperhtml

[11] Jeffrey O Kephart James E Hanson David W Levine Benjamin N Grosof Jakka Sairamesh Richard B Segal Steve R White 1998 Dynamics o f an Information-filtering Economy httpwwwibmcomiactech-paperhtml

[12] James E Hanson Jeffrey O Kephart 1998 Spontaneous Specialization in a Free-Market Economy os Agents httpwwwibmcomiactech-paperhtml

[13] Jakka Sairamesh Jeffrey O Kephart 1998 Price Dynamics o f Vertically differentiated Information Markets httpwwwibmcomiactech-paperhtml

[14] David Kosiur 1997 Understanding Electronic Commerce Microsoft Press

[15] Gunther Birznieks Selena Sol 1997 CGI fo r Commerce MampT Books - A Division of MIS Pres

58

[16] Ravi Kalakota Andrew B Whinston 1997 Electronic Commerce Addison Wesley

[17] Alex Fedorov Richard Harrison Dave Sussman Brian Francis Stephen Wood 1998 Profession Active Server Page 20 Wrox Press

[18] Calvin Austin Minica Pawlan 1999 Writing Advanced Application for the Java PlatformhttpVdeveloper iavasuncomdeveloperonlineTrainingProgrammin gJDCBooki ndexhtml

59

APPENDIX B

The Source Code of An On-Line Store System - Tiny Book Store

60

1 welcomeshtml

lthtmlgtltheadgtlttitlegtSearch Tinybookstorecomlttitlegtltheadgtltbodygt

lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=eeeeccgtlttrgtlttd rowspan=2 align=left valign=top width=15 cellspacing=0 cellpadding=0xIM G border=0 hspace=0 id=IMGl src=flowergif gtlttdgtlttd rowspan=2 align=left valign=centergtltstronggtlth2gtltigtTinyBookStorecomltigtlth2gtltstrongxtdgtlt trx tab legt

lttable border=0 width=100 cellspacing=0 cellpadding=0gtlttrgtlttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtltPgt

lttable width=100 cellspacing=0 cellpadding=5 border=0gtltTRgt ltTDgt ltTDgt ltTD colspan=2gt ltFONT FACE=verdanaarialhelvetica SIZE=-1 gtampnbsp ltFONTgt ltTDgt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD co lsp an = 2 x stro n g x fo n t face=verdanaarialhelvetica size=-lgtSearch B ooksltfontxstronggt ltTDgt ltTRgtltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt ltTD x f o n t face=verdanaarialhelvetica size=-l gt

lta href=w elcom eshtm lgtH om eltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt c T D x fo n t face=verdanaarialhelvetica size=-1 gt

lt A href= servletReqC ol 1 ec tc ategory gtC ate gory ltf o n tx A x T D gtltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollectauthorgtA uthorltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollecttitlengtTitleltorfo n tx A x T D gt ltTRgt

61

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectisbngtISBN ltA xfontxTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectpublisher_dategtPublisherD a telt A x fo n tx T D gtltTRgtlt tab lex p gtlttdgt

lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgtlttd valign=top align=leftgt

ltbr clear=allgtltPgtlt h 3 x s tro n g x fo n t color=ff6347gtWelcome to theltigt T in y B o o k S to rex o m lt ix fo n tx s tro n g x h 3 gt

ltbrgtlt s tro n g x b x h 3 x c e n te rgt F iv e Hot B o o k slt cen te rx h 3 x B x s tro n g gt

ltbrgtltservlet code=EchoServetTag myArgI=myValuel myArg2=myValue2gt ltparam name=myParm 1 value=Hellogtltparam name=myParml value=Worldgtltparam name=myParm2 value=myParmValue2gtltservletgt

lt td x trgt

lttablegt

ltTABLE width=100gtltTRgt ltTD width=50 valign=top align=Ieftgt ltTDgtltTD width=50 valign=top align=rightgtltfont size=-lgtltA href=topgtTop of P ag elt A x fo n tx T D gt ltTRgt

62

ltTABLEgt

ltcentergtltfont size=-lgtltA href=indexhtml gtTinybookstorecom HomeltAgt ampnbsplampnbsp ltA href=categoryhtml gtCategoryltAgt ampnbsplampnbspltA href= author html gtAuthorltAgt ampnbsplampnbspltA href= title html gtTitleltAgt ampnbsplampnbspltA href=7isbnhtml gtISBNltAgt ampnbsplampnbspltA href=publisherhtmrgtPublisher DateltAgtltpgtltfontgtltcentergt

ltPgtltcentergtlt b rx fo n t size=-lgtltA href=copyrighthtml gtCopyright and disclaimerltAgt copy 1999-2001 Fang Xiao ltfontgtltcentergt

ltbodygtlthtmlgt

63

2 AddToShoppingCartjava

ltpgt AddToShoppingCart is the servlet that process the action of adding item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javasql import javautil import javaxservlet import javaxservlethttp

public class AddToShoppingCart extends HttpServlet

protected Connection m_con = null protected ShoppingCart m_cart protected BookDetails book

public void initQ throws ServletException try

Class forName( sunj dbc odbc JdbcOdbcDriver)m_con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintstackTrace ()catch (SQLException e)

e prints tackT race ()

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

String[] params = reqgetParameterValues(isbn)

64

String isbn = get isbn from extra path infomationif (params = null)

isbn = params [0]

Get current session object create one if necessary HttpSession session = reqgetSession(true) m_cart = (ShoppingCart)sessiongetValue(cart)

if (m_cart == null) need new cart create a shopping cart m_cart = new ShoppingCart() add to current session sessionputValue(cart m_cart)

try Statement stmt = m_concreateStatement()ResultSet rs = stmtexecuteQuery(select from book where

ISBN=rsquo + isbn + rsquo)

if (rsnext()) book = new BookDetails(rsgetObject(ISBN)toString()

rsgetObject(TitIe)toStringOrsgetObject( Author) toStringO

rsgetDouble( Price) rs getObj ect( PublicationDate) toStringO)

catch (SQLException e)

eprintStackTrace()m_cartadd(bookgetISBN() book)

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lt h tm lxheadx titlegt T inyB ookS tore com S hopping

Cartlttitlexheadgt)outprintln(ltbody bgcolor=FFFFFF lmk=003399

alink=FF9933 vlink=996633 text=000000ngt)outprintln(lta nam e= topxmdashTop of Pagemdashx a gt )

65

outprin tln(ltpxa href=httplocalhost8080checkouthtmlximg src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=cccc99 gt)ou tp rin tln (lt tdxbrx tdgt )ou tp rin tln (lt tdxbrx tdgt )o u tp rin tln (lt tdxbrx tdgt )outprintln(lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=2xfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=left valign=topxfont

face=verdanaaria lhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=cccc99gt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lt td x b rx td gt ) outprintln(lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantityQ

outprintln(lttr bgcolor=FFFFFFgt) ou tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt )outprintln(ltbrgt + item getltem() get Author()) outprintln(ltbrgtQuantity + itemgetQuantityO) outprintln( ltbrgt) outprintln(lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=POST

action=7servletDeleteFromShoppingCartitemgetItem()getISBN()gt)

66

outprintln(ltpgt cinput type=hidden name=isbn value= + itemgetItem()getISBN())

outprintln(ltpgt ltinput type=submit name=ditemvalue=deletegt)

outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelve tica color=000000gt)

outprintln(ltNOBRgtltbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fon tx bx N O B R gt ltbrgt )

outprintln(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantity() + lt fo n tx b x N O B R x b rgt )

outprintln(ltfontgt) out println( lttdgt)

out printl n( lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)out println( lt fo n tx fo n tgt )outprintln(lttdxtrgt)outprintln(lttablegt)outprin tln(ltpxa href=httplocalhost8080checkouthtmlYximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)outprintln(ltbodygt lthtmlgt)

outflush()outclose()

67

3 AuthorProcessjava

bull ltpgt AuthorProcessbull This is the servlet that process the Author-search request and generatebull search resultbull Author Fang Xiao Purpose Thesis project Copyrightcopy Fang Xiao 1999-2001

import javaxservlet import jav ax servlet http import javaio import javasql

public class AuthorProcess extends HttpServlet protected final String EXACT = ldquoexactrdquo protected final String OTHERS = ldquolastrdquo

protected Connection con = null

public void init() throws ServletException try

ClassforName(ldquosunjdbcodbcJdbcOdbcDriverrdquo)con = DriverManagergetConnection(ldquojdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(ldquotexthtmlrdquo)PrintWriter out = resgetWriterQ

68

String[] valuesString name =

values = reqgetParameterValues(ldquoauthorrdquo) if (values = null)

name = values [0]

String mode = ldquordquovalues = reqgetParameterValues(ldquoauthor_moderdquo) if (values = null)

mode = values [0]

String sqlStmt = ldquordquo if (modeequalsIgnoreCase(EXACT))

sqlStmt = ldquoselect from BOOK where author=rsquordquo + name +else

sqlStmt = ldquoselect from BOOK where author like lsquordquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

ldquoYour Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ldquoltdlgtrdquo) 11 start Glossary List

while (rsnext()) count++outprintln(ldquolt d tx b gt rdquo + count + ldquo ldquo)String isbn = rsgetObject(ldquoISBNrdquo)toString()

69

outprintln(ldquolta href=servletDetailContentrdquo + isbn+

outprintln(rsgetObject(ldquoTitlerdquo)toString() +ldquolt a x b gt rdquo)

outprintln(ldquolt n o b rx fo n t color=990033gtUsually ships in 24 h o u rslt B R x fo n tx n o b rgt rdquo)

outprintln(ldquoltddgtrdquo +rsgetObject(ldquoAuthorrdquo)toString())

outprintln(ldquo ldquo +rsgetObject(ldquoPublisherrdquo)toString() + ldquo ldquo + rsgetObject(ldquoPublicationDaterdquo)toString())

outprintln(ldquoltbrgt Our Price ldquo +rsgetObject(ldquoPrice)toString())

outprintln(ldquolt b rx b rgt rdquo)

if (count == 0) outprintln(ldquoltdtgt No matched data foundrdquo)

outprintln(ldquoltdlgtrdquo) end Glossary List

catch (SQLException e) create footer here outprintln(ldquolttdgt lttrgtrdquo) outprintln(ldquolttablegtrdquo)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(ldquolthtmlgtrdquo) outprintln(ldquoltheadgtrdquo) outprintln(ldquolttitlegt TinyBookStorecom lttitlegtrdquo) outprintln(ldquoltheadgtrdquo)

outprintln(ldquoltbodygtrdquo)

70

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspacing=0 cellpadding=0 bgcolor=rdquoEEEECCYrsquogtrdquo)

outprintln(ldquolttrgtrdquo)outprintln(ldquolttd align=left valign=top width=90 gtrdquo) outprintln(ldquoltIMG border=0 hspace=0 id=IMGl

src=rdquodJavaWebServer20public_htmlflowergifrdquogtlttdgtrdquo) outprintln (ldquolttd width=30gtlttdgtrsquorsquo) outprintln(ldquolttd align=left valign=center width=300gtrdquo)

outprintln(ldquolt stro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x s tro n g x td gt rdquo) outprintln(ldquolttd align=right valign=centergtrdquo) outprintln(ldquolttdgtrdquo) outprintln(ldquolttd w id th= 20x tdgt rdquo) out pri ntln (ldquolttrgtrsquo rsquo) outprintln(ldquolttablegtrdquo)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ldquolttable width= 100gtrdquo)outprintln(ldquolttrgt lttd width=50 valign=top align=leftgt lttdgtrdquo) outprintln(ldquolttd width=50 valign=top align=rightgtrdquo) outprintln(ldquoltfont s iz e = - lx a href=rdquotoprdquogtTop of P agelt ax fon tgt rdquo) outprintln(ldquolttrgtrdquo) outprintln(ldquolttablegtrdquo)

outprintln(ldquoltcentergtrdquo) outprintln(ldquoltfont size=-lgtrdquo) outprintln(ldquolta

href=rdquohttplocalhost 8080welcomeshtmlrdquogtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080$ervletReqCollectcategoryrdquogtCategoryltagtampnbsplampnbsprdquo)

outprintln(ldquoltahref=Yhttplocalhost8080servletReqCollectauthorrdquogtAuthorltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_daterdquogtPublisheramp44Dateltagtrdquo)

outprintln(ldquoltpgtrdquo)

71

outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltpgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquolt b rx fo n t size=-lgtrdquo)outprintln(ldquoltA href=Y7copyrighthtmlrdquogtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiaordquo)outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltbodygtrdquo) outprintln(ldquolthtmlgtrdquo)

i

protected void CreateLeftMenu(PrintWriter out) System out println(ldquoLeftMenurdquo)

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspaeing=0 cellpadding=0gtrdquo)

outprintln(ldquolttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtrdquo)

outprintln(ldquoltpgtrdquo)

outprintln(ldquolttable width=rdquo 100rdquo cellspaeing=0 cellpadding=5border=0gtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquoltfont face=verdanaarialhelvetica SIZE=rdquo- l rdquogtampnbsp

ltfontgtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquolt strongxfon t face=verdanaarialhelvetica size=rdquo-

1 rdquogtSearch B ooksltfontxstronggtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd ldquo) outprintln(ldquoltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080welcomeshtmlYgt H o m elt fo n tx ax td gt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=rdquo-1rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080servletReqColIectcategoryrdquogt C ateg o ry lt fo n tx ax td gtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

72

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectauthorrdquogtAuthorltfontgtltagtlttdgtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width-2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l W rsquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltfontgtltagtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo-lYgtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_dateVrsquogtPublisher Dateltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolt tab lex p gt rdquo)

outprintln(lsquolsquolttdgtrdquo)outprintln(ldquolttd rowspan=4 width=5gtampnbspampnbspltbrgtlttdgtrdquo) outprintln(ldquolttd valign=top align=leftgtrdquo) outprintln(ldquoltbr clear=allgtrdquo)

73

4 BookTeatailsjava

ltpgt This is the class describing a book item in shopping cart

Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class BookDetails private String m_isbn = null private String m_title = null private String m_author = null private double m_price = 00 private String m_year = null

public BookDetails(String isbn String title String author double price String year)

thism_isbn = isbn thism_title = title thism_author = author thism_price = price thism_year = year

public String getISBN() return m_isbn

public String getTitle() return m_title

public String getAuthor() return m_author

public double getPrice() return m_price

ipublic String getYearQ

return m_year

75

5 CategoryProcessjava

ltpgt CategoryProcess This is the servlet that process the Category-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql import javautil

public class CategoryProcess extends FlttpServlet protected final String EXACT = exactprotected final String OTF1ERS = last

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

76

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentType( texthtml)Print Writer out = resgetWriterQ

String[] values String name = String sqlStmt =

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

else

path = pathsubstring(l) if (pathequalsIgnoreCase(cO 1))

sqlStmt = select from BOOK wherecategoryid=rsquo + cOl +

else if (pathequalsIgnoreCase(c02))sqlStmt = select from BOOK where

categoryid=rsquo + c02 +else if (pathequalsIgnoreCase(c03))

sqlStmt = select from BOOK wherecategoryid=rsquo + c03 +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftM enu(out)

Your Book Search Results try

77

if (con = null) Statement stmt = concreateStatement() rs = stmt executeQuery (sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn

+outprintln(rsgetObject(Title)toString() +

lt ax bgt )outprintln(ltnobrxfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltddgt +

rsgetObject( Author)toStringO)outprintln( +

rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)outprintln(ltbrgt Our Price +

rsgetObject( Price) toStringO) ltfont color=990000gtYou Save $1100

(20)ltfontgtoutprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

78

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)out println( lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20publicbdquohtmlflowergifgtlttdgt) outprintln(lttd width=3 0gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln( lt s tro n g x h 2 x igt T inyB ookS to re com lt ix h2x s tro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlngtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

79

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYrsquogtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln( ltfontgt)outprintln(ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rOwspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt)

outprintln(lttablewidth= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=Y2Ygt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y-1 Yrsquogtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2Yrsquogt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=Y-

lYrsquogtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=Y-lYgt)

80

outprintln(ltahref=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqColIectcategorygtCategoryltfontxagtlttdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(nltahref=httplocalhost8080servletReqCollectauthorVrsquogt A u th o rlt fo n tx ax td gtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httpIocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

6 CustomerlnfoProcessjava

ltpgt CustomerlnfoProcessThis servlet is responsible to process userrsquos information when heshe check out

Author Fang Xiao

Purpose Thesis projectCopyright (C) Fang Xiao 1999-2001

import javasql import javaio import j avau til import javaxservlet import javaxservlethttp

public class CustomerlnfoProcess extends HttpServlet protected Connection m_con = null protected HttpSession m_session = null protected static int m_cartID = 1 protected String firstname =protected String middleinit =protected String lastname =protected String email =protected String password =protected String creditcard =protected String cardtype =protected String cardholder =protected String expiredate =protected String shipping =protected String receiver =protected String address =protected String city =protected String state =protected String zipcode =protected String phone =

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)

82

m_con = DriverManagergetConnection(jdbcodbcfxbookstorenull null)

catch (ClassNotFoundException e)

eprintStackTrace()catch (SQLException e)

eprintStackTrace()i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

get informationString[] values = reqgetParameterValues(firstname) if (values = null)

firstname = values [0]

values = reqgetParameterValues(middleinit) if (values = null)

middleinit = values [0]

values = reqgetParameterValues(lastnameM) if (values = null)

lastname = values [0]

values = reqgetParameterValues(email) if (values = null)

email = values [0]

values = reqgetParameterValues(password) if (values = null)

password = values [0]

values = reqgetParameterValues(creditcard)

if (values = null) (creditcard = values [0]

values = reqgetParameterValues(cardtype) if (values = null)

cardtype = values [0]

values = reqgetParameterValues(cardholder) if (values = null) (

cardholder = values [0]

values = reqgetParameterValues(expiredate) if (values 1= null)

expiredate = values [0]

values = reqgetParameterValues(shippingrdquo) if (values = null)

shipping = values [0]

values = reqgetParameter Values (receiver) if (values = null)

receiver = values [0]

values = reqgetParameterValues(address) if (values = null)

address = values [0]

values = reqgetParameterValues(city) if (values = null) (

city = values [0])

values = reqgetParameterValues(state) if (values = null) (

state = values [0]

84

values = reqgetParameterValues(zipcode) if (values = null) (

zipcode = values [0]

values = reqgetParameterValues(phone) if (values = null)

phone = values[0]i

get session object m_session = reqgetSessionQ

try update databaseStatement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where Email Address=rsquo + email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext()) Systemoutprintln(insert customeraccount)

sql = insert into CUSTOMERACCOUNT (emailaddress password firstname middleinit lastname) values ( +

+ email + + password + + firstname +V + middleinit + + lastname + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber=rsquo +creditcard +

rs = stmtexecuteQuery (sql)

if (rsnext()) Systemoutprintln(insert creditcart)

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype HolderName ExpirationDate) values( +

+ creditcard + + cardtype + +cardholder + + expiredate + rdquo)

Systemoutprintln(sql)stmtexecute (sql)

i

85

sql = insert into SHOPPINGCART (ShoppingCartIDEmail Address CreditCardNumber ShippingType ReceiverName ReceiverAddress ReceiverCity ReceiverState ReceiverZipcode ReceiverPhone) values ( + m_cartID + V + email + Vrdquo +

creditcard + V + shipping + + receiver ++ address + V +

city + V + state + V + zipcode + V + phone +gt gt

Systemoutprintln(sql)stmtexecute (sql)

BookDetails book = nullShoppingCartltem bookAndQuantity = null Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

int aQuantity =0 String alSBN = null

while (itemshasMoreElementsO) insert into Orderltems bookAndQuantity =

(ShoppingCartItem)itemsnextElement()book = bookAndQuantitygetItem()

aQuantity = bookAndQuantitygetQuantity() alSBN - book getISBN()

Systemoutprintln(insert Orderltems)sql = insert into ORDERITEMS (shoppingCartED ISBN

quantity) values ( + m_cartID + +alSBN + + aQuantity + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

im_cartID++ must increase by one

86

catch (SQLException e) eprintS tackTrace()

printOrder(out)

public void printOrder(PrintWriter out) outprintln( lthtmlgt ltheadgt lttitlegt Order List lttitlegt ltheadgt) outprintln( ltbodygt)outprintln(lthlgt Your order reads as follows lthlgt)outprintln(lttablegt)outprintln( lttrgt)outprintln( lttdgtE-Mail Addres s lttdgt) outprintln(lttdgt+ em ail+lttdxtrgt) outprintln(lttrgt) outprintln(lttdgtship tolttdgt) outprintln(lttdgt+ receiver +ltbrgt) outprintln(address +ltbrgt) outprintln(city +ltbrgt) outprintln(state +ltbrgt) outprintln(zipcode + lt b rx td x trgt ) outprintln(lttrgt) outprintln( lttdgtTel lttdgt) outprintln(lttdgt+ phone +lttdxtrgt) outprintln(lttrgt) outprintln( lttdgtItems lttdgt)

BookDetails book = nullShoppingCartltem bookAndQuantity = nullEnumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

double total = 00

while (itemshasMoreElements()) bookAndQuantity = (ShoppingCartItem)itemsnextElement()

total += bookAndQuantitygetItem()getPrice() bookAndQuantitygetQuantityO

book = bookAndQuantitygetltem()

87

outprintln(lttdgtTitle+ bookgetTitle() + Qty + bookAndQuantitygetQuantity() + ltbrgt)

outprintln(Price + bookgetPrice() + Subtotal + bookAndQuantitygetQuantityO bookgetPrice() +ltbrgt)

outprintln(Total + total )outprintln(lttdxtrgt)outprintln(lttablegt)outflush()outclose()

7 DeleteFromShoppingCartjava

ltpgt DeleteFromShoppingCart is the servlet that process the action of deleting item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javautil import javaxservlet imp ort j avax servlet http

public class DeleteFromShoppingCart extends HttpServlet

protected ShoppingCart m_cart protected BookDetails book

public void doPost(HttpServletRequest req FIttpServletResponse res) throws ServletException IOException res setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String[] params = reqgetParameterValues(isbnrsquo) String isbn = get isbn hidden fieldif (params = null)

isbn = params [0]

Systemoutprintlnfisbn = + isbn)

Get current session objectHttpSession session = reqgetSession()m_cart = (ShoppingCart)sessiongetValue(carf)

m_cartremove(isbn)

89

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lthtm lgtltheadxtitlegtAm azoncom Shopping

C artlt titlexheadgt)out pri ntln ( ltb ody bgcolor=FFFFFF link=003399

alink=FF9933 vlink=Yrsquo996633Y text=rdquo000000rdquogtrdquo)outprintln(lta nam e= top xmdashTop of Pagemdashx a gt ) ou tp rin tln (lt pxa href=httplocalhost8080checkouthtmlximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=Yrsquocccc99Yrsquo gt)ou tp rin tln (lt tdxbrx tdgt )out pri ntln ( lt td x b r x td gt )outprintln( lt td x b r x td gt )out println (rsquo1 lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=Y2Yxfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=YleftY valign=YtopYxfont

face=verdanaarialhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=Ycccc99Yrsquogt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantity()

outprintln(lttr bgcolor=FFFFFFgt) o u tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt)outprintln(ltbrgt + itemgetItem()getAuthor())

90

outprintln(ltbrgtQuantity + itemgetQuantityO)outprintln(ltbrgt)outprintln( lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=VPOST

action=7servletDeleteFromShoppingCartVgt)outprintln(ltpgt ltinput type=hidden name=isbn value= +

itemgetItem()getISBN())outprintln(ltpgt cinput type=submit name=ditem

value=Y rsquo deletegt rsquo rsquo)outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelvetica color=000000gt)

outprintln(ltNOBRxbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fo n tx b x N O B R x b rgt )

outprintin(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantityO + lt fo n tx b x N O B R x b rgt )

outprintln( ltfontgt) outprintln( lttdgt)

i

outprintln(lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)outprintln(ltfontxfontgt)outprintln( lt td x trgt ) outprintln(lttablegt)ou tp rin tln (lt pxa href=Yhttplocalhost8080checkouthtmlYximg

src=YdYJavaWebServer20servletsimageproceed-to-checkoutgifYxagt)outprintln(ltbodygt lthtmlgt)

outflushOoutcloseQ

91

8 Detailcontentjava

ltpgt DetailContent is the servlet responsible for generating detailed information page for a book The book is identified by its ISBN Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaio import javasql import jav ax servlet import javaxservlethttp

public class DetailContent extends FIttpServlet protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String isbn = reqgetPathInfo()isbn = isbnsubstring(l) skip over rsquo rsquo

92

try String sql = select from book where ISBN=rsquo + isbn +

Statement stmt = concreateStatement()ResultSet rs = stmtexecuteQuery(sql)

create header here CreateHeader(out)

create left menu here CreateLeftMenu(out)

outprintlnfctd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintlnfctd valign=top align=leftgt)

cellpadding=0gt)

outprintln(ltbrgt)

create detailcontent here while (rsnext())

String strlSBN = rsgetObject(ISBN)toString() outprintln(lttable width=100 border=0 cellspacing=0

+ltbgtlttdxtrgt)

+ lt tdx trgt)

outprintln(lttrgt lttd colspan=3 align=leftxbgt) outprintln( rsgetObject(Title)toString()

outprin tln(lt trxtd colspan=3 align= leftxbgt by ltbgt) out println( rs getObj ec t( Author) toS tringQ

cellpadding=0gt)

outprin tln(lt trx td x i m g src=xtdgt) outprintln( lttd valign=topgt) outprintln( lttable border=0 cellspacing=0

outprintln( lt t r x td valign=topxbgtPrice )outprintln(

rsgetObject(Price)toString() + lt b x td x trgt ) outprintln(

lt trx td x b gt A v ailab ility lt b gt U su a lly lt td x trx b rgt )outprintln( lt t r x td vlign=topgtships within 24

hou rs lt td x trgt )outprintln( lt tab lextdgt)

93

outprintln( lttd align=rightgt) outprintln( lttable border=0 cellspacing=0

cellpadding=0gt)outprintln( lt trx td gt )outprintln( ltform

method=POST action=httplocalhost8080servletAddToShoppingCartgt)outprintln( ltinput

type=hidden name=isbn value= + strlSBN +outprintln( cinput

type=submit value=Add to cart )outprintln( lt tdx trgt )

outprintln( lt tab lex tdgt ) outprintln(rdquolttrgt)outprintln(lttrgt lttd clospan=3 align=leftgt ISBN ) outprintln( strlSBN +lttdxtrgt)outprintln(lttrgt lttd clospan=3 align=leftgt) outprintln( rsgetObject(Publisher)toString()

+rsgetObject(PublicationDate)toString() + lt tdx trgt )outprintln(lttablegt)outprintln(ltbrgt)outprintln(ltbrgt)

output reviewString review = rsgetObject(BookReview)toString() if (review = null)

review =DJavaWebServer20servletsreview + review

outprintln(ltbgtReviewsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(review))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprin tin (thisLine) ou t println( ltpgt)

)

icatch (IOException e)

need do something here eprintstackTrace ()

94

outprintln(ltbrgt)String comment =

rsgetObject(BookComment)toString()if (comment = null) comment = DJavaWebServer20servletscomment +

commentoutprintln(ltbgtReader Commentsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(comment))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprintln(thisLine) outprintln(ltpgt)

catch (IOException e)

need do something here eprintstackTrace ()

ou t pri ntln ( ltb rgt)

catch (SQLException e)

need to do something here

add table end tab outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt)

95

ou t pri ntln ( lthe adgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=YTOO cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d J avaW eb S erver 2 Opublic_htmlflo wer gif gtlttdgt) outprintln(lttd width=30gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyBookStorecomltigtlth2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln( lttd width=20gtlttdgt) out pri ntln ( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-1 gt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

96

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsptampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out prin tin ( ltcen tergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

eellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=Yhttplocalhost8080Avelcom eshtm lgtHom eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-1gt)

97

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=http7localhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref-httpIocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lVgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

98

9 EchoServlettagjava

import javaio import j avasql import javaxservlet import javaxservlethttp

public class EchoServletTag extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintStackTrace ()catch (SQLException e)

eprintStackTrace()

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

try Statement stmt = concreateStatementQResultSet rs = stmtexecuteQuery(select from book where title

like rsquoProgrammingrsquo)int count = 1outprintln(ltdlgt)while (rsnext() ampamp count lt 6)

outprintln(ltdtxbgt + count + )

99

String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn + outprintln(rsgetObject(Title)toString() + lt ax bgt ) outprintln(ltddxnobrgtltfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltbrgt + rs getObject( Author) toStringO) outprintln( + rsgetObject(Publisher)toStringO +

+ rsgetObject(PublicationDate)toStringO)outprintIn(ltbrgt Our Price +

rsgetObject(Price)-toStringO)

out println( lt b rx b rgt ) count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()outprintln(lttdgt lttrgt) outprintln(lttablegt) outflush() outcloseO

ii

100

10 ISBNProcessjava

ltpgt ISBNProcess This is the servlet that process the ISBN-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javax servlet import javaxservlethttp import javaio import j a vasql

public class ISBNProcess extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forN ame( sun j dbc odbc J dbcOdbcDri ver)con = DriverManagergetConnection(j dbc odbc fxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s s e tC on te n tTy pe ( tex th tm l)PrintWriter out = resgetWriter()

String[] values

String alSBN =

values = reqgetParameterValues(isbn) if (values = null)

alSBN = values [0]

String sqlStmt = select from BOOK where ISBN= + alSBN

ResultSet rs = null int count = 0

create header here bullCreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject( IS BN) toStringO

outprintln(lta href=servletDetailContent + isbn+ gt)

outprintln(rsgetObject(Title)toStringO +lt ax bgt )

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toStringO)

outprintln( +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

102

outprintln(ltbrgt Our Price +rsgetObject(rdquoPrice) toStringO)

outprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width= 100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d Uava WebS erver2 Opubhc_htmlflo wer gif gtlttdgt) outprintln(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS tore com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt)

103

out println( lttdgt) outprintln(lttd w id th= 20x tdgt ) out pri ntln( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)out pri ntln (lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) out pri ntln ( lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsp1ampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out println( ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

104

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 eellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Books lt fontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocaihost8080servletReqCollectcategorygtCategoryltfontxaxtdgt lttr gt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

105

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lttablegtltpgt)

o u t println( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

ii

106

11 PublisherDataProcessjava

ltpgt AuthorProcess This is the servlet that process the PublisherampDate-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql

public class PublisherDateProcess extends FIttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbc odbc JdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentT ype ( texthtml)PrintWriter out = resgetWriterQ

String[] valuesString namel =

107

values = reqgetParameterValues(publisher) if (values = null)

nam el = values [0]

String name2 =values = reqgetParameterValues(rdquopublication_date) if (values = null)

name2 = values [0]

String sqlStmt =sqlStmt = select from BOOK where publisher=rsquo + namel + rsquoand

publicationdate=rsquo +name2

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprin tln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toStringO outprintln(lta href=servletDetailContent + isbn

+ gt)outprintln(rsgetObject(Title)toString() + (

lt ax bgt )

108

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rs getObj ect( Author) toS tring())

outprintln(V +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

outprintln(ltbrgt Our Price +rsgetObject( Price) toStringO)

outprintln( lt b rx b rgt )

if (count == 0) (outprintln(ltdtgt No matched data found)

outprintln(rdquoltdlgt) end Glossary List

catch (SQLException e) ( create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 celipadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt)

109

outprintln(ltIMG border=0 hspace=0 id=IM Gl src=dJavaW ebServer20public_htmlflowergifxtdgt)

outprintln(lttd width=3 0 x td gt ) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS to re com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ctable w idths 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt) outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) ou t println( ltcentergt)

no

outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaim er^A gt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) out pri ntln ( lthtml gt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-1 gtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=V-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-1gt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

I l l

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitleYrsquogt T itle lt fo n tx a x td gt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(nltahref=Yhttplocalhost8080servletReqCollectisbnY gtISBNltaxfontxtdgt lttrgt)

outprindn(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdana arial helvetica size=Y -1 gt)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYgtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

1 12

12 ReqCollectjava

ltpgt This is a servlet responsible for generating search request collection page It read extra path information from URL and then according to the extra path information it generates corresponding page format Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001import javaxservlet import javaxservlethttp import javautil import javaio

public class ReqCollect extends HttpServlet

protected final String CATEGORY = categoryrdquo protected final String AUTHOR = author protected final String TITLE = titlerdquo protected final String ISBN = isbnprotected final String PUBLISHER_DATE = publisher_date

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentType( texthtml)PrintWriter out = resgetWriter()

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

)else

Create standard header CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

path = pathsubstring(l) if (pathequalsIgnoreCase(CATEGORY))

I I Create category request collect

outprintln(ltpgt)outprintln(lth3xstronggtProgrammingltstronggtlth3gt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc01gtAlgorithmsltagt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc02gtCampC++ltagt)outprintln( Delphi) outprintln(lta

href=httplocalhost8080servletCategoryProcessc03gtJavaltagt)outprintln( MFC Perl)

outprintln(software Design UML Visual Basic More)

outprintln(lth3xstronggtW eb Developm entltstrongxh3gt) outprintln(ASP Commercem Cyberculture HTML

JavaScript)

outprintln(Security Web Design XML more)

outprintln(lth3xstronggtGraphics amp Softwareltstrongxh3gt) outprintln(Asobe CAD Desktop Publishing Graphics)

outprintln(Microsoft More)

outprintln(lth3xstronggtNetW orking amp O Sltstrongxh3gt) outprintln(Linux Macs Oracle PCs SAp R3 SQL)

outprintln(TCPIP Unix WindowsampDOS W indowsNT)

out println( More)

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

1 14

outprintln(ltfont color-CC6600 face=verdana arial helvetic a size=+1 gtltbgtEnter Authorltbgtltfontgt)

outprintln(ltbrgt You can enter authorrsquos full name firstname or last nameltpgt)

outprintln(ltform method=POST action=httplocalhost 8080servletAuthorProcessY id=form 1 name=form 1 gt)

outprintln( lttable border=0gt) outprintln(lttrgt lttd valign=middle

ahgn= leftx ttx b gt A u th o rlt b gt lt ttx td gt )outprintln(lttd valign=middle align= leftx input

type=YtextY name=author size=40 value=YYxtdgt)outprintln(lttrgt)outprintln(lttrgt lttd colspan=2gt ltfont size=-lgt) outprintln(ltcentergt ltinput type=radio

name=Yauthor_modeY value=YexactY checkedgt Exact Name)outprintln(ltinput type=radio name=author_mode

value=lastgtLast First Name (or Initial))outprintln(ltcentergt) outprintln(ltfontgt) outprintln(lttdgt lttrgt)outprintln(lttrgt lttd colspan=2gt ltpgt ltbrgt lttdgt lttrgt)outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search NowY

id=submitl name=submitlgt)outprintln(cinput type=reset value=YClear Form

id=resetl nam e= rese tlxpgt )outprintln(ltcentergt ltformgt)

else if (pathequalsIgnoreCase(TITLE))

Create title request collect

outprintln(ltfont color=CC6600 face=verdanaarialhelvetica s ize= + lxbgt E n ter T itlelt bxfontgt)lsquo

outprintln(ltbrgtYou can enter the exact title or part oftitleltPgt)

outprintln(ltform method=YPOSTY action=Yhttplocalhost8080servletTitleProcessY id=form l name=formlgt)

outprintln(lttable border=0gt) outprintln(lt trxtd valign=middle

a lig n = le ftx ttx b gt T itle lt b x t tx td gt )

115

outprintln(lttd valign=middle align= leftx input type=text name=title size=40 value=xtdgt)

outprintln(lttrgt) outprintln(lttrgt) outprintln( lttd colspan=2gt) outprintln( ltfont size=-lgt) outprintln( ltcentergt)outprintln( ltinput type=radio name=title-mode

outprintln(value=exact checkedgt) outprintln( Exact Title)outprintln( ltinput type=radio name=title-mode

outprintln( value=titlewords gt ) outprintln( Title Words )outprintln(ltcentergt ltfontgt lttdgt lttrgt)outprin tln(lt trxtd c o ls p a n = 2 x p x b r x td x tr gt ) outprintln(lttablegt)

outprintln(ltcentergt)outprintln( ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln( ltinput type=reset value=Clear Form

id=resetl nam e= resetlxP gt )outprintln(ltcentergt) ou t println ( ltformgt)

outprintln(lthr noshade size=lgt)

outprintln(ltBgtExamplesltBgt)outprintln(ltULgt)outprintln(ltLIgtEntering ltbgtampquotJava Servlet

Programmingampquotltbgt in the title field )outprintln(and choosing ltemgtExact Titleltemgt finds the

book without also finding the many books)

outprintln(ltLIgtEntering ltbgtampquotJavaampquotltbgt in the Title field and choosing ltemgtTitle Wordsltemgt)

outprintln( finds all books whose title are related toltigtJavaltigt)

outprintln(ltULgt)

out printl n( lttdgtlttrgt) outprintln(lttablegt)

ielse if (pathequalsIgnoreCase(ISBN))

Create isbn request collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n ter ISBN ltbxfontgt)outprintln(ltbrgt) outprintln(ltform method=POSTY

action=httplocalhost8080servletISBNProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

a lig n = le ftx ttx b gt IS B N lt b x t tx td gt ) outprintln(lttd valign=middle a lign= leftx input

type=text name=isbn size=40 value=xtdgt)outprintln(lttrgt)

outprin tln(lt trxtd c o ls p a n = 2 x p x b rx td x trgt ) outprintln(lttablegt)

out println( ltcentergt)outprintln(ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln(ltinput type=reset value=Clear

FormV id=resetl nam e= resetlxP gt )outprintln(ltcentergt)outprintln(ltformgt)

outprintln(lthr noshade size=lgt)

outpiintln(ltULgtrdquo)outprintln(lttdxtrgt)outprintln(lttablegt)

else if (pathequalsIgnoreCase(PUBLISHER_DATE))

Create publisher date collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n te r Publisher and Publication D ate ltb gtltfontgt)

1 17

outprintln( ltbrgt) outprintln(ltform method=POST

action=httplocalhost8080servletPublisherDateProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

align=leftgtlt ttxbgt P ub lisher lt b x t t x t d gt )outprintln(lttd valign=middle align= leftx input

type=text name=publisher size=40 value=xtdgt)outprintln(lttrgt) outprintln(lttrgt lttd valign=middle

a lign= leftx ttxbgt P ub lica tion D a te lt b x ttx td gt )outprintln(lttd valign=middle align= leftx input

type=text name=publication_date size=40 value=xtdgt)outprintln(lttrgt)outprintln( c t r x td c o l s p a n = 2 x p x b r x td x t r gt )outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search Now

id=submitl name=submitlgt)outprintln(ltinput type=reset value=VClear FormYrsquo

id=resetl nam e= resetlxpgt )outprintln(ltcentergt) outprintln(ltformgt) outprintln(lthr noshade size=lgt)

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush()outclose()

)

protected void CreateHeader(PrintWriter out) outprintln(lthtmigt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding bgcolor=EEEECCgt)

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20pubiic_htmlflowergifgtlttdgt) outprindn(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(lt s tro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x stro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt)outprintln(lttd w idth=20xtdgt) ou t println ( rsquo lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

out pri ntln ( ltfon tgt) outpri ntln( ltcentergt ) out pri ntln ( ltpgt) outprintln(ltcentergt) outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)out pri ntln ( ltf on tgt) outprintln(irltcentergt) out println ( ltbodygt) out pri ntln( lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

cellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=YT00 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE= -lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

1 gtS earch B ookslt fontx stronggt)outprintln(lttdgt lttrgt)out pri ntln (lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=l-lgt)

outpri ntln(ltahref=httplocalhost8080servletReqCoilectauthorgtA uthorltfontxaxtdgtlttrgt)

120

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprindn(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=V-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln(lttablexpgt)outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

121

13 ShoppingCartjava

ltpgt This is the definition for ShoppingCart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import Javautil

public class ShoppingCart Hashtable items = null int numberOfltems = 0

public ShoppingCart() items = new Hashtable()

add BookDetails to cart param bookID isbn param book book need to be added to cart copyreturn void

public void add(String bookld BookDetails book) if(itemscontainsKey(bookId))

ShoppingCartltem scitem = (ShoppingCartltem)itemsget(bookld) scitemincrementQuantity ()

else ShoppingCartltem newltem = new ShoppingCartltem(book) itemsput(bookId newltem)

numberOftems++

param bookld isbn

public void remove(String bookld) if(itemscontainsKey(bookd))

items remove (bookld) numberOfltems - -

public Enumeration getltems() return itemselements()

protected void finalize() throws Throwable items clear()

public int getNumberOfItems() return numberOfltems

public void clear() items clear() numberOfltems = 0

123

14 ShoppingCartltemjava

ltpgt This is the definition for the shoppingcart item Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class ShoppingCartltem BookDetails item int quantity

public ShoppingCartItem(BookDetails anltem) this item = anltem this quantity = 1

public void decrementQuantity() if (quantity gt 0)

quantitymdash

public void incrementQuantity() thisquantity++

i

public BookDetails getltem() return thisitem

public int getQuantity() ( return thisquantity

i

124

15 StandardFooterjava

package servlets

import j avax servlet

ltpgt This is a server side include servlet that will format the TinyBookStore HTML footer

public class StandardFooter extends GenericServlet

ltpgtPerform the servlet service

param req The request from the client param res The response from the servlet public void service (ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the response javaioPrintW riter out = new

javaioPrintWriter(resgetOutputStream())

Format the standard footeroutprintln(ctable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(rdquoltfont s iz e = - lx a href=topgtTop of

P agelt ax fon tgt )outprintln(lttrgt) out println( lttablegt) outprintln(ltcentergt) outprintln(rsquoltfont size=-lgt)outprintln(lta href=7welcomeshtmlYgtTinybookstorecom

Homeltagt ampnbsplampnbsp)outprintln(lta href=categoryhtmlgtCategoryltagt

ampnbsplampnbsp)outprintln(lta href-authorhtmlgtAuthorltagt

ampnbsplampnbsp)outprintln(lta href=titlehtmlrdquogtTitleltagt ampnbsplampnbsp)

125

outprintln(lta href=isbnhtmlgtISBNltagt ampnbsplampnbsp) outprintln(lta href=7publisherhtmlgtPublisheramp44

Dateltagt)outprintln(ltpgt)outprintln(ltfontgt)ou t println ( ltcen tergt)outprintln(ltpgt)out println (ltcentergt )outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and

disclaim er^A gt ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln( ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

outflush()outclose()

126

16 StandardHeaderjava

package servlets

import javaxservlet

ltpgt This is a server side include servlet that will format the standard TinyBookStore HTML header The Title of the page will be set to the value of the title property

public class StandardHeader extends Generic Servlet

ltpgt Performs the servlet service param req The request from the client param res The response from the servlet

public void service(ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the responsejavaioPrintWriter out = new javaioPrintWriter(resgetOutputStream())

Get the title of the page Set to empty string if no title parameter was givenString titles[] = reqgetParameterValues(title)String title = if (titles = null)

if (titleslength gt 0) title = titles [0]

outprintln(lthtmlgt) outprintln(ltheadgt) outprintln(lttitlegt + title + lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=T00 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)

127

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src=dJavaWebS erver2 Opublic_htmlflower gi A gtlttdgt) out println(lttd width=3 O x td gt ) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyB ookStorecom ltigtlth2xstrongxtdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) out printl n ( lttd width=20gtlttdgt) out printl n( lttrgt) outprintln(lttablegt)

outflush()outclose()

128

17 TitleProcessjava

ltpgt TltleProcess This is the servlet that process the Tltle-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import j avax servlet import javaxservlethttp import javaio import j avasql

public class TitleProcess extends HttpServlet protected final String EXACT = exact protected final String OTFIERS = titleWords

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

129

String[] valuesString name =

values = reqgetParameterValues(title) if (values = null)

name = values [0]

String mode =values = reqgetParameterValues(title_mode) if (values = null)

mode = values [0]

String sqlStmt =if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where title=rdquo + name +else

sqlStmt = select from BOOK where title like rsquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString()

130

outprintln(lta href=servletDetailContent + isbn+

outprintln(rsgetObject(Title)toString() +ltagtltbgt)

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toString())

outprintln( +rsgetObject(Publisher)toString() + + rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +rsgetObject(Price)toString())

outprintln(ltbrxbrgt)i

if (count == 0) outprintln(ltdtgt No matched data found)

ioutprintln(ltdlgt) II end Glossary List

catch (SQLException e) i create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

131

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=EEEECCgt)

outprintln(rdquolttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaW ebServer20public_htmlflowergifxtdgt) outprintln(lttd w idth=30xtdgt) outprintln(rdquolttd align=left valign=center width=300gt)

outprintln(ltstronggtlth2gtltigtTinyBookStorecomltixh2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(rdquolttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln( lttrgt)outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(rdquolta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(rdquoltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

132

out println( ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) outprintln( ltcentergt) outprin tln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disciaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) S y s te m out println( LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt )

outprintln(lttable width= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y- lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost 8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

133

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lt tab lex pgt )

ou t pri ntl n ( lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

134

18 checkouthtml

lthtmlgtltheadgt lttitlegtCustomer Informationlttitlegt ltheadgtltbodygt

lt hlgt ltcentergt ltbgt Customer Information ltbgt ltcentergt lt hlgt

ltform method=POST action=httplocalhost8080servletCustomerInfoProcessgt lttable border=0gt

lttrgtlttd align=rightgtFirst namelttdgtlttd colspan=2 align= leftx input type=text name=firstname size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtMiddle initiallttdgtlttd colspan=2 align= leftx input type-text name=middleinit s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtLast namelttdgtlttd colspan=2 align= leftx input type-text name=lastname size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtEmail addresslttdgtlttd colspan=2 align= leftx input type=text name=email s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgt Account pass word lttdgtlttd colspan=2 align= leftx input type=text name=password s ize= 40x tdgt

lttrgtlttrgt

lthrgtlttrgt

lttablegtltbrgt

ctable border=0gtlttrgt

lttd align=rightgtCredit card numberlttdgtlttd colspan=2 align= leftx input type=text name=creditcard s ize= 40x tdgt

lttrgtlttr valign=topgt

135

lttd align=rightgtCredit card typelttdgtlttd align=leftgtltinput type=radio name=cardtype value=visagtVisaltbrgtltinput type=radio name=cardtype value= mastercard gtMasterCardltbrgt lttdgtlttd align=leftgtltinput type=radio name=cardtype value=bluebirdgtBluebirdltbrgtltinput type=radio name=cardtype value=fishergtFisherltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtCredit card holderlttdgtlttd colspan=2 a lign= leftx input type=text name=cardholder s ize= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCredit card expire date (mmddyy)lttdgtlttd colspan=2 align= leftx inpu t type=text name=expiredate size= 40x tdgt

lttrgtlt trx trgtlt trx trgtlttr valign=topgt

lttd align=rightgtSelect shipping methodlttdgtlttd align=leftgtltinput type=radio name=shipping value=upsgtUPSltbrgtltinput type=radio name=shipping value=expressgtExpressltbrgtlttdgtlttd align=leftgtcinput type=radio name=shipping value=normalgtNormalltbrgtltinput type=radio name=shipping value=abnormalgtAbnormalltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtReceiver Namelttdgtlttd col span=2 a lign= leftx inpu t type=text name=receiver size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtAddresslttdgtlttd colspan=2 align= leftx input type=text name=address size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCitylttdgtlttd colspan=2 align= leftx inpu t type=text name=city size= 4 0 x td gt

lttrgtlttrgt

136

lttd align=rightgtStatelttdgtlttd colspan=2 align= leftx inpu t type=text name=state s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtZipcodelttdgtlttd colspan=2 align= leftx inpu t type=text name=zipcode size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtPhonelttdgtlttd colspan=2 align= leftx input type=text name=phone size= 40x tdgt

lttrgtlttablegtlt b rx b rgtcinput type=submit value=Process name=actiongt

ltformgt

ltbodygtlthtmlgt

137

APPENDIX C

Screen Display of the Test

138

mmm File Edit View Favorites T o d s Help

^ Jit j j ^ LJ U 3) ~ pound=J _Am Back - S top Refresh Home j Search Favorites History Mait Print Edit

Links gtgt Address |4S ] httDVIocalhost808QAvdcorne shtml

TinyBookStore com

Welcome to the TJnyBoakStoro com

F i v e H o t B o o k s

1 T h e C + + Programming LanguageU s u a l l y s h i p s i n 24 h o u r s

B j a r n e S t r o u s t r u p A d d i s o n - W e s l e y Pub Co 1997 Our P r i c e 31 47

2 - P r o g r a m m i n g V i s u a l C + +U s u a l l y s h i p s i n 24 h ou r I I

Local intranet

Search BooksHorne

Category

Author

Title

ISBNPublisherDate

3 iigt60

3 1 S earch T inybooksloiecom - Microsoft Internet Explorer

139

T inyB ookStorecom - Microsoft Internet Explorer

j File Edit View Favorites lo o k Help

q a a H 3 1 d B ack S top R efresh Home S earch Favorite History j M aJ Print

Links gtgt A ddress httpV localhost 308QoryleV PetailCorterV 020i8SC l4

MM

Edit

Search Books

Home

Category

Author

Title

ISBN

PublisherDate

TinyBookStore com

The C++ Programming Languageby B j a r n e S t r o u s t r u p

0

ISBN 0 2 0 1 8 8 9 5 4 4 A d d i s o n - W e s 1e y P ub Co 199 7

Reviews

P r i c e 31 47A v a i 1ab i 1i t y U s u a l 1 ys h i p s w i t h i n 24h o u r s

Aic t o c a r t

ijgJ Local intranet

140

^ | I myBook5torecom Shopping Cart - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

[v] I ^ -J JB ack - Stop R efresh Home S earch Favorites History lsquo Mail Print

Links A ddress 0 1 h ttp localhost8080servetA ddT oShoppingCart ~3 ltGdeg

Shopping Cart Item s Price

The C++ Programmi ng LanguageB j a r n e S t r o u s t r u p Q u a n t i 1 7 1

Price $ 3 1 4 7 Subtotal $ 3 1 4 7

d e l e t e

Total 31 47

Customer Information Microsoft Internet Explorer

File Edit View Favorites lo o ls Help bull _

bullgt 3i 4 n j j d a 31Back ~-j Stop- R efresh Home S earch Favorites History j Mail Print Edit

Link gtgt j Address ] j j h ttplocalhost SOSOcheekoot html

EMH1

~3

Customer Information

First name jFang

Middle initial |a

Last name Xiao

Email address fxiaomitecnet

Account password pooooc

0 1 Done

Credit card number 1234567891234567

Credit card type VisaC MasterCard

C Bluebir d C Fisher

Credit card holder jr ong Xiao

ard expire date (mmddyy) J010102

Select shipping method UPSO Express

O Normal C Abnormal

J |sect Local intranet

141

lt2] Order List - Microsoft Internet ExplorerFile |d i t View Fayotites lo o t Help

^ 3 ^ S i l S - j S tep R efresh Home Search Favorite History Mail Print h-

HFte-LLinks A ddress I g ] httplocalhost8030servletCustemeilrifoProcess 3 ^Go

Your order reads as followsE - M a i l A d d r e s s f x i a o

F a n g X i a o

ship to

T e l

11 e m s

pound] Pc

10821 W e s t e r n P l a z aOmahaME6 8 1 5 4

( 4 0 2 ) 4 9 6 - 7 5 7 0T i t l e T h e C++ P r o g r a m m i n g L a n g u a g e Q t y 1 P r i c e 31 47 S u b t o t a l 31 47

| a [ Local intianet rsquo

l i

T inyB ookSloiecom - Microsoft Internet Explorer

T 7 ~ J iii 4 a i t Vi 1+ a Si

5 E

P r i te i+ A d d ie r I ig l httplocalhot8080ervletReqCollectauthor

S e a r c h B o o k s

Horne

Ca t e g o r y

A u th o r

Title

ISBN

P ublishe r Date

jS 1 D one

TinyBookStore com

fc t i t e r l i t n o rYou can enter authors full name first name or last name

A u t h o r |sCOtt

O ExactName amp Last F irst Name (or Initial)

T itiv b o o k s to re c o m H o a e | C a te g o ry | A u th o r | T itle | ISBN | P u b lish e r D ate

C opyright and disclaim ercopy 1999-2001 F an g Xiao

T op o f P f

|sect g j Local intranet

142

linyBookStore^com- MiciosoFUnteinet ExplorerFite Edit View Favorites Tools Ftelp

IIl4 rsquojO IjjlI - 3 -Upraquo 8 a c k ltbullltbullbullltlaquo Stop R efresh Home S earch Favorites History Mail Print 1

| Links 1 Address j raquo 3 http7localhost8CI80servletAuthorProcess

l - i f l |x |

S e a r c h B o o k s

Home

C a t e g o r y

Ti t le

ISBN

P ublishe r D a te

D o n e-

TinyB o okStore com

1- Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

I G aleampory I A utho t | I jt te | ISBN | PubH shei^D atg

i t and disclaim erreg 1999-2001 F ang Xiao

Top of

l i Local intranet

j T iny8ookStorecom - M icrosoft Internet Explorer

Fite Edit View Favorites Tools Help

4- 5 ni M m ~ltpound C r =gt 2f|L i p | | | | | iAdiiill|^Thttp7localhost8080seivletD etailContent0201924889

U 3

S e a r c h B o o k s

H ome

C a t e g o r y

A u th o r

Title

ISBN

P u b lish e r P a te

TinyB o okStore com

Effective C++b y Scott Meyers

ISBN 0201924889 Addison-Wesley Pub Co 1995

R eviews

This is the review of Effective C++

R eader Comments

Price 3795 Availability U sually ships within 24 hours

Add to iosil

IIH LdcSiiihttahdt

143

l inyBookStorecom Shopping Cart - Microsoft Internet Explorer

4- -- _ t lS M JJ ltpound I 7 r mdash2--I or- Stop R efiesh Home S ea rch Favorites History Wait PrintBach

Links Y 1^ddtessj-^1 httDvVlocalliostiBOBOyservletMddToShoppinqCart 73 ^

0

Shopping Cart Item s

Effective C + +Scott Meyers Quantity 1

0 1 Done

delete

Price

Price $ 3 7 9 5 Su b to ta l $ 3 7 9 5

Total 3 7 9 5

IB~ht Locai intranet

bull 3 TinyBooKGIoFooom M icrosoft Internet Cxplorcr

Fite Edit View Favorites Tools Help

4- -4gt Lfl 4 r amp J J lt$ i icirsquo s J ~lAB ack Ti(^poundprV aTdV iS^Stop-T SfSjefre^ptr I i - M t s s j r y rvlih- i JPopSnr -JE

i i i l l l P I I I ^ I i l l ] httplocalhost8080servletR eqC ollectauthor

G3SJ

7 ^ Go

S e a r c h B o o k s

H om e

C a t e g o ry

A u th o r

Title

ISBN

Eytoiisiier Date

101 D one

T i n y B o o k S t o r e c o m

E n te r AuthorYou can enter authors full name first narne or last name

A u t h o r jCraig Larmen

E Exact N ante O Last F irst N ame (or Initial)

Search Now 1 Clear Form

I C ategory | A u th o r | j j t l s | ISBN |

C opyright and ctiiclali[er copy 1999-2001 F an g Xiao

T o p o fP ag e

^tDpcafihttangfe-

144

gj TinyBbokSlorecom - Microsoft Internet ExplorerFile Edit View F a v o n te s - Pools

4-1 4 gt_poundj Q Jl3S top R efresh Home S ea rch Favorites History Mail PrintCacl-

lsquo Unko A ddress j ig ] httplocalhostSOSCiservletAuthorProces 71

S e a r c h B o o k s

Home

C a t e o o r v

A u th o r

Tit le

ISBN

P ub l i she r D a t e

Titty Bo okStore com

1 Applying UM L and Pattern Usually ships in 24 hours Craig Larmen Prentice Hall 1997 Our Price 450

T im booksto re com Home | C ateg o ry | A u th o r | Title | I3BM | Publisher P a ts

C opyrigh t and disclaimer copy 1999-2001 F an g X iao IIg ] http7localhost 8080eopyright html Local intranet

7 j T inyBookStorecom - Microsoft Internet Explorer

^ 03 4 31 0 i -_r _j _T B ack ~j~ S top R efresh Hom e Search Favorites History Mail Print Edit

I Links Addiess AocalhcistiiiOciOserv-letCctailConfent0137488S07

u m m

S e a r c h B o o k s

HorneC a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r Date

Tiny Bo okStore com

Applying LOVIL and Patternby Craig Larmen

0 Price 450 Availability TJ sually ships within 24 hours

ISBN 013748880 Prentice Halil 997

R ev iew s

Tins is the review o f Applying UML and Pattern

R ea d er Com ments

Add to cart

01ll iPdSSIihirSdety

145

3 TinyBookStorecom Shopping Cart bull Microsoft internet ExplorerFile Edit View Favorites Tools Help

vJBeck

JStop Refresh

4Home

H Si - iS- -=dSearch Favorites History Mail Pnnt

Links rdquo Address jlti] httpVlocalhostBOSOservletAddToShoppingCart 3 ^ Gc

r o 1

Shopping Cirt J toms Price

A pplying UML and PatternCraig Larmen Quantity 1 Effective C++Scott Meyers Quantity 1

l i l le t e

delete

Price $ 4 5 0 Subtotal $45 0

Price $ 3 7 9 5 Subtotal $ 3 7 9 5

Total 82 95

d f g a j Local intranet

146

lt3 TinyBookStoiecom - Microsoft Internet ExplorerFile Edit View Favorites Io o ls Help

gt j i 4 a - a i [j JB ack Forward Stop Refresh Home S earch Favorites Histeiy Mail Print Edit

Links Address ] pound ] hiipVonahost803CeerveirsquoReqColectlsquoauthor

0 1 i

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r D a te

Tiny Bo okStore com

You can enter authors full name first name or last name

A u t h o r jJeff

O Exact N ame Last First N ame (or Initial)

Search Now i Clear Form

T inybookstorecotti H oinf | Category | A trthor | Title j ISBN | Publisher Date

Copyright and disclaimer copy 1999-2001 Fang Xiao

Top of Page

M Local intraZl

m TinyBook Stote com - Microsoft Internet Explorer

Fife Edit View Favorites Joo ls Help

ISregBack Stop Refresh Home S earch Favorites History Marl Print c

Lirrks Address samp] httplocalhost8080servletAuthorProcess ~z ^ Gc

S e a r c h B o o k s

H ome

CategoryA u th o r

Title

ISBN

P u b lishe r D a te

i M

TinyBookStore com

1 Progi aimning Windows bullwith M FC Usually slaps in 24 hours JeffProsise Microsoft P ress 1999 Our Price 4799

jnybo-okstorscom Homo | Category | A u th or | Title | ISBN | Publisher P a h

C opyright and disclaijRief copy 1999-liOO1 FangX iao

Loccii intranet

147

148

m I myUookSlorecom - Microsoft Internet ExplorerFile- pound d it View Favorite T ools Help

^ J ] 4 U J j j =jgt Stop R efresh Home S e a rc h Favorites History i Mail Print EditBack

Links AddressilaquojigThttplocalhost5 i380ser4eM D etailContent157231 pound350

rfgKxi

ldquo3 gt6deg

S e a r c h B o o k s

HorneC a teg o ry

A u th o r

Ti tle

ISBN

P ub l i she r D a t e

TinyBookStorecom

Programming Windows with M FCby JeffProsise

0

ISB N 1572316950 Micro s oft Pre s s 19 9 9

Price 4799 Availability Usually ships within 24 hours

R e N ew s

This is the review of Programming Windows with MFC

R eader Comments

A dd to cart

D one i jh j Local intranet

lt 3 TjryBook S tore com Shop p in g Cart - M icrosoft Internet Exolorer

File Edit View f a nute T ools Help

r 1B ack

J 3 Q 0J amp poundlr - Jlilip isS h lA ld rS s httpy |ocalhost8U 80AervletA ddToShoppingCait TSIIlli

Shopping Cart Item s

Program m ing W indow s w ith M F CJeffProsise Quantity 1A pplying UML a n d PatternCraig Larmen Quantity 1 E ffective C++Scott Meyers Quantity 1

d e le te

d elete

d elete

Price

Price $ 4 7 9 9 S u b to ta l $ 4 7 9 9

P rice $ 4 5 0 S u b to ta l $ 4 5 0

Price $ 3 7 9 5 S u b to ta l $ 3 7 9 5

Total 1 3 0 9 4

^ h W h e iM

S s i Local intranet

149

File Edit View Favorites lo o ls Help n4- -0 iS - M L U

Back Stop Refresh Home Search FavoritesJ

History I3 H H H B H H H BMail Pm Edit

Links rdquo Addrecs |s] hHplocalhogt5t8080servletReqCollectcategorii ^_____ bulllt bullbull llilltllll

Search Books

Home

Category

Author

Title

ISBNPublisherDate

TinyBookStore com

P r o g r a m m in g

AI g o r i t Lins CampC++ D e l p h i J a v a MFC P e r l s o f t w a r e D e s i g n UML V i s u a l B a s i c M o r e

Done

Web D e v e lo p m e n t

ASP Commercem C y b e r c u l t u r e HTML J a v a S c r i p t S e c u r i t y Web D e s ig n XML more

G r a p h i c s amp S o f t w a r e

Asobe CAD D es k t op P u b l i s h i n g G r a p h i c s M i c r o s o f t More

I J J ig Local intranet

150

finvBookStorecom - Microsoil Internet Explorer - j g j x

j Fite Edit Jfiew Favorites lo o ts Help

bull j 5 a i B ack lsquolti S top Refresh Home S e a tc h Favorites History Mail Print Edit

Links 1 Address |ltg] hitpVocalhostl-i030seryletCateciofyPreceigtVc03 ^ | g

S e a r c h B o o k s

Home CategoQ

A u th o r

Title

ISBN

Publishe r D a te

TinyBookStore com

1 Core Ja v a 2 Usually ships in 24 hoursCay S Horstmaun Prentice Hall 1999 Our Price 2579

2 Ja v a S erv let Programm itig Usually ships in 24 hoursJason Hunter i O Reilly 1993 Our Price 1977

3 Ju st J a v a 2 Usually ships in 24 hoursPerter van der Linden Prentice Hall 1999 Our Price 3149

Tinybookstorecom Home | C ategory | A u th o r | T itle | IbBN | Publisher D ateloRoIEage

n g Local intranet

ta

151

41 Tinytfookbtorecom - Microsoft Internet ExplorerFile gdit y iew Favorites JLools Help

1 ^ hgt a a a amp a j ri i - 3 bull a Back Forward Stop Refresh Home S earch Favorites History Mart Print Edit

lisLinteslsii Address ji^]h ttp localhost8D 8o7serv letD etailC ontent0130319336

M i

3 f^Gc

S e a r c h B o o k s

Homec a t e g o r y

Tiny Bo okStore com

Core Java 2by Cay S Horstmaun

El

ISBN 0130819336 Prentice H alil999

Reviews

This is the review of Core Java

R eader Comments

Price 2579 Availability U sually ships within 24 hours

I Add to car

S ] Done S i Local intranet

TinyBookStorecom Shopping Cart - Microsoft Internet Explorerfel11 File Eefit View Favorite l o o k H e lp

tljH|V| 4 a 3 j 09 c T J

Stop Refresh Home S e a rc h Favorites History j Mail Print

jiiLihkIi87js ^ B ie s S ij^ ] http Z localhost8080servletiddT oShoppirigC art

B I B

3= i

Shopping Cart Item s

Core Java 2Cay S Horstmaun Quantity 1

Icopy

t i l

delete

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Total 2 5 7 9

sal Local intranet

152

a TinvBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites J o o lr Fjelp

NBack

amp Id b iStop Refresh Home

ISearch Favorifes History - Mail Print Edit

Links gty I Address [ jg l httplocalhost8080servletD etailContent156592391 x d

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

T i t le

IS B N

Publisher Date

ampJ Lrl e

Tiny Bo okStore com

J a v a S erv le t Piograitmmigby Jason Hunter

a Price 1977 Availability XT sually ships within 24 hours

ISBN 15659239 lx O Refflvl998

R e N ew s

In this brand-new third edition of Java Servlet Programming author Bjame Stroustrup the creator of Java presents the full specification for the Java language and standard library a spec that will soon become the joint ISOANSI Java standard

j ~2J Local intranetm

dH T iny8ook5torecom Shopping Cart - Microsoft Internet Explorer

File pound d t y iew Favorites Io o ls HelpB H

a $ a i a a -Stop Refresh Home S ea rch Favorites Hi lory Mjl

3- lsquonr I

| j | i | H | g i | i | i d ^ | | | | l Q httplocalhost80S0servletAddToShoppirigCart J P

m

Shopping Cart Item s

Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d e le te

d e le te

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Price $ 1 9 7 7 S y b to ta l $ 1 9 7 7

Total 4 5 5 6

I O I

aiil

153

Lustomer Information - Microsoft Internet Explorerpoundite pounddit View Favorites Xoo|s Help

v- _) _ l 4 J I VB ack - Stop R efresh Home Search Favorites History Mail

Links gty] A ddress ] j i l h ttD localhost8080checkouthtm l

F -iVj ~f

l l i l i i

C u sto m er In fo rm a tio n

First name jFang

Middle initial lA

Last name fXiao

Email address jfxiao m itecnet

Account password jxxxxx

Credit card number ]1234567B91234567

Credit card type C VisaC M asterCard

C Bluebird O Fisher

Credit card holder jFang Xiao

Credit card expire date (mmddyy) jo 10102

Select shipping method c u p sC Express

NormalAbnormal

0 ] D one Local intranet

poundpound Order List - Microsoft Internet Explorer

s

Back

Li il raquo

Yiew Favorites l o o h Help

bullV Y lJ j X I T- lty S to p Refresh H o m e

amp 1 3 J - jrS earch Favorite History lt Mail Print

fcesssaampl httplocalhost8080servletCustom erlnfoProcess

Y o u r ord er reads as fo llow sE-Mail Address 6daomitecnet

Fang Xiao

ship to

Tel

Items

12345 Western PlazaOmahaNE68154(402) 123-4567

Title C ore Java 2 Qty 1 Price2579 Subtotal 2579

Tide Java Servlet ProjammingQty 1 Pnce 1977Subtotal 1977 Total4556

ffl|b ] Done kl Local intranet

154

mammmm 1

File Edit View Favorites lo o ts tieip

E=cl i u F t l H -n e -i i rdquo F j-oiilsquoiBillHistory lsquo gt1 ll Print Edit

iiiiiiiiiiiiiiiiiirsquo Links Address j-copy] http localhust 8080servletReqCollectisbn J

TinyBookStore com

Search Books

Home ISBN

Author

Title

IS B N

S e a r c h Hew C le a r Form

PubnsheuDate

Top o f PageITnjrbooksj^ore^ com Horne I C a te g o rv | ^ i t h o r | T i t Ie I ISBN | Publisher Date

- g ] http locdlho-st SOSOwelcome shtrnl

TinvBookStorecom - Microsoft Internet Exploier

poundaj Local intranetId

| File Edit View Favorites Tools Help

i -e -e u u r5_ _ _ a u ^ 4 - a a j Back Forward S top Refresh Home S earch Favorites History Hail Print Edit

Links A d d re ss ^ hitp rsquoIdcanc-stEtnSOservlltlsquoF-aqZoll-~ntispn z raquo h

TinyB o okStore com

S e a r c h B o o k s

Horne

A utho r

T itle

ISBN

P u b lish e r P a t e

fcntar ISBN

I SB H 1565922840

|sectplli||pbw||l| IliM M pifiillj

T rgU onL cirrti -nr Kini- | Cgtgpound-gg | Agithor | Title | ISBN f uhhe-rt Pete

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top o f Pag e

aipoundbull] O o n e Local intranet

155

File Edit View Favorites Tools Help

HUTinyBookStorecom - MicrosoH InternetExplorer

B ad-J J A J d -2r =3

Stop R efresh Home S e a rc h Favorites History Mail Print

Links ygt A ddress j ^ ] httpVlocalhost8080servletrsquoISBM Process

S e a r c h B o o k s

Horne

C a t e g o r y

A u th o r

T itle

IS B N

Pub l i she r D a t e

TinyB o okStore com

1 Learning Perl Usually ships m 24 hours Randal L Schwartz O Reilly 1997 Our Price 1997

T in vh ooksto re c o m H orne | C at ego tv | A u th o r | Title | ISBM | Publisher D ate

C opy rig h t a n d d isclaim ercopy 1999-2001 F a n g X iao

0 ] Done

yen

ighj Local i

TinyB ookStoiecom - Microsoft Internet Explorer

Erie Edrt View Favorites- lo o ls Help

-s pound] 4 pound1 jLl icArdquo =pound 2 S top Refresh Home S earch Favorites History Marl Print Edit

iilHI

NpBack

httpyiocalhostSOBOservleMDetailContentAI 565922840 ~T] Cm

Tiny Bo okStore com

S e a r c h B o o k s

H o m e i

C a teg o ry

A u th o r

T itle

ISBN

Publishe r D a te

Learning Perlby Randal L Schwartz

I ^

ISBN 1565922840 O Reillvl997

Price 1997 Availability U sually ships within 24 hours

Reviews

This is the review of learning Perl

Reader Comments M0 ] Done lsquofR | Local intranet

156

IHHHHHI _ I f f i x |

File E d t yiew Favorites J o e ls H elp 11v- -__ l

Back ~ rc Stop R efresh Home S earch Favorites HistoryJ rMail

HH1111Pgtnt

Links A ddress | ] http7docalhost8030servleM AddToShoppingCart 3 tgt G o

O S III

Shopping Cart Item s

Learning PeriRandal L Schwartz Quantity 1

delete

Price

Price $ 1 9 9 7 Subtota l $ 1 9 9 7

Total 1 9 9 7

s

Done Local intranet

Eg W illi 1 lttMM41 i H H p n B n 1 0 1 x i

Fite Edit View Favorites Toots Help E H

1$3 L plusmn J8ack Forward Stop Refresh Home Search Favoutes

4History i

- i V -=JMail Print

-Edit

71 Address http7localhost8080lsquoservletFleqCollecVisbn I l f i l l l

TinyBookStore com

Search Books

Home

C ateao rv

Author

Title

ISBN

Publisher D a te

Enter ISSN

i s bit [l 565921496

Search Now I Clear Form

Tinybookstore o n Home | Category | A uthor | Titb | ISBN | Publisher Dte

Copyright arid disclaimer copy 1999-2001 Fang Xiao zl amp j Done Js J Local intranet I

157

H H H r f e i x i File Edit View Favorites Lools Help

- J j j j ] JBack Stop Fiefresh Home Search

J JFavorites-

-J i C rHistory Mail Print

111111811i n

r Links wj i Address |reg] http docalhost 8080servletIS8N Process

S ea rch B ooks

Home

Category-

rdquo A u th o r

T i t l e

IS B fi

P u b l i s h e r D a ta

Tiny Bo okStore com

1 Programtning Perl Usually ships in 24 hours Larry Wall O Reilly 1997 Our Price 2397

T o o k s t o r e c o m H P in e | C a t e g o r y | A u t h o r | Till | IS B N | P -ubtu-hai D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g X ia

T o p o f P a g e

zlamp2 Done Local intranet

158

lt3 l mytfookSlorecom - Microsoft Internet ExplorerF3e Edit View FavoMes lo o ts Help

Back3 U Si S rsquo IStop Refresh Home lt Search Favorites History Mail Print Edit

httplocalhost8080servletDetailContent15S5321496 j3

Search Books

Horns

Category

Author

Title

ISBN

Publisher Date

Done

TinyB o okStore com

Programming Perlby Larry Wall

0 Price 2397 Av ail ability U sually ships within 24 hours

ISBN 1565921496 O Reillyl997

Reviews

This is the review of Programming Perl

Reader Comments

Add to cart

l or=lM

159

Tm vBookSlorecom Shopping Cart - M icrosoft Internet Explorer

i Fite Edit View Favorites lo o k Help

^ Beck R efresh Home

ampS earch Favorites History j Mail Print

E Links I Address ] pound http localhost 8080servletA ddT oShoppingCart rsquo ] O rai

i O

Shopping Cart Jlems

Learning Peri Randal L Schwartz Quantity 1 Program m ing PeriLarry W all Quantity 1

delete

d e le te

Price

Price $ 1 9 9 7 S u b to ta l $ 1 9 9 7

Price $ 2 3 9 7 S u b to ta l $ 2 3 9 7

Total 4 3 9 4

3SJ Done j | s [ Local intranet

160

m m mmmHi mmmHHHHHi1 File Edit View Favorites Tools Help

^ - J J -ih Ji - j| B a d Forward Stop Refresh Home S earch FavoritesHIH ctuv Mjl Print

IHIlllliEd

B l

MbfeifcssfjP Address httplocalhost8080servletFleqCollectpLiblisher_date_ ___ ________ ___________ _ bull bull bull bull_________________ Zi T gt 6 o

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

Title

ISBN

Publishe r P a t e

S ] Done

TinyBo okStore com

T rsquov -

Publisher

sind IPpiIs1iclaquoifciori OsifiC

jAd cl i so n-VVe oI e y Fuo C o ~

P u b l i c a t i o n D a t e 1U97

Search Now Clear Form

T inybookstore com Home | C ategory j A u tho r j I itle | ISBN | Publisher Ds

C opyright and disclaimer copy 1999-2001 F an g Xiao

T op o f Page

g a l Local intranet

161

lt|j TinyBookStoiecom - Microsoft Internet Explorerlsquo Erie Edit View Favorites lo o ls Help

v-1 Q rij - 3 rsquo- a u -=pound Ci Back s lsquoi i 1 Stop Refresh Home S earch Favorites History Mail Print i

jL inks i A ddress 0 1 http7localhost8Q80servletPublisherDateProcess

EMM

3

S e a r c h B o o k s

Home

C a t e g o r y

Author Title

ISBN

Publisher D a te

TinyBookStore com

1- Algorithm s in C Usually ships in 24 hoursRobert Sedgewick Addison-Wesley Pub Co 1997 Our Price 4495

2 The C++ P rogr amming L anguage Usually ships in 24 hourBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

3 Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

4- U M L D istilled Usually ships in 24 horn sMartin Fowler Addison-Wesley Pub Co 1997 Our Price 2995

Done | s j L ocalm

TinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorites l o o k Help

Backamp 3 $ -Q 3 3 AJStop Refresh Home S earch Favorites History Mail Print Edit

Lipikkigt7i Ajddr$esjhttpv7localhost8080-servletDetailCoriterit0201314525

m

3 rgtGc

S earch B ooks

Horne

A uthor

Title

ISBN

Publisher D a te

Tiny BookStore com

Algorithms in Cby Robert Sedgewick

S

ISBN 0201314525 Addison-Wesley Pub Co 1995

Reviews

This is the review of Algorithms in C

Reader Comments

Price 4495 Availability U sually ships within 24 hours

Add to cart

0I reg S a i t^ s a l intranet

162

File Edit View Favorites lo o ls Help

2 ^ iVi ^ ^ t j j B ack gt Stop Refresh Home S ea rch Favorites History ||

- i -Mail Print

WB0BUBSSSI B ifl

Links ygt Addrese |isect ] httpvVlocalhostSOSChservletAddToShoppingCart

Shopping Cart Item s

A lgontfim s in CRobert Sedgewick Quantity 1

0 1 D one

delete-

Price

Price $ 4 4 9 5 Subtota l $ 4 4 9 5

Total 4 4 9 5

Local intranet

163

^ l inyBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

ls31

3 bullrsquo -I- _J _jj - j i_ 3 - j rdquo -= $ ABack Forward Stop Refresh Home Search Favorites History Mail Print Edit

Links rdquo Address 6 J http Vlocalhost SOSOAervletR eqCollectpublisher_date j ^G

Search B o o k s

Home

categoryAutho r

Title

IS B N

Publi sher D a te

TinyBookStore com

liter Publisher and Publication Date

P u b l i s h e r Wrox Press Inc

P u b l i c a t i o n D a t e ]1

Search Now j Clear Form

T invbookstor ecotnHomg | Category | A uthor | Title | ISBN | Pu b lish e rP a t

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top of Page

zD one Local infra

m TinyB ookStoiecom - Microsoft Internet Explorer

R e Edit View Favorites Tools Help

- -i 13 4 St 2J amp t r - JHB-1

fff ij if P S | Address |sjpound~| httpVlocalhost8030servletPublisherDateProcess

S e a r c h B o o k s

Home

C a t e g o r y

A utho r

T itle

ISBN

Publisher D a te

0 ] Done

TinyBookStore com

1 Beginning Visual Basic 6 Database Programming Usually ships in 24 hour John Connell W rox Press Inc 1998 Our Price 3199

2 Befmiung Visual Basic 6 Usually ships in 24 hours Peter Wright Wrox Press Inc 1998 Our Price 3199

T inybookstore com H orae | C ategory | A u thor | Title | ISBN | Publisher Date

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top o f Fas

Local intranet

64

| File Edit Yiew Favorites T ook Help

i A - + - - a S 3 rsquo reg - pound J -3 Back ldquo d Stop Refresh Home Search Favorites History

- vMail Print

i

Edit

IllplBlllll________ g - M

isisfcinbsijp Addre s | g ) httplocalhost8080servletDetailCoritent1861001061 3 Gdeg

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

T itle

ISBN

Publishe r D a te

TinyBookStore com

Beginning Visual Basic 6 Database Programmingby John Connell

a Price 3199 Availability U sually ships within 24 hours

ISBN 1861001061 Wrox Press Inc 1998

Reviews

This is the review of beginning Visual Basic 6 Database Programming

Reader Comments

A d d to c a n

S] pone Local intranet

m u i

lillllEHl ^ bdquo A 3 2tl 4 t M liJ i

Back Forward Stop Refresh Home Search Favorites3

History 4 _ r

M j 1J

Print EditiSillilillllS

httplocalhost8080servletReqCollecttitle

S e a r c h B o o k s

Home

C a t e g o r y

Author

Title

ISBN

Publisher Date

TinyB o okStore com

Enter TicleYou can enter the exact title or part of title

T i t l e C++

O Exact Title Title Words

Search Now Clear Form

Example

bull Entering Java Servlet Programming in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title are related to Java _li

165

lt5 TinyBookStorecom - Microsoft Internet ExplorerFite Edit View Favorites lo o ts Help

Back Stop Refresh Home S earch Favorites History Mail Print

Links gty Addiess http-localhost8080servlet7TitleProcess

i|p1

I

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

Publi sher IS a t e

TinyBookStore com

1 The C++ Programming L anguage Usually ships in 24 hoursBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

2 Effective C+-F Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

3 Programttung Visual C-H- Usually ships in 24 hours David J Kmglinski Microsoft Press 1998 Our Price 3999

T m y h o o k s to e co m H o m e | C a te g o ry | A u th o r | T itle | ISBH | P u b lish er D ate

http iocalhost SOSOservletFleqCollectcategary

T op of P age

~hj Local intranet

bull a TlnjpBflOkStOfecom - Microsoft Internet Explorer

File Edit View Favorite Pools Help

0 3 4 S l i 3 O - J J i t of Stop Refresh Home S earch Favorites History - Mart Print Edit

HBack

i i i i lS i lB i I i f f id i l f f lH Q http Vlocalhost 8080AervletD etailContent1572318570

EEEI

J

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b lis h e r D a f t

TinyBookStore com

Programming Visual C++by David J KrngHnski

[Hj

ISBN 1572318570Microsoft Press 1998

Price 3999 Availability Usually ships within 24 hours

R e v ie w s

This is the review o f Programming Visual1

Reader Comments

Add to cart

if Local intranet

166

mm| File pounddtt View Favorites Jo o ls Help

c J J j j mdash JB ack - J Stop Refresh Home S earch Favorites History

- _ i -M u

J tPrint

t e t a f e w P A ddress | ^ ] httplocalhost8080servletAddToShoppingCart zl -lt1gtSo

Shopping Cart Item s

Programmeng Visual C + +David J Kmgbnski Quantity 1

delete-

Price

Price $ 3 0 9 0 Sub to ta l $ 3 9 9 9

Total 3 0 9 9

D one ^aj Local intranet

TinyBookStorecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

vHBack-

-J a 4 -a si fi- 3 aStop R efresh Home S earch Favorites History j Mail Print- Edit

Links gty A d d re s sL ^ ] hrtpWlocalhostSOSOservleVFIeqCollectAitle

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

ISBN

Pub l i she r Date

TinyBookStore com

Enter TitleYou can enter the exact title or part of title

Title Distil I nrfExact T itle V T itle W o rd s

Search Now | Cle ar Fo rm

Examples

rpound] Done

bull Entering Java Servlet Programming11 in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title arei date 11 j Java JZJ

167

a TlnyBA5kSioiecom - Microsoft Internet Explorergt 0e Edit ifiew Favorites Jock Jd lp

a a amp -a tii j k i Back s - Stop Refresh Home Search Favorites History Mail Print

liilP raquo httpiVlocalhostSOSOservletTitleProcess

E M 3

ldquo3 rgt-

S ea rch B ook s

Horne

C a t e d o r v

A utho r

TiUgt~ ISSN

Publi sher D a te

Tiny BookStore com

1- TJML D istilled Usually ships in 24 nowsMartin Fowler Addis on-Wesley Pub Co 1997 Our Price 2995

| C s rg g o ty | A u th o r | T itle | IStBH I P u b lis h e r D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g Xiao

-jg Local intranetS3

m n ^ i l a i i x l

File Edd View Favorites Joels- Help M Mi r J lt 3 L h f 4 - 0 lt 3

Back i t Stop Refresh Home S earch Favorites History Mail9

PrintM

Edit

Links raquo A ddress j | i ] http do ca lh o d 1030N m letDetailContenr0201325632 Mimas

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

Title

IS B N

Publisher Date

Tiny BookStore com

TJML Distilledby Martin Fowler

0

ISBN 0201325632 Addison-Weslev Pub Co 1997

Reviews

Tins is the review of The UML Distilled

Reader Comments

Price 2995 Avail abilityTJs u ally ships within 24 hours

Add to c a r t

0 3S i] Done |g^iLnealiihfrregei

TinyBookStorecom Shopping Cart Microsoft Internet ExplorerFile Edit View Favorites Jo o ls HetP

IBiiiBlll l l lHBlSglSlllllilMH MlllBliriilllgllSlIlBack - f - i - S top Refresh Home

a J i l ^ j 3 Search Favorites History 1 Mail Print liiii

3 Links ( A ddress j ig j hrtplocalhost803DservletAddToShoppingCart

Shopping Cart Herns Price

UML D istilledMartin Fowler Quantity 1Program m ing Visual C + +David J Kraglinski Quantity 1

Price $ 2 9 9 5 Subtota l $ 2 9 9 5

delete

Price $ 3 9 9 9 Subtota l $ 3 9 9 9d elete

Total 6 9 9 4

  • Electronic Commerce on Business Application
    • Recommended Citation
      • tmp1499779448pdf2JOpQ

An on-line store system is different from a traditional web publishing It needs a

customerrsquos interactive communication and frequent data update The traditional

HTML page does not satisfy the customerrsquos needs because all it does is simply

publish static contents More complex technologies are required in order to produce

dynamic contents

There are a few technologies that can be used for implementing the on-line stores

Common Gateway Interface (CGI) Microsoft Active Server Page (ASP) and Server-

side Java application are the most popular technologies Introducing the Server-Side

Java application is one of the latest and most exciting trends in Java programming

The Server-side Java application has many advantages over the other technologies

Table of Contents

Chapter 1 Introduction 1

Chapter 2 Electronic Commerce 2

21 What Is Electronic Commerce2

22 The Importance of Electronic Commerce3

23 Types of Electronic Commerce3

24 Why Most Internet Based Electronic Commerce Is In

The Business-To-Consumer W orld 6

25 Current State of Business-To-Consumer E-Commerce7

26 The Structure of The On-Line Store8

Chapter 3 Technologies For On-Line Store System11

31 Traditional Web Application - Common Gateway Interface(CGI) 11

32 Active Server Page 12

33 Server-Side Java Application 14

Chapter 4 Design of On-Line Bookstore Using Java Servlets

A Practical Verification18

41 The Design of Home Page of Tiny Book Store18

42 Design of Search by Different Requests27

43 Servlets Chaining To Process Requests In Different Levels28

44 Database Connectivity and Search from Database29

45 Session Tracking 35

46 Check O ut42

47 Customer Information Processing 43

Chapter 5 Future Work50

51 Connection Pooling50

52 More Object-Oriented - Better Encapsulation51

Chapter 6 Conclusion 53

Appendix A Bibliography54

Appendix B The Source Code of An On-Line Store System -

Tiny Book Store57

Appendix C Screen Display of the Test 135

List of Figure

Figure 261 The Structure of An Online Store 10

Figure 321 Handle Requests Flow Chart 13

Figure 331 HttpService of The Java Web Server Using Servlets 15

Figure 411 The Home Page of Tiny Book Store 22

Figure 412 One of The Searching by Author Pages26

Figure 441 One of The Outputs of Servlet AuthorProces 34

Figure 451 A Page Show All Information About A Book 39

Figure 452 A Page Show Items In The Shopping Cart After A User

Added Books To The Shopping Cart 40

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A

Book From The Shopping Cart42

Figure 461 A Check Out Page 43

Figure 471 An Invoice Page48

1

Chapter 1

Introduction

As we step in the year 2000 we can no longer look to the past as the guide for the

future A combination of business social and technical possibilities drives the rapid

progress in electronic commerce

Electronic commerce can offer a company both short-term and long-term benefits

Not only can it open new markets enabling a business firm to reach new customers

but it can also make it easier and faster for the firm to do business with their existing

customer base Moving business practices such as ordering invoicing and customer

support to network-based systems can also reduce the paperwork involved in

business-to-business transactions When more of the information is digitized it

allows that business firm to focus on meeting their customerrsquos needs Tracking

customer feedbacks and presenting customer solutions for their clientele are just

some of the opportunities that can stem from electronic commerce

2

Chapter 2

Electronic- Commerce

21 What Is Electronic Commerce

For some time now large business enterprises have used electronic commerce to conduct

their business-to-business transactions In early 1960 private networks were dedicated

for the use of electronic data interchange (EDI) and electronic funds transfer (EFT) in the

banking industry Recently however with the increased awareness and popularity of the

Internet electronic commerce has come to encompass individual consumers as well as

businesses of all size

To many electronic commerce is defined as the buying and selling of products and

service over the Internet But there are many other aspects Depending on whom you ask

electronic commerce has different definitions

From a communications perspective electronic commerce is the delivery of information

productsservices or payments via telephone lines computer networks or any other

means From a business process perspective electronic commerce is the application of

technology toward the automation of business transactions and workflow From a service

perspective electronic commerce is a tool that addresses the desire of firms consumers

and management to cut service costs while improving the quality of goods and increasing

3

the speed of service delivery From an online perspective electronic commerce provides

the capability of buying and selling products and information on the Internet and other

online services [16]

These definitions are valid with their perspectives It is a matter of which lens is used to

view the electronic commerce landscape Broadly speaking electronic commerce

emphasizes the generation and exploitation of new business opportunities by ldquogenerating

business valuerdquo or ldquodoing more with lessrdquo

22 The Importance of Electronic Commerce

As we approach the year 2000 we can no longer look to the past as guide to the future In

the face of strong market forces created by electronic commerce and mounting

competition corporations can no longer plod along historical tracks or seek the

preservation of the status quo Companies are discovering that old solutions do not work

with new problems The business parameters have changed and so have the risks and

payoffs

23 Types of Electronic Commerce

From a broad view there are three distinct general classes of electronic commerce

applications Inter-organizational (business-to-business) intra-organizational (within

business) and customer-to-business application [16]

4

231 Inter-Organizational Electronic Commerce

Inter-organizational electronic commerce makes business more convenient on the

following aspects

Firstly e-commerce can improve supplier management since electronic applications can

reduce the processing costs and cycle times for each purchase order and it can reduce the

number of people who work on purchase orders

Secondly e-commerce can improve inventory management since electronic applications

make the business partners can fast exchange information and easy track their documents

to ensure that they were received This not only can eliminate out-of-stock occurrences

but also can reduce inventory and improve inventory turn

Thirdly e-commerce can improve distribution management since electronic applications

can make the business partners receive the shipping documents as soon as possible and

enable better resource management by ensuring that the documents contain more accurate

data

Fourthly e-commerce can improve channel management since electronic application can

let the business partner post the information to electronic bulletin boards This can

eliminate repeated telephone calls and countless labor hours

Fifthly e-commerce can improve payment management since the business partner are

linked by network so the payments can be sent and received electronically Electronic

payment is more accurate and fast than traditional payment

232 Intra-Organizational Electronic Commerce

5

Intra-organizational electronic commerce facilities the following business applications

Workgroup communications Electronic applications enable manager to

communicate with employees using electronic mail videoconferencing and

bulletin boards

Electronic publishing Electronic applications enable companies to publish

information by using tools such as the World Wide Web On-line publishing can

show information immediately and clearly and reduce costs for printing and

distributing documentation

Sales promotion Electronic application improve the flow of information between

the production and sales forces and between the firms and customers This can

make companies have greater access to market and competitor information

Today Intranets are primarily set up to publish and access vital corporate information

Some of the most common types of information are Human Resources information

employee communications product development and project management data internal

catalogs sales support data equipment and shipment tracking and accessing corporate

database

233 Consumer-To-Business Electronic Commerce

In consumer-to-business transactions customers learn about products through electronic

publishing buy products with electronic cash and other secure payment systems and

even have information goods delivered over the network

6

From the consumerrsquos perspective there are three transactions

1 Electronic applications enable consumers to communicate with each other through

electronic mail videoconferencing and news groups

2 Electronic applications enable consumers to manage investments and personal finances

using online banking tools

3 Electronic application enable consumers to find online information about existing and

new products services

Consumers consistently demand greater convenience and lower prices Electronic

commerce provides consumers with convenient shopping methods from online catalog

ordering to phone banking both of which eliminate the costs of expensive retail

branches Electronic commerce facilitates factory orders by eliminating many

intermediary steps thereby reducing manufacturersrsquo inventory and distribution costs and

indirectly providing consumers with lower prices

24 Why Most Internet Based Electronic Commerce Is In The Business-To-

Consumer World

For the Business-to-Business e-commerce the lack of well-accepted standards is

hindering the success in promoting Business-to-Business electronic commerce

solutions[5] VAN (Value-Added Networks) EDI (Electronic Data Interchange) based

solutions are only accessible to large organizations due to the cost factor Corporate

buyers and suppliers large and small are looking for Internet based solutions to

streamline the procurement procedures and to reduce the cost of establishing trading

relationship and the trading transactions Such demands put forward some fundamental

challenge on issue like trust infrastructure on the Internet standards and inter-operability

etc

25 Current State of Business-To-Consumer E-Commerce

Business activity on the Internet is currently limited to publicizing the business

opportunity and to catalog based sales but it will rapidly expand to include the

negotiations conducted to settle the price of the goods or commodities being traded

These negotiations are currently conducted by human intermediaries through various

forms of auctions bidding systems for awarding contracts and brokerages The role of

the intermediaries can now be performed by Internet trading applications at a fraction of

the cost[4] Trading on the Internet allows a business to reach a large number of potential

customers and suppliers in a shorter time and a lower cost than possible by other modes

of communication and to settle business transaction with lower cost overhead in a shorter

time

Auctioned or brokered sales are the norm in business world for negotiating trades of large

monetary value But consumer sales and small-scale purchases have used the fixed price

mode perhaps because of the high overhead cost of using the auction or brokerage

method The new economics of the Internet will make auctions popular in consumer and

small business transactions also

Auctions are just one form of business negotiations Other examples are competitive bids

for procurement brokeragesexchangescartels and two party negotiations

Nowadays the free-market economy of software agents is in the embryonic stage But in

the near future the software agents will populate the Internet and provide trade and use

a rich variety of information goods and services in an open free-market economy In a

free-market economy of software agents information is produced traded and consumed

by vast numbers of autonomous self-motivated agents An essential task in such an

economy is the retailing or brokering of information gathering it from the right

producers and distributing it to the right consumers[10] The overall research goal is to

characterize and understand the dynamic behavior of information economies very large

open economies of automated information agents that are likely to come into existence in

the Internet

26 The Structure of The On-Line Store

9

Nowadays there are thousands of on-line stores running on the Internet A few well-

known ones are amazoncom and bookpoolcom Most of such applications involve

common functions which are as following

Searching for product information

Ordering products

Paying for goods and services

Providing online customer service

So they have a similar structure as shown in Figure 261 The system contains the

following components

1 A web server running continuously accepts userrsquos connection gets user requests and

forward requests to business procedure retrieves data (answers to user requests) from

business procedure and send it back to user

2 Business procedure usually consists of a user identification procedure like credit card

check user request analysis procedure analyzing requests calculating discomposing (if

necessary) and dispatching request to different data source component Also in some

case business procedure is responsible to compose data obtained from different data

sources into user-readable format

3 Database is the place to hold relevant data These data not only serve as a data source

describing commercial goods and prices but can be used for data mining to improve

store service quality as well Database is updated and maintained by both customersrsquo

input and system applications A customerrsquos input usually includes order information

10

Figure 261 The Structure of An Online Store

(through browser)

Databas

(through browser)client

client

serverWeb

Systemapplication

Busines

procedu

4 System applications can include a search engine running all the time and searching

relevant information from the internet data mining application deals with mining and

analyzing customer and sale data for management use database maintaining application

handles update data when product information changes Varying from system size to

system size not every system has cleardistinct boundaries between these components

The system can be 3-tired or n-tired but these systems all operate in similar ways

11

Chapter 3

Technologies For On-Line Store System

An on-line store system is different from traditional web publishing It needs customerrsquos

interactive communications and frequent data update The traditional HTML page is

insufficient because all it does is provide static content publishing Other technologies

are required in order to implement the on-line store

Currently there are three mainstream technologies which are widely used Common

Gateway Interface (CGI) Microsoft Active Server Page (ASP) and Server-side Java

application We briefly explore these technologies here

31 Traditional Web Application - Common Gateway Interface (CGI)

The common Gateway Interface normally referred to as CGI is one of the first practical

techniques for creating dynamic content With CGI a web server passes certain requests

to an external program The output of this program is then sent to the client in place of a

static file The advent of CGI makes it possible to implement all sorts of new

functionality in web pages and CGI quickly become a defacto standard implemented on

dozens of web servers Even though a CGI program can be written in almost any

language the Perl programming language is the predominant choice However CGI have

some distinct disadvantages

Firstly CGI program is transient A request is made each time to a CGI program It must

be loaded and executed by the Web server When the CGI program is complete it is

removed from memory and the results are returned to the client All program

initialization (such as connecting to a database) must be repeated each time a CGI

program is used

Secondly when a server receives a request that accesses a CGI program it must create a

new process to run the CGI program and then pass to it via environment variables and

standard input Every bit of information might be necessary to generate a response

Creating a process for every such request requires time and significant server resources

which limits the number of requests a server can handle concurrently

Thirdly a CGI program cannot interact with the web server or take the advantage of the

serverrsquos abilities once it begins execution because it is running in a separate process

32 Active Server Page

As shown in figure 321 the following list walks you step-by-step through what

happens if the client requests the page xyzasp

The client requests the page xyzasp from the server The Web server checks the file

extension to see whether a special program (such as the Active server Pages engine)

13

must be invoked to process the request If therersquos a asp extension the Web server

determines that it should invoke ASP to process this page

Figure 321 Handle Requests Flow Chart

Request

Response

WEB SERVERComponents

Databas

ns

ASP File

CLIENT

Active X Data

VBScript

If this page has never been requested before or has been changed since the last

request it must be parsed and the syntax checked and then be compiled by the Web

server Otherwise the page might be read from a cache of recently processed pages

which aids in performance During the parsing process the HTML and scripting code

14

are separated IIS (Internet Information Server) determines which scripting engine is

responsible for which part of the script and delegates the work of syntax checking and

compiling to the proper scripting engine (such as VB Script)

Now the code is executed by the scripting engine using resources from IIS which is

hosting the scripting engines All objects that the language engine cannot handle are

requested by the IIS which is also responsible for handling inputs and outputs for the

external ActiveX objects that are created and used inside the script If it is not able to

supply the object an error is generated

Script output and static HTML code in the ASP file are merged

The final HTML is sent back to the user in an HTTP response

The important point about ASP is that the Script runs entirely in a server to protect the

intellectual property by shielding it from browser which are different from the account

for when writing client-side code The entire server-side code is processed and only plain

HTML - or whatever kind of content you chose to generate - is sent to the client

33 Server-Side Java Application

The rise of server-side Java applications is one of the latest and most exciting trends in

Java programming A Servlet can be thought of as a server-side applet Servlets are

loaded and executed by a Web server in the same manner that applets are loaded and

executed by a Web browser

15

As shown in Figure 331 a servlet accepts requests from a client (via the Web server)

performs some task and returns the results

The client (mostly likely a Web browser) makes a request via HTTP The Web server

receives the request and forwards it to the servlet If the servlet has not yet been loaded

the Web server will load it into the Java virtual machine and execute it The servlet will

receive the HTTP request perform some type of process and return a response back to

the Web server The Web server will forward the response to the client

Figure 331 HttpService of The Java Web Server Using Servlets

RequestResponseRequestResponse

RequestResponse

Java Web Server

Administrative SERVLET

SERVLETHTTP

SERVLETWeb Proxy

Servlets have distinct advantages over CGI program

Servlets are persistent Servlets are loaded only once by the Web server and can

maintain services (such as a database connection) between requests

Servlets are fast since servlets only need to be loaded once

16

Servlets are platform independent Servlets are written in Java and conform to a well-

defined and widely accepted API They are highly portable across operating systems

and across server implementations A servlet can be developed on a Windows NT

machine running the Java Web Server and later can be deployed effortlessly on a

high-end Unix server running Apache

Servlet portability is not the stumbling block it so often is with applets There are two

reasons Firstly servlet portability is not mandatory Unlike applets which have to be

tested on all possible client platforms servlets have to work only in the server

machines that you are using for development and deployment Unless you are in the

business of selling your servlets you donrsquot have to worry about complete portability

Secondly servlets avoid the most error-prone and inconsistently implemented portion

of the Java language the Abstract Windowing toolkit (AWT) that forms the basis of

Java graphical user interfaces

Servlets are extendable Servlets that are written in Java brings all of the other

benefits of Java to servlet Java is a robust object-oriented programming language

which can be extended easily to suit our needs

Servlets are secure The only way to invoke a servlet from the outside world is

through a Web server This brings a high level of security especially if the Web

server is protected behind a firewall

Servlets can be used with a variety of clients

Servlets are tightly integrated with the server This integration allows a servlet to

cooperate with the server For example a servlet can use the server to translate file

paths to perform logging and to check authorization

Servlets are quite flexible An HTTP servlet can be used to generate a complete web

page it can be added to a static page using a ltSERVLETgt tag in whatrsquos know as a

server-side include and it can be used in cooperation with any number of other

servlets to filter content in something called a servlet chain

18

Chapter 4

Design of On-line Bookstore Using Java Servlets A Practical

Verification

Server-side Java application is one of the latest technologies used to implement an onshy

line store system Servlet is a set of classes that come up from Java language It is

designed to be used for server-side Java applications There are many techniques people

can use when they utilize servlet such as Server-Side Include (SSI) Servlet Chaining

Applet and Servlet communication etc We tried to use as many such techniques as

necessary in our implementation to demonstrate the advantages of servlets

The demonstration system module is same as the one we mentioned above Figure 331

We use this module to show how such system works

The system called Tiny Book Store emulates an on-line bookstore selling computer

books It has the full functionality of other on-line stores The only difference between

this system and the other on-line systems is the database size We donrsquot want to spend

much developing time for database maintaining part because this part is similar to

ordinary database maintaining and it is an independent subsystem The Tiny Book Store

mainly consists of three modules user interface business procedure and data access

19

41 The Design of Home Page of Tiny Book Store

The home page - welcome page - is designed using the Server-Side Include technique

That is embedding a servlet inside HTML file with a specific HTML tag ltSERVLETgt

In our case this servlet when invoked can run a query on database via data access

objects to retrieve most recent top 5 best-seller books and then returns the retrieved data

to the place within the page where the ltSERVLETgt tag was As long as the data in

database update timely it is guaranteed that customer will get the most recent data

The embedded servlet is invoked by Java Web Server before the page is sent back to

client Java Web Server processes any HTML file having shtml extension and invokes

the embedded servlet marked by ltSERVLETgt tags

Server-Side Includes are useful when a page is primarily static but contains a few distinct

dynamic portions One of the servlets produces the ldquo Five Hot Books ldquo which is shown in

the following example

Example 411 A Part of Code of welcomeshtml

lt P gt

lth3xstrongxf ont color= f f 6347 gtWelcome to theltigt

TinyBookStorecomltigtltfontgtltstronggtlth3 gt

20

ltstrongxbxh3gtltcentergtFive Hot

Booksltc e n t e r x h3gtltbgtltstronggt

ltbrgt

ltservlet code=EchoServletTaggt

ltservletgt

The servlet EchoServletTag searches database according to some business rule and gets

data from data access objects to produce the Five Hot Books The following example is

the sample code

Example 412 A Part of Code of The EchoServletTagjava

public void service(HttpServletRequest req

HttpServletResponse res)

throws ServletException IOException

res setContentType ( text Jhtml)

PrintWriter out = resgetWriter()

try

Statement stmt = concreateStatement()

21

ResultSet rs = stmtexecuteQuery(select from

book where

title like Programming)

int count = 1

outprintln(ltdlgt)

while (rsnext() ampamp count lt 6)

out print In ( ltdtxbgt + count + )

String isbn =

rsgetObj ect(ISBN) toString()

outprintln(lta

href=servletDetailContent + isbn +

outprintln(rsgetObj ect(Title) toString()

+ lt a x bgt )

out println ( ltddxnobrxfont color=990033gtUsuallY

ships in 24 hoursltBRxfontxnobrgt )

outprintIn(ltbrgt +

rsgetObject(Author) toString() )

outprintIn( +

r s getObject(Publisher)toString() + +

r s getObj ect(PublicationDate) toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

out println ltbrxbrgt )

22

count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()

The servelt EchoServletTag by the business mle that searching a specific table sends a

request query through data access object stmt and gets search result through another

data access object rs It then passes data to the page The content between ltservletgt and

ltservletgt tags in the HTML of home page is replaced by the search result at run time

The center part of the sample result page in Figure 411 is an example

23

Figure 411 The Home Page of Tiny Book Store

gj Search TinybookstGiecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

^ bullgt o a 4 i a a j ugt- a a Back lt7gtn Stop Refresh Home j Search Favorites History Mail Print Etfe

-Six

sfekinlfeSsI 3 Address |iS1 httpiVlocalhosLSOSCVwelcomeshtrnl Cj

f S M B l TinyBookStorecom

Search B o o k sW e l c o m e tc f l i e

HomeFive H ot Books 1 1

Category i-si

IA uthor

Title1 The C + + Programming L a n g u a g e B

Usually ships in 114 hoursISBN

k

IPublisher D a teBjame Stroustrup Addis on-Wesley Pub Co 1997Our Price 3147

m2 Programming Visual C+ +

Usually ships in 24 hours y

David J Krn^dinski Dlicrosoft Press 1998 c damp Local intranet

From this practice we know Server-Side Include not only can produce dynamic portion

of the page but also prevent from other people spy into your code Since Java servlet runs

entirely on a server thus protecting your intellectual property and shielding you from the

browser This means what the client sees can be totally different from what the server

does From the client side it is difficult to figure out how the server works

The left-hand menu items are implemented by using a characteristic of servlet - extra

path information or virtual path The extra path information can be used as a kind of

parameter passed to a servlet In general this extra path information is used to indicate a

24

file on the server that should use for something We use this feature here in an abnormal

way to manage customer requests and process these requests in a single place

Consider a traditional method When a menu item is selected by a customer it redirects

the customer to another page where it hyperlinks to If we have several ten items we

need to pre-create several ten pages This is the disadvantage of static HTML pages

However with servlet which can dynamically generate page content we can direct all the

customer requests to a central servlet and process the requests there according to some

condition (parameters) and then generate the page which customer need to see In this

way we only need one place to hold the code to save serverrsquos space And this place is

easy to maintain

The following is how it was doing for the Tiny Book Store

The Author item uses the following hyperlink

ltA

href = servlet ReqCo 11 ect author gtAuthorlt fontx AxTDgt

ltTRgt

The ReqCollect is the name of a servlet We pass the ldquoauthorrdquo in the hyperlink as a

parameter to ReqCollect When the Author item is selected ReqCollect is invoked by

lava Web Server ReqCollect generates a html page to let a user input author search

condition The ReqCollect code is listed below

25

Example 413 A part of Source Code of ReqCollectjava

public class ReqCollect extends HttpServlet

protected final String AUTHOR = author

public void service(HttpServletRequest req

HttpServletResponse res) throws ServletException

IOException

PrintWriter out = resgetWriter()

String path = reqgetPathlnfo ()

if (path == null)

error handling

else

Create standard header

CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

26

path = pathsubstring(1)

if (pathequalsIgnoreCase(CATEGORY))

Create category request collect

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

outprintln(ltfont color=CC66 0 0

face-verdana arial helvetica size = + lxbgtEnter

Authorltbgtltfontgt )

outprintln(ltbrgt You can enter

authors full name first name or last nameltpgt)

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess

id=forml name=formlgt)

outprintln(lttable border=0gt)

outprintln(lttrgt lttd valign=middle

align = lef txttgtltbgtAuthor ltbxttxtdgt )

outprintln(lttd valign=middle

align = lef txinput type = text name= author size = 40

value=x tdgt )

outprintln(lttrgt)

27

outprintln(lttrgt lttd colspan=2gt ltfont

size=-lgt)

outprintln(ltcentergt ltinput

type=radio name=author_mode value=exact

checkedgt Exact Name)

outprintln(ltinput type=radio

name=author_mode value=lastgtLast First Name (or

Initial) )

outprintln(ltcentergt)

outprintln(ltfontgt)

outprintln(lttdgt lttrgt)

outprintln(lttrgt lttd colspan=2gt ltpgt

ltbrgt lttdgt lttrgt)

outprintln(lttablegt)

outprintln(ltcentergt)

outprintln(ltinput type=submit

value=Search Now id=submitl name=submitlgt)

outprintln(cinput type=reset

value=Clear Form id=resetl name=resetlxpgt )

outprintln(ltcentergt ltformgt)

Create standard footer

28

CreateFooter(out)

outflush()

outclose()

The generated page looks like this

Figure 412 One of The Searching by Author PagesTinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorite l o o k H e lp

^ 3 4 s j ] S o zdStop Refresh Home Search Favorites History Mail Print EditBack bull

I t i h f e l f f httplocalhost8080servletReqCollectauthor

S ea rch Books

Home

C a t e g o r y

Author

Title

ISBN Publisher Date

poundj

TinyBookStore com

You can enter authors foil name first name or last name

A u t h o r jbjarne

C Exact N ame amp Last First N atne (or Initial)

Search Now | Clear Form

Taw boekstofeeoraH om e | Category | A uthor | Title | IS3M | Publisher Date

jpyright and disclaimer copy 1999-2001 F ang Xiao

ihtterteti

42 Design of Search by Different Requests

29

According to different requests the different pages should be produced There are many

common parts in the produced pages So we donrsquot need to code the common parts for

each page We can design the common parts into standard utility classes or static

functions You can simply call the standard classes or functions when you needed them

An example looks like this

CreateHeader(out)

CreateLeftMenu(out)

CreateFooter(out)

The three lines above invoke the standard functions CreateHeader() CreateFooter() and

CreateLeftMenu() which are developed in this thesis writing The CreateHeader()

function produces the top part of the pages The CreateLeftMenu() function produces the

left part of the pages The Createfooter() function produces the bottom part of the pages

You can find the source code in several servlets in Appendix

43 Servlet Chaining To Process Requests In Different Levels

A request can be handled by a sequence of servlets This system is designed to use the

first level servlets to handle the search requests If needed the first level servlets can

cooperates with the second level servlets by passing their processing result to the second

level servlets and let them to proceed the request until the final result is obtained The

final result is returned by the last servlet This is called servlet chaining The request

30

from the client browser is sent to the first servlet in the chain The response from the last

servlet in the chain is returned to the browser In between the output from each servlet is

passed as an input to the next servlet Each servlet in the chain has the option to change

or extend the content W e can see the example in the ReqCollect code

Example 431 A Part of Code of The ReqCollectjava

if (pathequalsIgnoreCase(AUTHOR))

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess id=forml

name=formlgt)

The ReqCollect servlet uses the getPathInfo() method to get the extra path information

This method returns the extra path information associated with request According to the

different extra path information the first level servlet invokes the different servlet of the

second level In this case ReqCollect invokes AuthorProcess servlet The final output

has been listed in Figure 412

31

44 Database Connectivity and Search from Database

The biggest advantage for servlets with regard to database connectivity is that the servlet

life cycle allows servlets to maintain open database connections An existing connection

can trim several seconds from a response time compared to a CGI program that has to

reestablish its connection for every invocation

Another advantage of the servlets over CGI and many other technologies is that JDBC is

database-independent JDBC is a SQL-level API - one that allows you to execute SQL

statements and retrieve the results if any The API itself is a set of interfaces and classes

designed to perform action against any database

An individual database system is accessed via a specific JDBC driver that implements the

javasqlDrivers interface Drivers exist for nearly all-popular RDBMS systems The

database connection used for Tiny Book Store uses a JDBC-ODBC bridge driver coming

along with the JDK 12 to allow access to standard ODBC data source such as the

Microsoft Access database

The first step in using a JDBC driver to get a database connection involves loading the

specific driver class into the applicationrsquos Java Virtual Machine This makes the driver

available later when we need it for opening the connection An easy way to load the

driver class is to use the ClassforNameQ method

32

ClassforName(sunj dbcodbcJdbcOdbcDriver)

When the driver is loaded into memory it registers itself with the javasqlDriverManager

class as an available database driver

The next step is to ask the DriverManager class to open a connection to a given database

where the database is specified by a specified formatted URL The method used to open

the connection is DriverManagergetConnection() It returns a class that implements the

javasqlConnection interface

Connection con =

DriverManagergetConnection(j dbcodbcsomedb

user passwd)

A JDBC URL identifies an individual database in a driver-specific manner Different

drivers may need different information in the URL to specify the host database

During the call to getConnection() the DriverManager object asks each registered driver

if it recognizes the URL If a driver says yes the driver manager uses that driver to create

the Connection object Here is an example

Example 441 A Part of Code of AuthorProcessjava

public void init() throws ServletException

try

ClassforNamesunj dbcodbcJdbcOdbcDriver)

con =

DriverManagergetConnection(j dbcodbcfxbookstore null

null)

catch (ClassNotFoundException e)

catch (SQLException e)

After we got the database connection we need to have some way to execute queries The

simplest way to execute a query is to use the javasqlStatement class Statement objects

are never instantiated directly instead a program calls the createStatement() method of

Connection to obtain a new Statement object

Statement stmt = concreateStatement()

34

A query that returns data can be executed using the executeQuery() method of Statement

This method executes the statement and returns a javasqlResultSet that encapsulates the

retrieved data

Example 442 A Part of Code of AuthorProcessjava

String sqlStmt =

if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where author= + name +II i n

else

sqlStmt = select from BOOK where author like +

name +

ResultSet rs = null

Statement stmt = concreateStatement()

rs = stmtexecuteQuery(sqlStmt)

35

A ResultSet object can be thought as a representation of the query result returned one row

at a time The next() method of ResultSet is used to move from row to row The

ResultSet interface also boasts a multitude of methods designed for retrieving data from

the current row The getStringO and getObject() methods can be used for retrieving

column values

Example 443 A Part of Code of AuthorProcessjava

while (rsnextO )

count++

outprintln(ltdtgtltbgt + count + )

String isbn = rsgetObject(ISBN)toString()

outprintln(lta href=servletDetailContent + isbn +

gt )

outprintln(rsgetObj ect(Title) toString() +

ltagtltbgt)

outprintln (ltnobrxfont color=990033gtUsually ships

in 24 hoursltBRgtltfontxnobrgt)

outprintln(ltddgt +

rsgetObj ect(Author) toString() )

36

outprintln( +

rs getOb j ect ( Publisher) toString () + +

rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

outprintln(ltbrgtltbrgt)

One of the outputs of servlet AuthorProcess is show in Figure 421 and Figure 441

Figure 441 One of The Outputs of Servlet AuthorProcess

37

File Edit View Favorites lo o k - Help M i

T 1 bdquo - 0 L Q 4 pound $ L L lBack r s Stop Refresh Home S earch Favorites History

A - Mail Print

Links rdquo Address | jyen j http7ocalhost808O$ervletAuthorProcess 3

Search B ooks

Home

CategoryA uthor

Title

ISBN

P u b l i sh e r D a te

Tiny Bookstore com

1 The C++ Prograitmuitg Language Usually ships in 24 hour Bjame Stroustrup Addison-Wesley Pub Co i 1997 Our Price 3147

T in yb o oks to re c om H ora e | Category | A uthor | Till | ISBN | Publisher P a t

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top of Page

gk j Local intranet

45 Session Tracking

Session Tracking is one of the most important techniques for any on-line store systems

This is because that HTTP protocol is a stateless protocol A HTTP server sees only a

series of requests and it by itself has no way to know exactly who is making the request

This means that when a customer puts a book in his shopping cart and then goes to other

pages to find more books next time when he puts another book in his shopping cart there

is no guarantee that he puts the book in the same cart It is very possible that he uses

another customerrsquos shopping cart at this time

38

To solve this problem session-tracking is introduced Traditional techniques used by

CGI include hidden form fields URL rewriting user authorization and persistent cookies

For server-side Java applications a built-in class supplied servlet can be used easily to

handle such tasks

When a user first accesses the site web server assigns a new HttpSession object and a

unique session ID to the user The session ID identifies the user and is used to match the

user with the HttpSession object in subsequent requests Usually the session ID is saved

on the client in a cookie or sent as part of a rewritten URL The Tiny Book Store uses this

technique

The Tiny Book Store is a classic shopping cart application A client can put items in his

virtual cart accumulating them until he checks out several page requests later How to

make sure a userrsquos shopping items will be put in his shopping cart or delete from his

shopping cart The Java Servlet API provide built in session tracking to handle this

problem Every user of a site is associated with a javaxservlethttpHttpSession object

that servlets can use to store or retrieve information about that user We can save any set

of arbitrary Java objects in a session object For example a userrsquos session object provides

a convenient location for a servlet to store the userrsquos shopping cart contents An example

shows below

Example 451 A Part of Code of AddToShoppingCartjava

39

1 Get current session object create one if necessary

2 HttpSession session = reqgetSession(true)

3 m_cart = (ShoppingCart)sessiongetValue(cart)

4 if (ra_cart == null) need new cart

5 create a shopping cart

6 m_cart = new ShoppingCart()

7 add to current session

8 sessionputValue(cart m_cart)

9

10

11 try

12 Statement stmt = m_concreateStatement()

13 ResultSet rs = stmtexecuteQuery(select from

book where ISBN= + isbn +)

14 if (rsnext())

15 book - new

BookDetails(rsgetObj ect(ISBN) toString()

16 rsgetObject(Title)toString()

rsgetObj ect(Authorrdquo) toString()

17 rsgetDouble(Price)

rsgetObj ect(PublicationDate) toString() )

18

40

1 9

2 0 catch (SQLException e)

21 e printStackTrace()

22

23 m_cartadd(bookgetlSBN() book)

The servlet uses its request objectrsquos getSession() method to retrieve the current

httpSession object

public HttpSession HttpServeltRequestgetSession (boolean create)

This method returns the current session associated with the user making the request If

the user has no current valid session this method creates one if create is true or return

null if create is false To ensure the session is properly maintained this method must be

called at least once before any output is written to the response Please look at the line 2

in the example 451

If you want to add data to an HttpSession object you can use the putValueQ method

public void HttpSessionputValue(String name Object value)

41

This method binds the specified object value under the specified name Any existing

binding with the same name is replaced This specifies at line 8 of the example 451

If you want to retrieve an object from a session you can use getValue() method

public Object HttpSessiongetValue(String name)

This method specified at line 3 of example 451 returns the object bound under the

specified name or null if there is no binding

From line 4 to line 9 the servlet checks whether the user already has a shopping cart If

the user didnrsquot have a shopping cart the servlet assigns a shopping cart to this user and

add the shopping cart to the current session to keep tracking The ShoppingCartjava class

is developed in this thesis writing code is provided in the appendix

From line 10 to line 21 the servlet knows the user already has a shopping cart m_con is

a data member of AddtoShoppingCart class Lines 12-13 have been discussed in the

previous section Lines 16-20 get some information of the book which the user selected

The information will be the data members of the ldquobookrdquo object that is an instance object

of BookDetailsjava class BookDetailsjava class is developed in this thesis writing the

source code is provided in the Appendix

Line 25 puts the book which is selected by the user into the shopping cart

42

Please see a set of pages are shown below

Figure 451 A Page Show All Information About A Book

TinjiRnfikStnre com - M inrnsnfl Interned Explnrpr

File Edit View Favorites Tools Help-

^ O 4 4 1 f i tStop Refresh Home I Search Favorites History Mail Print Edit

I Link gtgt Address [gl hgtplocalhos9l]IBrit-rvetDetailConetit-Ll20183l)544

S e a r c h B o o k s

Home-

C a t e g o r y

Author

Title

ISSNPublisher Pate

TinyBookStore com

The C++ Programming Languageby Bjarne Stroustrup

aISBN 0201889544 Addison-Wesley Pub Co 1997

Price 3147 Availability U sually ships within 24 hours

Add to cart

Done

R ev iew s

In tins brand-new third edition of The C + + Programming Language author Bjame Stroustrup the creator of C++ presents the full specification for the C++ language and standard library a spec that will soon become the joint ISOANSI C++ standard

g ig L o ca l in tranet

43

Figure 452 A Page Show Items In The Shopping Cart after A User Added Books To The Shopping Cart

H H I H I - I I

j File Edit View Favorites l o o k Help I f

| S ack Stop Refresh Home Search FavoritesJ V

History Wail Print

j Links Address |S1 http7localhost8O80servletAddToShoppingCart i i i i a i i i

( O ldquo ii

Shopping Cart Item s Price

An Introduction to fen e tic Algorithm sMelanie MteheU Quantity 1 Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

drle trgt

delete

delete

Price $ 2 2 0 Subtotal $ 2 2 0

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 6 7 5 6

|euro

rfuj Local intranet

44

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A Book From The Shopping Cart

^ A m a z o n c o m Shopping Cart - Microsoft Internet Explorer

- J A l 4Stop Refresh Home

gtH bdquo ] Back bdquo

httplocalhost8080servletDeleteFromShoppingCartitemgetltem()getlSBN()

Ji _J 3Search Favorites History

j - JMarl Print

~U ccdeg

Shopping Cart Item s

Core Java 2Cay S Horstrnaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d elete

delete

Price

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 4 5 5 6

rsquo0 1 Done gSsfLocat intranet

46 Check Out

This part is designed only using the HTML It collects all information from a user The

information will be written into the database

An important line in this HTML file is shown below

45

ltform method=POST

action=httplocalhost808 0servletCustomerlnfoProcessgt

This line will invoke the servlet CustomerlnfoProcess that will process all data collected

from the user This servlet will discuss in the next section The check out page shows in

Figure 461

Figure 461 A Check Out Page

M M iH M M M i M MmmrnfrnM File Edit View Favorites too ls Help

^ gt a 3 A hi -ltamp f V j HISllll mmB ack S lop R efresh H em e S earch 1 i l lie History M 1 Print Edit

^Links A ddrecs j ig ] h ltp localhostSO SO checkouth tm l i i i l a s

Custom er Information

First name (Fang

Middle initial |a

Last name [Xiao

Email address |fgtdaomitecnet

Account password Jxxxxx

C red it card num ber jl 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7

Credit card type ttV isa O BluebirdO MasterCard O Fisher

Credit card holder jFarig Xiao

Credit card expire date (tnmddyy) joi 0102 ~

Select shipping method t UPS 0 NormalO Express C Abnormal

| | ] Dorraquo raquo f j^ I o c a l intranet

47 Customer Information Processing

The customer information processing is handled by a servlet CustomerlnfoProces Its

source code is provided in the appendix

46

All information collected from the user should be written into the database therefore we

have to open a connection to a given database at first Example 461 is given for this

purpose

Example 471 A Part of Code of CustomerlnfoProcessjava

public void init() throws ServletException

try

ClassforName(sunjdbcodbcJdbcOdbcDriver)

m_con = riverManagergetConnection(jdbcodbcfxbookstore

null null)

catch (ClassNotFoundException e)

e printStackTrace()

catch (SQLException e)

e printStackTrace( )

There is a PO ST request in the check out page The servlet CustomerlnfoProcess will

handle the PO ST request by doPost function which is demonstrated in the following

example

47

Example 472 A Part of Source Code of CustomerlnfoProcessjava

public void doPost (HttpServletRequest req HttpServletResponse res)

throws ServletException IOException

ressetContentType(texthtml)

PrintWriter out = resgetWriter()

get information

String[] values = reqgetParameterValues(firstname)

if (values = null)

firstname = values[0]

values = reqgetParameterValues(middleinit)

if (values = null)

middleinit = values[0]

In the example the HttpServletRequest object res will get each data which was input by

the user by the getParameterValues() function

If the user is a returned user we donrsquot need open a new account again If the returned user

use the same credit card as previous we also donrsquot need to insert the credit card

48

information into the CREDITCARD table Otherwise we should insert all related

information into related table This is shown in the following example

Example 473 A Part of Source Code of CustomerlnfoProcessjava

Statement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where EmailAddress= +

email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext())

sql = insert into CUSTOMERACCOUNT (emailaddress password

firstname middleinit lastname) values ( + + email +

password + + firstname + + middleinit + lastname +

)

stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber= + creditcard

+

rs = stmtexecuteQuery (sql)

if (rsnext())

49

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype

HolderName ExpirationDate) values( + + creditcard + +

cardtype + + cardholder + 11 + expiredate + )

stmtexecute (sql)

All information related the books selected by the user can be obtained from the

shopping cart as shown in the following example

Example 474 A Part of Source Code of CustomerlnfoProcessjava

BookDetails book = null

ShoppingCartltern bookAndQuantity = null

Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getltems()

int aQuantity =0

String alSBN = null

while (itemshasMoreElements())

insert into Orderltems

bookAndQuantity = (ShoppingCartItem)itemsnextElement()

book = bookAndQuantitygetltem()

50

aQuantity = bookAndQuantitygetQuantity()

alSBN = book getISBN()

sql = insert into ORDERITEMS (shoppingCartID ISBN quantity)

values ( + + m_cartID + + aISBN + + aQuantity + )

stmtexecute (sql)

After all information inserted into related tables the servlet CustomerlnfoProcess will

produce invoice page The example page shows in Figure 471

51

Figure 471 An Invoice Page 3 Order List Microsoft Internet Explorer

is File Edit View Favorites Tools Help

J J J U r PS to p Refresh Hom e i -S earch Favorites History s Mai Print

Links Address iff 1 httpVlocalhostBOSOservletCustomerlnfoProcess 3

s5al Local intranet

Y ou r order reads as fo llow sE-MailAddress fiiiaomitecnet

ship to

Tel

Items

F ang Xiao12345 Western Plaza 23OmahaNE68154(402)123-4567

TitleCore Java 2Qtyl Price2579Subtotal2579

TitleJava Servlet PrograrnmingQtyl Price 1977 Sub total 1977 Total4556

i|51 D one

52

Chapter 5

Future Work

In this chapter we discuss two major problems for our future work They are the

Connection Pooling and Object-Oriented for better encapsulation

51 Connection Pooling

After we have used JDBC for a short time it will become evident that the major

performance bottleneck often comes right at the beginning when you are opening a

database connection This is because that opening a connection might involve a series of

low level communications between network protocols and database connection protocols

such as TCPIP ODBC etc

Servlet life cycle allows for extremely fast database access Servlet is loaded into Web

server only once Once it is loaded it can hold a connection to database all its life cycle

Every time it receives a request to read from or write data to database it can just use the

connection to do this

Here comes a problem however Suppose that a customer comes to the on-line store

During the period of selecting some items from the store he leaves his desktop and do

something else leaving this connection to database idling This will waste the precious

resource on the database From database port of view the connection to the database will

assign a space to hold corresponding status and to cache data For example Microsoft

SQL-Servertrade assigns about 36K bytes for each of its connection Resource on the

53

database is limited and idling connection causes such resource unable to be reused for

other users

To solve this problem we can use the technique called connection pooling Essentially a

connection pool is an object holding connections to backend database and managing the

number and status of connections For example if a connection in the pool idles over a

certain time of period the pool can terminate this connection if the requests are not the

same size of the connection pool the pool can dynamically shrink or expand the size of

itself A connection pool can run on a separate thread and is initialized when the server

starts or when a request to database is arrived

To implement a connection pool is pretty straight-forward Because of time constraint

however we did not do it in this paper and leave it as a possible future improvement

52 More Object-Oriented - Better Encapsulation

Another improvement might be done in the future is to create a HTML-related utility

class We have seen in this thesis that there are some duplicated code processing HTML

output such as ldquoout printIn ( lttbxtrgt lttrxtbgt)rdquo All these HTML-

related processes right now are used in a raw way That is they are not encapsulated A

better way to do this is to create a utility class or classes to deal with all HTML-related

processes and hide all HTML tags and format inside the class or classes For example

suppose that we create a Table class then we can use it in a way like

Table table = new Table()

54

table(somerow somecol contents)

table(somerow somecol some_image)

In this way we do not need to use HTML tags in our program and concentrate on the

programming logic The implementation is enriched with more object-oriented property

and therefore it is easy to maintain

55

Chapter 6

Conclusion

The increased awareness and popularity of the Internet make all kinds of electronic

commerce grow vigorously The most popular Web applications are the on-line stores

An on-line store system usually contains four components Web server business

procedure Database system application An on-line store system is different from web

publishing Currently there are three mainstream technologies which are widely used to

develop the on-line store systems CGI Microsoft ASP and Server-side Java application

Introducing the server-side Java application is one of the latest and most exciting trends

in Java programming We have discussed this technology in detail in this thesis The

server-side Java applications have many distinct advantages over CGI and other

technologies We present plenty of examples and figures to analysis the characteristics of

the server-side Java application

As a glance into the future electronic commerce will continue to grow driven by

purchases of home computers and other Web-enabled devices as well as new business

opportunities Electronic commerce is changing whole business procedures The future of

electronic commerce will be exciting and full of opportunities

56

APPENDIX A

Bibliography

57

[1] Karl Moss 1998 Java Servlets Mcgraw-Hill

[2] Jason Hunter William Crawford 1998 Java Servlet Programming O rsquoReilly

[3] Manoj Kumar Anand Rangachari Anant Jhingran Rakesh Mohan 1998 Sales Promitions on the Internet h ttpwwwibmcomiactech-paperhtml

[4] Manoj Kumar Stuart I Feldman 1998 Business Negotiations on the Internet httpwwwibmcomiactech-paperhtml

[5] Manoj Kumar Stuart I Feldman 1998 Internet Auction httpwwwibmcomiactech-paperhtml

[6] Shiwa Fu Jen-Yao Chung Walter Dietrich Vibby Gottemukkala Mitchell Cohen Shyhkwei Chen 1999 A Practical Approach to Web-Based Internet EDI httpwwwibmcomiacpapersicdcsws99indexhtml

[7] Zhong Tian Leo Y Liu Jing Li Jen-Yao Chung Vibby Guttemukkala 1999 Business-to-Business e-Commerce with Open Buying on the Internethttpw w w ibm comi acpapersobi -paperindex html

[8] Gerald J Tesauro Jeffrey O Kephart 1998 Foresight-Based Pricing Algorithms in an Economy os Software Agents http wwwi bm comi actech - paper html

[10] Jeffrey O Kephart James E Hanson Jakka Sairamesh 1998 Price and Niche Wars in a Free-Market Economy o f Software Agents httpwwwibmcomiactech-paperhtml

[11] Jeffrey O Kephart James E Hanson David W Levine Benjamin N Grosof Jakka Sairamesh Richard B Segal Steve R White 1998 Dynamics o f an Information-filtering Economy httpwwwibmcomiactech-paperhtml

[12] James E Hanson Jeffrey O Kephart 1998 Spontaneous Specialization in a Free-Market Economy os Agents httpwwwibmcomiactech-paperhtml

[13] Jakka Sairamesh Jeffrey O Kephart 1998 Price Dynamics o f Vertically differentiated Information Markets httpwwwibmcomiactech-paperhtml

[14] David Kosiur 1997 Understanding Electronic Commerce Microsoft Press

[15] Gunther Birznieks Selena Sol 1997 CGI fo r Commerce MampT Books - A Division of MIS Pres

58

[16] Ravi Kalakota Andrew B Whinston 1997 Electronic Commerce Addison Wesley

[17] Alex Fedorov Richard Harrison Dave Sussman Brian Francis Stephen Wood 1998 Profession Active Server Page 20 Wrox Press

[18] Calvin Austin Minica Pawlan 1999 Writing Advanced Application for the Java PlatformhttpVdeveloper iavasuncomdeveloperonlineTrainingProgrammin gJDCBooki ndexhtml

59

APPENDIX B

The Source Code of An On-Line Store System - Tiny Book Store

60

1 welcomeshtml

lthtmlgtltheadgtlttitlegtSearch Tinybookstorecomlttitlegtltheadgtltbodygt

lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=eeeeccgtlttrgtlttd rowspan=2 align=left valign=top width=15 cellspacing=0 cellpadding=0xIM G border=0 hspace=0 id=IMGl src=flowergif gtlttdgtlttd rowspan=2 align=left valign=centergtltstronggtlth2gtltigtTinyBookStorecomltigtlth2gtltstrongxtdgtlt trx tab legt

lttable border=0 width=100 cellspacing=0 cellpadding=0gtlttrgtlttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtltPgt

lttable width=100 cellspacing=0 cellpadding=5 border=0gtltTRgt ltTDgt ltTDgt ltTD colspan=2gt ltFONT FACE=verdanaarialhelvetica SIZE=-1 gtampnbsp ltFONTgt ltTDgt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD co lsp an = 2 x stro n g x fo n t face=verdanaarialhelvetica size=-lgtSearch B ooksltfontxstronggt ltTDgt ltTRgtltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt ltTD x f o n t face=verdanaarialhelvetica size=-l gt

lta href=w elcom eshtm lgtH om eltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt c T D x fo n t face=verdanaarialhelvetica size=-1 gt

lt A href= servletReqC ol 1 ec tc ategory gtC ate gory ltf o n tx A x T D gtltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollectauthorgtA uthorltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollecttitlengtTitleltorfo n tx A x T D gt ltTRgt

61

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectisbngtISBN ltA xfontxTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectpublisher_dategtPublisherD a telt A x fo n tx T D gtltTRgtlt tab lex p gtlttdgt

lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgtlttd valign=top align=leftgt

ltbr clear=allgtltPgtlt h 3 x s tro n g x fo n t color=ff6347gtWelcome to theltigt T in y B o o k S to rex o m lt ix fo n tx s tro n g x h 3 gt

ltbrgtlt s tro n g x b x h 3 x c e n te rgt F iv e Hot B o o k slt cen te rx h 3 x B x s tro n g gt

ltbrgtltservlet code=EchoServetTag myArgI=myValuel myArg2=myValue2gt ltparam name=myParm 1 value=Hellogtltparam name=myParml value=Worldgtltparam name=myParm2 value=myParmValue2gtltservletgt

lt td x trgt

lttablegt

ltTABLE width=100gtltTRgt ltTD width=50 valign=top align=Ieftgt ltTDgtltTD width=50 valign=top align=rightgtltfont size=-lgtltA href=topgtTop of P ag elt A x fo n tx T D gt ltTRgt

62

ltTABLEgt

ltcentergtltfont size=-lgtltA href=indexhtml gtTinybookstorecom HomeltAgt ampnbsplampnbsp ltA href=categoryhtml gtCategoryltAgt ampnbsplampnbspltA href= author html gtAuthorltAgt ampnbsplampnbspltA href= title html gtTitleltAgt ampnbsplampnbspltA href=7isbnhtml gtISBNltAgt ampnbsplampnbspltA href=publisherhtmrgtPublisher DateltAgtltpgtltfontgtltcentergt

ltPgtltcentergtlt b rx fo n t size=-lgtltA href=copyrighthtml gtCopyright and disclaimerltAgt copy 1999-2001 Fang Xiao ltfontgtltcentergt

ltbodygtlthtmlgt

63

2 AddToShoppingCartjava

ltpgt AddToShoppingCart is the servlet that process the action of adding item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javasql import javautil import javaxservlet import javaxservlethttp

public class AddToShoppingCart extends HttpServlet

protected Connection m_con = null protected ShoppingCart m_cart protected BookDetails book

public void initQ throws ServletException try

Class forName( sunj dbc odbc JdbcOdbcDriver)m_con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintstackTrace ()catch (SQLException e)

e prints tackT race ()

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

String[] params = reqgetParameterValues(isbn)

64

String isbn = get isbn from extra path infomationif (params = null)

isbn = params [0]

Get current session object create one if necessary HttpSession session = reqgetSession(true) m_cart = (ShoppingCart)sessiongetValue(cart)

if (m_cart == null) need new cart create a shopping cart m_cart = new ShoppingCart() add to current session sessionputValue(cart m_cart)

try Statement stmt = m_concreateStatement()ResultSet rs = stmtexecuteQuery(select from book where

ISBN=rsquo + isbn + rsquo)

if (rsnext()) book = new BookDetails(rsgetObject(ISBN)toString()

rsgetObject(TitIe)toStringOrsgetObject( Author) toStringO

rsgetDouble( Price) rs getObj ect( PublicationDate) toStringO)

catch (SQLException e)

eprintStackTrace()m_cartadd(bookgetISBN() book)

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lt h tm lxheadx titlegt T inyB ookS tore com S hopping

Cartlttitlexheadgt)outprintln(ltbody bgcolor=FFFFFF lmk=003399

alink=FF9933 vlink=996633 text=000000ngt)outprintln(lta nam e= topxmdashTop of Pagemdashx a gt )

65

outprin tln(ltpxa href=httplocalhost8080checkouthtmlximg src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=cccc99 gt)ou tp rin tln (lt tdxbrx tdgt )ou tp rin tln (lt tdxbrx tdgt )o u tp rin tln (lt tdxbrx tdgt )outprintln(lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=2xfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=left valign=topxfont

face=verdanaaria lhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=cccc99gt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lt td x b rx td gt ) outprintln(lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantityQ

outprintln(lttr bgcolor=FFFFFFgt) ou tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt )outprintln(ltbrgt + item getltem() get Author()) outprintln(ltbrgtQuantity + itemgetQuantityO) outprintln( ltbrgt) outprintln(lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=POST

action=7servletDeleteFromShoppingCartitemgetItem()getISBN()gt)

66

outprintln(ltpgt cinput type=hidden name=isbn value= + itemgetItem()getISBN())

outprintln(ltpgt ltinput type=submit name=ditemvalue=deletegt)

outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelve tica color=000000gt)

outprintln(ltNOBRgtltbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fon tx bx N O B R gt ltbrgt )

outprintln(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantity() + lt fo n tx b x N O B R x b rgt )

outprintln(ltfontgt) out println( lttdgt)

out printl n( lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)out println( lt fo n tx fo n tgt )outprintln(lttdxtrgt)outprintln(lttablegt)outprin tln(ltpxa href=httplocalhost8080checkouthtmlYximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)outprintln(ltbodygt lthtmlgt)

outflush()outclose()

67

3 AuthorProcessjava

bull ltpgt AuthorProcessbull This is the servlet that process the Author-search request and generatebull search resultbull Author Fang Xiao Purpose Thesis project Copyrightcopy Fang Xiao 1999-2001

import javaxservlet import jav ax servlet http import javaio import javasql

public class AuthorProcess extends HttpServlet protected final String EXACT = ldquoexactrdquo protected final String OTHERS = ldquolastrdquo

protected Connection con = null

public void init() throws ServletException try

ClassforName(ldquosunjdbcodbcJdbcOdbcDriverrdquo)con = DriverManagergetConnection(ldquojdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(ldquotexthtmlrdquo)PrintWriter out = resgetWriterQ

68

String[] valuesString name =

values = reqgetParameterValues(ldquoauthorrdquo) if (values = null)

name = values [0]

String mode = ldquordquovalues = reqgetParameterValues(ldquoauthor_moderdquo) if (values = null)

mode = values [0]

String sqlStmt = ldquordquo if (modeequalsIgnoreCase(EXACT))

sqlStmt = ldquoselect from BOOK where author=rsquordquo + name +else

sqlStmt = ldquoselect from BOOK where author like lsquordquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

ldquoYour Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ldquoltdlgtrdquo) 11 start Glossary List

while (rsnext()) count++outprintln(ldquolt d tx b gt rdquo + count + ldquo ldquo)String isbn = rsgetObject(ldquoISBNrdquo)toString()

69

outprintln(ldquolta href=servletDetailContentrdquo + isbn+

outprintln(rsgetObject(ldquoTitlerdquo)toString() +ldquolt a x b gt rdquo)

outprintln(ldquolt n o b rx fo n t color=990033gtUsually ships in 24 h o u rslt B R x fo n tx n o b rgt rdquo)

outprintln(ldquoltddgtrdquo +rsgetObject(ldquoAuthorrdquo)toString())

outprintln(ldquo ldquo +rsgetObject(ldquoPublisherrdquo)toString() + ldquo ldquo + rsgetObject(ldquoPublicationDaterdquo)toString())

outprintln(ldquoltbrgt Our Price ldquo +rsgetObject(ldquoPrice)toString())

outprintln(ldquolt b rx b rgt rdquo)

if (count == 0) outprintln(ldquoltdtgt No matched data foundrdquo)

outprintln(ldquoltdlgtrdquo) end Glossary List

catch (SQLException e) create footer here outprintln(ldquolttdgt lttrgtrdquo) outprintln(ldquolttablegtrdquo)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(ldquolthtmlgtrdquo) outprintln(ldquoltheadgtrdquo) outprintln(ldquolttitlegt TinyBookStorecom lttitlegtrdquo) outprintln(ldquoltheadgtrdquo)

outprintln(ldquoltbodygtrdquo)

70

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspacing=0 cellpadding=0 bgcolor=rdquoEEEECCYrsquogtrdquo)

outprintln(ldquolttrgtrdquo)outprintln(ldquolttd align=left valign=top width=90 gtrdquo) outprintln(ldquoltIMG border=0 hspace=0 id=IMGl

src=rdquodJavaWebServer20public_htmlflowergifrdquogtlttdgtrdquo) outprintln (ldquolttd width=30gtlttdgtrsquorsquo) outprintln(ldquolttd align=left valign=center width=300gtrdquo)

outprintln(ldquolt stro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x s tro n g x td gt rdquo) outprintln(ldquolttd align=right valign=centergtrdquo) outprintln(ldquolttdgtrdquo) outprintln(ldquolttd w id th= 20x tdgt rdquo) out pri ntln (ldquolttrgtrsquo rsquo) outprintln(ldquolttablegtrdquo)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ldquolttable width= 100gtrdquo)outprintln(ldquolttrgt lttd width=50 valign=top align=leftgt lttdgtrdquo) outprintln(ldquolttd width=50 valign=top align=rightgtrdquo) outprintln(ldquoltfont s iz e = - lx a href=rdquotoprdquogtTop of P agelt ax fon tgt rdquo) outprintln(ldquolttrgtrdquo) outprintln(ldquolttablegtrdquo)

outprintln(ldquoltcentergtrdquo) outprintln(ldquoltfont size=-lgtrdquo) outprintln(ldquolta

href=rdquohttplocalhost 8080welcomeshtmlrdquogtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080$ervletReqCollectcategoryrdquogtCategoryltagtampnbsplampnbsprdquo)

outprintln(ldquoltahref=Yhttplocalhost8080servletReqCollectauthorrdquogtAuthorltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_daterdquogtPublisheramp44Dateltagtrdquo)

outprintln(ldquoltpgtrdquo)

71

outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltpgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquolt b rx fo n t size=-lgtrdquo)outprintln(ldquoltA href=Y7copyrighthtmlrdquogtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiaordquo)outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltbodygtrdquo) outprintln(ldquolthtmlgtrdquo)

i

protected void CreateLeftMenu(PrintWriter out) System out println(ldquoLeftMenurdquo)

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspaeing=0 cellpadding=0gtrdquo)

outprintln(ldquolttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtrdquo)

outprintln(ldquoltpgtrdquo)

outprintln(ldquolttable width=rdquo 100rdquo cellspaeing=0 cellpadding=5border=0gtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquoltfont face=verdanaarialhelvetica SIZE=rdquo- l rdquogtampnbsp

ltfontgtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquolt strongxfon t face=verdanaarialhelvetica size=rdquo-

1 rdquogtSearch B ooksltfontxstronggtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd ldquo) outprintln(ldquoltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080welcomeshtmlYgt H o m elt fo n tx ax td gt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=rdquo-1rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080servletReqColIectcategoryrdquogt C ateg o ry lt fo n tx ax td gtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

72

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectauthorrdquogtAuthorltfontgtltagtlttdgtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width-2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l W rsquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltfontgtltagtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo-lYgtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_dateVrsquogtPublisher Dateltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolt tab lex p gt rdquo)

outprintln(lsquolsquolttdgtrdquo)outprintln(ldquolttd rowspan=4 width=5gtampnbspampnbspltbrgtlttdgtrdquo) outprintln(ldquolttd valign=top align=leftgtrdquo) outprintln(ldquoltbr clear=allgtrdquo)

73

4 BookTeatailsjava

ltpgt This is the class describing a book item in shopping cart

Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class BookDetails private String m_isbn = null private String m_title = null private String m_author = null private double m_price = 00 private String m_year = null

public BookDetails(String isbn String title String author double price String year)

thism_isbn = isbn thism_title = title thism_author = author thism_price = price thism_year = year

public String getISBN() return m_isbn

public String getTitle() return m_title

public String getAuthor() return m_author

public double getPrice() return m_price

ipublic String getYearQ

return m_year

75

5 CategoryProcessjava

ltpgt CategoryProcess This is the servlet that process the Category-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql import javautil

public class CategoryProcess extends FlttpServlet protected final String EXACT = exactprotected final String OTF1ERS = last

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

76

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentType( texthtml)Print Writer out = resgetWriterQ

String[] values String name = String sqlStmt =

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

else

path = pathsubstring(l) if (pathequalsIgnoreCase(cO 1))

sqlStmt = select from BOOK wherecategoryid=rsquo + cOl +

else if (pathequalsIgnoreCase(c02))sqlStmt = select from BOOK where

categoryid=rsquo + c02 +else if (pathequalsIgnoreCase(c03))

sqlStmt = select from BOOK wherecategoryid=rsquo + c03 +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftM enu(out)

Your Book Search Results try

77

if (con = null) Statement stmt = concreateStatement() rs = stmt executeQuery (sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn

+outprintln(rsgetObject(Title)toString() +

lt ax bgt )outprintln(ltnobrxfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltddgt +

rsgetObject( Author)toStringO)outprintln( +

rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)outprintln(ltbrgt Our Price +

rsgetObject( Price) toStringO) ltfont color=990000gtYou Save $1100

(20)ltfontgtoutprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

78

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)out println( lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20publicbdquohtmlflowergifgtlttdgt) outprintln(lttd width=3 0gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln( lt s tro n g x h 2 x igt T inyB ookS to re com lt ix h2x s tro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlngtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

79

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYrsquogtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln( ltfontgt)outprintln(ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rOwspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt)

outprintln(lttablewidth= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=Y2Ygt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y-1 Yrsquogtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2Yrsquogt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=Y-

lYrsquogtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=Y-lYgt)

80

outprintln(ltahref=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqColIectcategorygtCategoryltfontxagtlttdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(nltahref=httplocalhost8080servletReqCollectauthorVrsquogt A u th o rlt fo n tx ax td gtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httpIocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

6 CustomerlnfoProcessjava

ltpgt CustomerlnfoProcessThis servlet is responsible to process userrsquos information when heshe check out

Author Fang Xiao

Purpose Thesis projectCopyright (C) Fang Xiao 1999-2001

import javasql import javaio import j avau til import javaxservlet import javaxservlethttp

public class CustomerlnfoProcess extends HttpServlet protected Connection m_con = null protected HttpSession m_session = null protected static int m_cartID = 1 protected String firstname =protected String middleinit =protected String lastname =protected String email =protected String password =protected String creditcard =protected String cardtype =protected String cardholder =protected String expiredate =protected String shipping =protected String receiver =protected String address =protected String city =protected String state =protected String zipcode =protected String phone =

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)

82

m_con = DriverManagergetConnection(jdbcodbcfxbookstorenull null)

catch (ClassNotFoundException e)

eprintStackTrace()catch (SQLException e)

eprintStackTrace()i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

get informationString[] values = reqgetParameterValues(firstname) if (values = null)

firstname = values [0]

values = reqgetParameterValues(middleinit) if (values = null)

middleinit = values [0]

values = reqgetParameterValues(lastnameM) if (values = null)

lastname = values [0]

values = reqgetParameterValues(email) if (values = null)

email = values [0]

values = reqgetParameterValues(password) if (values = null)

password = values [0]

values = reqgetParameterValues(creditcard)

if (values = null) (creditcard = values [0]

values = reqgetParameterValues(cardtype) if (values = null)

cardtype = values [0]

values = reqgetParameterValues(cardholder) if (values = null) (

cardholder = values [0]

values = reqgetParameterValues(expiredate) if (values 1= null)

expiredate = values [0]

values = reqgetParameterValues(shippingrdquo) if (values = null)

shipping = values [0]

values = reqgetParameter Values (receiver) if (values = null)

receiver = values [0]

values = reqgetParameterValues(address) if (values = null)

address = values [0]

values = reqgetParameterValues(city) if (values = null) (

city = values [0])

values = reqgetParameterValues(state) if (values = null) (

state = values [0]

84

values = reqgetParameterValues(zipcode) if (values = null) (

zipcode = values [0]

values = reqgetParameterValues(phone) if (values = null)

phone = values[0]i

get session object m_session = reqgetSessionQ

try update databaseStatement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where Email Address=rsquo + email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext()) Systemoutprintln(insert customeraccount)

sql = insert into CUSTOMERACCOUNT (emailaddress password firstname middleinit lastname) values ( +

+ email + + password + + firstname +V + middleinit + + lastname + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber=rsquo +creditcard +

rs = stmtexecuteQuery (sql)

if (rsnext()) Systemoutprintln(insert creditcart)

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype HolderName ExpirationDate) values( +

+ creditcard + + cardtype + +cardholder + + expiredate + rdquo)

Systemoutprintln(sql)stmtexecute (sql)

i

85

sql = insert into SHOPPINGCART (ShoppingCartIDEmail Address CreditCardNumber ShippingType ReceiverName ReceiverAddress ReceiverCity ReceiverState ReceiverZipcode ReceiverPhone) values ( + m_cartID + V + email + Vrdquo +

creditcard + V + shipping + + receiver ++ address + V +

city + V + state + V + zipcode + V + phone +gt gt

Systemoutprintln(sql)stmtexecute (sql)

BookDetails book = nullShoppingCartltem bookAndQuantity = null Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

int aQuantity =0 String alSBN = null

while (itemshasMoreElementsO) insert into Orderltems bookAndQuantity =

(ShoppingCartItem)itemsnextElement()book = bookAndQuantitygetItem()

aQuantity = bookAndQuantitygetQuantity() alSBN - book getISBN()

Systemoutprintln(insert Orderltems)sql = insert into ORDERITEMS (shoppingCartED ISBN

quantity) values ( + m_cartID + +alSBN + + aQuantity + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

im_cartID++ must increase by one

86

catch (SQLException e) eprintS tackTrace()

printOrder(out)

public void printOrder(PrintWriter out) outprintln( lthtmlgt ltheadgt lttitlegt Order List lttitlegt ltheadgt) outprintln( ltbodygt)outprintln(lthlgt Your order reads as follows lthlgt)outprintln(lttablegt)outprintln( lttrgt)outprintln( lttdgtE-Mail Addres s lttdgt) outprintln(lttdgt+ em ail+lttdxtrgt) outprintln(lttrgt) outprintln(lttdgtship tolttdgt) outprintln(lttdgt+ receiver +ltbrgt) outprintln(address +ltbrgt) outprintln(city +ltbrgt) outprintln(state +ltbrgt) outprintln(zipcode + lt b rx td x trgt ) outprintln(lttrgt) outprintln( lttdgtTel lttdgt) outprintln(lttdgt+ phone +lttdxtrgt) outprintln(lttrgt) outprintln( lttdgtItems lttdgt)

BookDetails book = nullShoppingCartltem bookAndQuantity = nullEnumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

double total = 00

while (itemshasMoreElements()) bookAndQuantity = (ShoppingCartItem)itemsnextElement()

total += bookAndQuantitygetItem()getPrice() bookAndQuantitygetQuantityO

book = bookAndQuantitygetltem()

87

outprintln(lttdgtTitle+ bookgetTitle() + Qty + bookAndQuantitygetQuantity() + ltbrgt)

outprintln(Price + bookgetPrice() + Subtotal + bookAndQuantitygetQuantityO bookgetPrice() +ltbrgt)

outprintln(Total + total )outprintln(lttdxtrgt)outprintln(lttablegt)outflush()outclose()

7 DeleteFromShoppingCartjava

ltpgt DeleteFromShoppingCart is the servlet that process the action of deleting item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javautil import javaxservlet imp ort j avax servlet http

public class DeleteFromShoppingCart extends HttpServlet

protected ShoppingCart m_cart protected BookDetails book

public void doPost(HttpServletRequest req FIttpServletResponse res) throws ServletException IOException res setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String[] params = reqgetParameterValues(isbnrsquo) String isbn = get isbn hidden fieldif (params = null)

isbn = params [0]

Systemoutprintlnfisbn = + isbn)

Get current session objectHttpSession session = reqgetSession()m_cart = (ShoppingCart)sessiongetValue(carf)

m_cartremove(isbn)

89

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lthtm lgtltheadxtitlegtAm azoncom Shopping

C artlt titlexheadgt)out pri ntln ( ltb ody bgcolor=FFFFFF link=003399

alink=FF9933 vlink=Yrsquo996633Y text=rdquo000000rdquogtrdquo)outprintln(lta nam e= top xmdashTop of Pagemdashx a gt ) ou tp rin tln (lt pxa href=httplocalhost8080checkouthtmlximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=Yrsquocccc99Yrsquo gt)ou tp rin tln (lt tdxbrx tdgt )out pri ntln ( lt td x b r x td gt )outprintln( lt td x b r x td gt )out println (rsquo1 lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=Y2Yxfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=YleftY valign=YtopYxfont

face=verdanaarialhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=Ycccc99Yrsquogt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantity()

outprintln(lttr bgcolor=FFFFFFgt) o u tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt)outprintln(ltbrgt + itemgetItem()getAuthor())

90

outprintln(ltbrgtQuantity + itemgetQuantityO)outprintln(ltbrgt)outprintln( lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=VPOST

action=7servletDeleteFromShoppingCartVgt)outprintln(ltpgt ltinput type=hidden name=isbn value= +

itemgetItem()getISBN())outprintln(ltpgt cinput type=submit name=ditem

value=Y rsquo deletegt rsquo rsquo)outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelvetica color=000000gt)

outprintln(ltNOBRxbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fo n tx b x N O B R x b rgt )

outprintin(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantityO + lt fo n tx b x N O B R x b rgt )

outprintln( ltfontgt) outprintln( lttdgt)

i

outprintln(lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)outprintln(ltfontxfontgt)outprintln( lt td x trgt ) outprintln(lttablegt)ou tp rin tln (lt pxa href=Yhttplocalhost8080checkouthtmlYximg

src=YdYJavaWebServer20servletsimageproceed-to-checkoutgifYxagt)outprintln(ltbodygt lthtmlgt)

outflushOoutcloseQ

91

8 Detailcontentjava

ltpgt DetailContent is the servlet responsible for generating detailed information page for a book The book is identified by its ISBN Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaio import javasql import jav ax servlet import javaxservlethttp

public class DetailContent extends FIttpServlet protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String isbn = reqgetPathInfo()isbn = isbnsubstring(l) skip over rsquo rsquo

92

try String sql = select from book where ISBN=rsquo + isbn +

Statement stmt = concreateStatement()ResultSet rs = stmtexecuteQuery(sql)

create header here CreateHeader(out)

create left menu here CreateLeftMenu(out)

outprintlnfctd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintlnfctd valign=top align=leftgt)

cellpadding=0gt)

outprintln(ltbrgt)

create detailcontent here while (rsnext())

String strlSBN = rsgetObject(ISBN)toString() outprintln(lttable width=100 border=0 cellspacing=0

+ltbgtlttdxtrgt)

+ lt tdx trgt)

outprintln(lttrgt lttd colspan=3 align=leftxbgt) outprintln( rsgetObject(Title)toString()

outprin tln(lt trxtd colspan=3 align= leftxbgt by ltbgt) out println( rs getObj ec t( Author) toS tringQ

cellpadding=0gt)

outprin tln(lt trx td x i m g src=xtdgt) outprintln( lttd valign=topgt) outprintln( lttable border=0 cellspacing=0

outprintln( lt t r x td valign=topxbgtPrice )outprintln(

rsgetObject(Price)toString() + lt b x td x trgt ) outprintln(

lt trx td x b gt A v ailab ility lt b gt U su a lly lt td x trx b rgt )outprintln( lt t r x td vlign=topgtships within 24

hou rs lt td x trgt )outprintln( lt tab lextdgt)

93

outprintln( lttd align=rightgt) outprintln( lttable border=0 cellspacing=0

cellpadding=0gt)outprintln( lt trx td gt )outprintln( ltform

method=POST action=httplocalhost8080servletAddToShoppingCartgt)outprintln( ltinput

type=hidden name=isbn value= + strlSBN +outprintln( cinput

type=submit value=Add to cart )outprintln( lt tdx trgt )

outprintln( lt tab lex tdgt ) outprintln(rdquolttrgt)outprintln(lttrgt lttd clospan=3 align=leftgt ISBN ) outprintln( strlSBN +lttdxtrgt)outprintln(lttrgt lttd clospan=3 align=leftgt) outprintln( rsgetObject(Publisher)toString()

+rsgetObject(PublicationDate)toString() + lt tdx trgt )outprintln(lttablegt)outprintln(ltbrgt)outprintln(ltbrgt)

output reviewString review = rsgetObject(BookReview)toString() if (review = null)

review =DJavaWebServer20servletsreview + review

outprintln(ltbgtReviewsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(review))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprin tin (thisLine) ou t println( ltpgt)

)

icatch (IOException e)

need do something here eprintstackTrace ()

94

outprintln(ltbrgt)String comment =

rsgetObject(BookComment)toString()if (comment = null) comment = DJavaWebServer20servletscomment +

commentoutprintln(ltbgtReader Commentsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(comment))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprintln(thisLine) outprintln(ltpgt)

catch (IOException e)

need do something here eprintstackTrace ()

ou t pri ntln ( ltb rgt)

catch (SQLException e)

need to do something here

add table end tab outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt)

95

ou t pri ntln ( lthe adgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=YTOO cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d J avaW eb S erver 2 Opublic_htmlflo wer gif gtlttdgt) outprintln(lttd width=30gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyBookStorecomltigtlth2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln( lttd width=20gtlttdgt) out pri ntln ( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-1 gt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

96

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsptampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out prin tin ( ltcen tergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

eellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=Yhttplocalhost8080Avelcom eshtm lgtHom eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-1gt)

97

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=http7localhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref-httpIocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lVgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

98

9 EchoServlettagjava

import javaio import j avasql import javaxservlet import javaxservlethttp

public class EchoServletTag extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintStackTrace ()catch (SQLException e)

eprintStackTrace()

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

try Statement stmt = concreateStatementQResultSet rs = stmtexecuteQuery(select from book where title

like rsquoProgrammingrsquo)int count = 1outprintln(ltdlgt)while (rsnext() ampamp count lt 6)

outprintln(ltdtxbgt + count + )

99

String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn + outprintln(rsgetObject(Title)toString() + lt ax bgt ) outprintln(ltddxnobrgtltfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltbrgt + rs getObject( Author) toStringO) outprintln( + rsgetObject(Publisher)toStringO +

+ rsgetObject(PublicationDate)toStringO)outprintIn(ltbrgt Our Price +

rsgetObject(Price)-toStringO)

out println( lt b rx b rgt ) count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()outprintln(lttdgt lttrgt) outprintln(lttablegt) outflush() outcloseO

ii

100

10 ISBNProcessjava

ltpgt ISBNProcess This is the servlet that process the ISBN-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javax servlet import javaxservlethttp import javaio import j a vasql

public class ISBNProcess extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forN ame( sun j dbc odbc J dbcOdbcDri ver)con = DriverManagergetConnection(j dbc odbc fxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s s e tC on te n tTy pe ( tex th tm l)PrintWriter out = resgetWriter()

String[] values

String alSBN =

values = reqgetParameterValues(isbn) if (values = null)

alSBN = values [0]

String sqlStmt = select from BOOK where ISBN= + alSBN

ResultSet rs = null int count = 0

create header here bullCreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject( IS BN) toStringO

outprintln(lta href=servletDetailContent + isbn+ gt)

outprintln(rsgetObject(Title)toStringO +lt ax bgt )

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toStringO)

outprintln( +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

102

outprintln(ltbrgt Our Price +rsgetObject(rdquoPrice) toStringO)

outprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width= 100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d Uava WebS erver2 Opubhc_htmlflo wer gif gtlttdgt) outprintln(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS tore com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt)

103

out println( lttdgt) outprintln(lttd w id th= 20x tdgt ) out pri ntln( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)out pri ntln (lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) out pri ntln ( lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsp1ampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out println( ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

104

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 eellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Books lt fontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocaihost8080servletReqCollectcategorygtCategoryltfontxaxtdgt lttr gt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

105

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lttablegtltpgt)

o u t println( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

ii

106

11 PublisherDataProcessjava

ltpgt AuthorProcess This is the servlet that process the PublisherampDate-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql

public class PublisherDateProcess extends FIttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbc odbc JdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentT ype ( texthtml)PrintWriter out = resgetWriterQ

String[] valuesString namel =

107

values = reqgetParameterValues(publisher) if (values = null)

nam el = values [0]

String name2 =values = reqgetParameterValues(rdquopublication_date) if (values = null)

name2 = values [0]

String sqlStmt =sqlStmt = select from BOOK where publisher=rsquo + namel + rsquoand

publicationdate=rsquo +name2

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprin tln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toStringO outprintln(lta href=servletDetailContent + isbn

+ gt)outprintln(rsgetObject(Title)toString() + (

lt ax bgt )

108

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rs getObj ect( Author) toS tring())

outprintln(V +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

outprintln(ltbrgt Our Price +rsgetObject( Price) toStringO)

outprintln( lt b rx b rgt )

if (count == 0) (outprintln(ltdtgt No matched data found)

outprintln(rdquoltdlgt) end Glossary List

catch (SQLException e) ( create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 celipadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt)

109

outprintln(ltIMG border=0 hspace=0 id=IM Gl src=dJavaW ebServer20public_htmlflowergifxtdgt)

outprintln(lttd width=3 0 x td gt ) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS to re com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ctable w idths 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt) outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) ou t println( ltcentergt)

no

outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaim er^A gt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) out pri ntln ( lthtml gt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-1 gtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=V-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-1gt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

I l l

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitleYrsquogt T itle lt fo n tx a x td gt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(nltahref=Yhttplocalhost8080servletReqCollectisbnY gtISBNltaxfontxtdgt lttrgt)

outprindn(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdana arial helvetica size=Y -1 gt)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYgtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

1 12

12 ReqCollectjava

ltpgt This is a servlet responsible for generating search request collection page It read extra path information from URL and then according to the extra path information it generates corresponding page format Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001import javaxservlet import javaxservlethttp import javautil import javaio

public class ReqCollect extends HttpServlet

protected final String CATEGORY = categoryrdquo protected final String AUTHOR = author protected final String TITLE = titlerdquo protected final String ISBN = isbnprotected final String PUBLISHER_DATE = publisher_date

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentType( texthtml)PrintWriter out = resgetWriter()

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

)else

Create standard header CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

path = pathsubstring(l) if (pathequalsIgnoreCase(CATEGORY))

I I Create category request collect

outprintln(ltpgt)outprintln(lth3xstronggtProgrammingltstronggtlth3gt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc01gtAlgorithmsltagt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc02gtCampC++ltagt)outprintln( Delphi) outprintln(lta

href=httplocalhost8080servletCategoryProcessc03gtJavaltagt)outprintln( MFC Perl)

outprintln(software Design UML Visual Basic More)

outprintln(lth3xstronggtW eb Developm entltstrongxh3gt) outprintln(ASP Commercem Cyberculture HTML

JavaScript)

outprintln(Security Web Design XML more)

outprintln(lth3xstronggtGraphics amp Softwareltstrongxh3gt) outprintln(Asobe CAD Desktop Publishing Graphics)

outprintln(Microsoft More)

outprintln(lth3xstronggtNetW orking amp O Sltstrongxh3gt) outprintln(Linux Macs Oracle PCs SAp R3 SQL)

outprintln(TCPIP Unix WindowsampDOS W indowsNT)

out println( More)

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

1 14

outprintln(ltfont color-CC6600 face=verdana arial helvetic a size=+1 gtltbgtEnter Authorltbgtltfontgt)

outprintln(ltbrgt You can enter authorrsquos full name firstname or last nameltpgt)

outprintln(ltform method=POST action=httplocalhost 8080servletAuthorProcessY id=form 1 name=form 1 gt)

outprintln( lttable border=0gt) outprintln(lttrgt lttd valign=middle

ahgn= leftx ttx b gt A u th o rlt b gt lt ttx td gt )outprintln(lttd valign=middle align= leftx input

type=YtextY name=author size=40 value=YYxtdgt)outprintln(lttrgt)outprintln(lttrgt lttd colspan=2gt ltfont size=-lgt) outprintln(ltcentergt ltinput type=radio

name=Yauthor_modeY value=YexactY checkedgt Exact Name)outprintln(ltinput type=radio name=author_mode

value=lastgtLast First Name (or Initial))outprintln(ltcentergt) outprintln(ltfontgt) outprintln(lttdgt lttrgt)outprintln(lttrgt lttd colspan=2gt ltpgt ltbrgt lttdgt lttrgt)outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search NowY

id=submitl name=submitlgt)outprintln(cinput type=reset value=YClear Form

id=resetl nam e= rese tlxpgt )outprintln(ltcentergt ltformgt)

else if (pathequalsIgnoreCase(TITLE))

Create title request collect

outprintln(ltfont color=CC6600 face=verdanaarialhelvetica s ize= + lxbgt E n ter T itlelt bxfontgt)lsquo

outprintln(ltbrgtYou can enter the exact title or part oftitleltPgt)

outprintln(ltform method=YPOSTY action=Yhttplocalhost8080servletTitleProcessY id=form l name=formlgt)

outprintln(lttable border=0gt) outprintln(lt trxtd valign=middle

a lig n = le ftx ttx b gt T itle lt b x t tx td gt )

115

outprintln(lttd valign=middle align= leftx input type=text name=title size=40 value=xtdgt)

outprintln(lttrgt) outprintln(lttrgt) outprintln( lttd colspan=2gt) outprintln( ltfont size=-lgt) outprintln( ltcentergt)outprintln( ltinput type=radio name=title-mode

outprintln(value=exact checkedgt) outprintln( Exact Title)outprintln( ltinput type=radio name=title-mode

outprintln( value=titlewords gt ) outprintln( Title Words )outprintln(ltcentergt ltfontgt lttdgt lttrgt)outprin tln(lt trxtd c o ls p a n = 2 x p x b r x td x tr gt ) outprintln(lttablegt)

outprintln(ltcentergt)outprintln( ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln( ltinput type=reset value=Clear Form

id=resetl nam e= resetlxP gt )outprintln(ltcentergt) ou t println ( ltformgt)

outprintln(lthr noshade size=lgt)

outprintln(ltBgtExamplesltBgt)outprintln(ltULgt)outprintln(ltLIgtEntering ltbgtampquotJava Servlet

Programmingampquotltbgt in the title field )outprintln(and choosing ltemgtExact Titleltemgt finds the

book without also finding the many books)

outprintln(ltLIgtEntering ltbgtampquotJavaampquotltbgt in the Title field and choosing ltemgtTitle Wordsltemgt)

outprintln( finds all books whose title are related toltigtJavaltigt)

outprintln(ltULgt)

out printl n( lttdgtlttrgt) outprintln(lttablegt)

ielse if (pathequalsIgnoreCase(ISBN))

Create isbn request collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n ter ISBN ltbxfontgt)outprintln(ltbrgt) outprintln(ltform method=POSTY

action=httplocalhost8080servletISBNProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

a lig n = le ftx ttx b gt IS B N lt b x t tx td gt ) outprintln(lttd valign=middle a lign= leftx input

type=text name=isbn size=40 value=xtdgt)outprintln(lttrgt)

outprin tln(lt trxtd c o ls p a n = 2 x p x b rx td x trgt ) outprintln(lttablegt)

out println( ltcentergt)outprintln(ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln(ltinput type=reset value=Clear

FormV id=resetl nam e= resetlxP gt )outprintln(ltcentergt)outprintln(ltformgt)

outprintln(lthr noshade size=lgt)

outpiintln(ltULgtrdquo)outprintln(lttdxtrgt)outprintln(lttablegt)

else if (pathequalsIgnoreCase(PUBLISHER_DATE))

Create publisher date collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n te r Publisher and Publication D ate ltb gtltfontgt)

1 17

outprintln( ltbrgt) outprintln(ltform method=POST

action=httplocalhost8080servletPublisherDateProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

align=leftgtlt ttxbgt P ub lisher lt b x t t x t d gt )outprintln(lttd valign=middle align= leftx input

type=text name=publisher size=40 value=xtdgt)outprintln(lttrgt) outprintln(lttrgt lttd valign=middle

a lign= leftx ttxbgt P ub lica tion D a te lt b x ttx td gt )outprintln(lttd valign=middle align= leftx input

type=text name=publication_date size=40 value=xtdgt)outprintln(lttrgt)outprintln( c t r x td c o l s p a n = 2 x p x b r x td x t r gt )outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search Now

id=submitl name=submitlgt)outprintln(ltinput type=reset value=VClear FormYrsquo

id=resetl nam e= resetlxpgt )outprintln(ltcentergt) outprintln(ltformgt) outprintln(lthr noshade size=lgt)

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush()outclose()

)

protected void CreateHeader(PrintWriter out) outprintln(lthtmigt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding bgcolor=EEEECCgt)

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20pubiic_htmlflowergifgtlttdgt) outprindn(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(lt s tro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x stro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt)outprintln(lttd w idth=20xtdgt) ou t println ( rsquo lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

out pri ntln ( ltfon tgt) outpri ntln( ltcentergt ) out pri ntln ( ltpgt) outprintln(ltcentergt) outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)out pri ntln ( ltf on tgt) outprintln(irltcentergt) out println ( ltbodygt) out pri ntln( lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

cellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=YT00 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE= -lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

1 gtS earch B ookslt fontx stronggt)outprintln(lttdgt lttrgt)out pri ntln (lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=l-lgt)

outpri ntln(ltahref=httplocalhost8080servletReqCoilectauthorgtA uthorltfontxaxtdgtlttrgt)

120

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprindn(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=V-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln(lttablexpgt)outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

121

13 ShoppingCartjava

ltpgt This is the definition for ShoppingCart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import Javautil

public class ShoppingCart Hashtable items = null int numberOfltems = 0

public ShoppingCart() items = new Hashtable()

add BookDetails to cart param bookID isbn param book book need to be added to cart copyreturn void

public void add(String bookld BookDetails book) if(itemscontainsKey(bookId))

ShoppingCartltem scitem = (ShoppingCartltem)itemsget(bookld) scitemincrementQuantity ()

else ShoppingCartltem newltem = new ShoppingCartltem(book) itemsput(bookId newltem)

numberOftems++

param bookld isbn

public void remove(String bookld) if(itemscontainsKey(bookd))

items remove (bookld) numberOfltems - -

public Enumeration getltems() return itemselements()

protected void finalize() throws Throwable items clear()

public int getNumberOfItems() return numberOfltems

public void clear() items clear() numberOfltems = 0

123

14 ShoppingCartltemjava

ltpgt This is the definition for the shoppingcart item Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class ShoppingCartltem BookDetails item int quantity

public ShoppingCartItem(BookDetails anltem) this item = anltem this quantity = 1

public void decrementQuantity() if (quantity gt 0)

quantitymdash

public void incrementQuantity() thisquantity++

i

public BookDetails getltem() return thisitem

public int getQuantity() ( return thisquantity

i

124

15 StandardFooterjava

package servlets

import j avax servlet

ltpgt This is a server side include servlet that will format the TinyBookStore HTML footer

public class StandardFooter extends GenericServlet

ltpgtPerform the servlet service

param req The request from the client param res The response from the servlet public void service (ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the response javaioPrintW riter out = new

javaioPrintWriter(resgetOutputStream())

Format the standard footeroutprintln(ctable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(rdquoltfont s iz e = - lx a href=topgtTop of

P agelt ax fon tgt )outprintln(lttrgt) out println( lttablegt) outprintln(ltcentergt) outprintln(rsquoltfont size=-lgt)outprintln(lta href=7welcomeshtmlYgtTinybookstorecom

Homeltagt ampnbsplampnbsp)outprintln(lta href=categoryhtmlgtCategoryltagt

ampnbsplampnbsp)outprintln(lta href-authorhtmlgtAuthorltagt

ampnbsplampnbsp)outprintln(lta href=titlehtmlrdquogtTitleltagt ampnbsplampnbsp)

125

outprintln(lta href=isbnhtmlgtISBNltagt ampnbsplampnbsp) outprintln(lta href=7publisherhtmlgtPublisheramp44

Dateltagt)outprintln(ltpgt)outprintln(ltfontgt)ou t println ( ltcen tergt)outprintln(ltpgt)out println (ltcentergt )outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and

disclaim er^A gt ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln( ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

outflush()outclose()

126

16 StandardHeaderjava

package servlets

import javaxservlet

ltpgt This is a server side include servlet that will format the standard TinyBookStore HTML header The Title of the page will be set to the value of the title property

public class StandardHeader extends Generic Servlet

ltpgt Performs the servlet service param req The request from the client param res The response from the servlet

public void service(ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the responsejavaioPrintWriter out = new javaioPrintWriter(resgetOutputStream())

Get the title of the page Set to empty string if no title parameter was givenString titles[] = reqgetParameterValues(title)String title = if (titles = null)

if (titleslength gt 0) title = titles [0]

outprintln(lthtmlgt) outprintln(ltheadgt) outprintln(lttitlegt + title + lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=T00 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)

127

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src=dJavaWebS erver2 Opublic_htmlflower gi A gtlttdgt) out println(lttd width=3 O x td gt ) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyB ookStorecom ltigtlth2xstrongxtdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) out printl n ( lttd width=20gtlttdgt) out printl n( lttrgt) outprintln(lttablegt)

outflush()outclose()

128

17 TitleProcessjava

ltpgt TltleProcess This is the servlet that process the Tltle-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import j avax servlet import javaxservlethttp import javaio import j avasql

public class TitleProcess extends HttpServlet protected final String EXACT = exact protected final String OTFIERS = titleWords

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

129

String[] valuesString name =

values = reqgetParameterValues(title) if (values = null)

name = values [0]

String mode =values = reqgetParameterValues(title_mode) if (values = null)

mode = values [0]

String sqlStmt =if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where title=rdquo + name +else

sqlStmt = select from BOOK where title like rsquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString()

130

outprintln(lta href=servletDetailContent + isbn+

outprintln(rsgetObject(Title)toString() +ltagtltbgt)

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toString())

outprintln( +rsgetObject(Publisher)toString() + + rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +rsgetObject(Price)toString())

outprintln(ltbrxbrgt)i

if (count == 0) outprintln(ltdtgt No matched data found)

ioutprintln(ltdlgt) II end Glossary List

catch (SQLException e) i create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

131

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=EEEECCgt)

outprintln(rdquolttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaW ebServer20public_htmlflowergifxtdgt) outprintln(lttd w idth=30xtdgt) outprintln(rdquolttd align=left valign=center width=300gt)

outprintln(ltstronggtlth2gtltigtTinyBookStorecomltixh2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(rdquolttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln( lttrgt)outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(rdquolta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(rdquoltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

132

out println( ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) outprintln( ltcentergt) outprin tln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disciaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) S y s te m out println( LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt )

outprintln(lttable width= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y- lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost 8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

133

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lt tab lex pgt )

ou t pri ntl n ( lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

134

18 checkouthtml

lthtmlgtltheadgt lttitlegtCustomer Informationlttitlegt ltheadgtltbodygt

lt hlgt ltcentergt ltbgt Customer Information ltbgt ltcentergt lt hlgt

ltform method=POST action=httplocalhost8080servletCustomerInfoProcessgt lttable border=0gt

lttrgtlttd align=rightgtFirst namelttdgtlttd colspan=2 align= leftx input type=text name=firstname size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtMiddle initiallttdgtlttd colspan=2 align= leftx input type-text name=middleinit s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtLast namelttdgtlttd colspan=2 align= leftx input type-text name=lastname size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtEmail addresslttdgtlttd colspan=2 align= leftx input type=text name=email s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgt Account pass word lttdgtlttd colspan=2 align= leftx input type=text name=password s ize= 40x tdgt

lttrgtlttrgt

lthrgtlttrgt

lttablegtltbrgt

ctable border=0gtlttrgt

lttd align=rightgtCredit card numberlttdgtlttd colspan=2 align= leftx input type=text name=creditcard s ize= 40x tdgt

lttrgtlttr valign=topgt

135

lttd align=rightgtCredit card typelttdgtlttd align=leftgtltinput type=radio name=cardtype value=visagtVisaltbrgtltinput type=radio name=cardtype value= mastercard gtMasterCardltbrgt lttdgtlttd align=leftgtltinput type=radio name=cardtype value=bluebirdgtBluebirdltbrgtltinput type=radio name=cardtype value=fishergtFisherltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtCredit card holderlttdgtlttd colspan=2 a lign= leftx input type=text name=cardholder s ize= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCredit card expire date (mmddyy)lttdgtlttd colspan=2 align= leftx inpu t type=text name=expiredate size= 40x tdgt

lttrgtlt trx trgtlt trx trgtlttr valign=topgt

lttd align=rightgtSelect shipping methodlttdgtlttd align=leftgtltinput type=radio name=shipping value=upsgtUPSltbrgtltinput type=radio name=shipping value=expressgtExpressltbrgtlttdgtlttd align=leftgtcinput type=radio name=shipping value=normalgtNormalltbrgtltinput type=radio name=shipping value=abnormalgtAbnormalltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtReceiver Namelttdgtlttd col span=2 a lign= leftx inpu t type=text name=receiver size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtAddresslttdgtlttd colspan=2 align= leftx input type=text name=address size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCitylttdgtlttd colspan=2 align= leftx inpu t type=text name=city size= 4 0 x td gt

lttrgtlttrgt

136

lttd align=rightgtStatelttdgtlttd colspan=2 align= leftx inpu t type=text name=state s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtZipcodelttdgtlttd colspan=2 align= leftx inpu t type=text name=zipcode size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtPhonelttdgtlttd colspan=2 align= leftx input type=text name=phone size= 40x tdgt

lttrgtlttablegtlt b rx b rgtcinput type=submit value=Process name=actiongt

ltformgt

ltbodygtlthtmlgt

137

APPENDIX C

Screen Display of the Test

138

mmm File Edit View Favorites T o d s Help

^ Jit j j ^ LJ U 3) ~ pound=J _Am Back - S top Refresh Home j Search Favorites History Mait Print Edit

Links gtgt Address |4S ] httDVIocalhost808QAvdcorne shtml

TinyBookStore com

Welcome to the TJnyBoakStoro com

F i v e H o t B o o k s

1 T h e C + + Programming LanguageU s u a l l y s h i p s i n 24 h o u r s

B j a r n e S t r o u s t r u p A d d i s o n - W e s l e y Pub Co 1997 Our P r i c e 31 47

2 - P r o g r a m m i n g V i s u a l C + +U s u a l l y s h i p s i n 24 h ou r I I

Local intranet

Search BooksHorne

Category

Author

Title

ISBNPublisherDate

3 iigt60

3 1 S earch T inybooksloiecom - Microsoft Internet Explorer

139

T inyB ookStorecom - Microsoft Internet Explorer

j File Edit View Favorites lo o k Help

q a a H 3 1 d B ack S top R efresh Home S earch Favorite History j M aJ Print

Links gtgt A ddress httpV localhost 308QoryleV PetailCorterV 020i8SC l4

MM

Edit

Search Books

Home

Category

Author

Title

ISBN

PublisherDate

TinyBookStore com

The C++ Programming Languageby B j a r n e S t r o u s t r u p

0

ISBN 0 2 0 1 8 8 9 5 4 4 A d d i s o n - W e s 1e y P ub Co 199 7

Reviews

P r i c e 31 47A v a i 1ab i 1i t y U s u a l 1 ys h i p s w i t h i n 24h o u r s

Aic t o c a r t

ijgJ Local intranet

140

^ | I myBook5torecom Shopping Cart - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

[v] I ^ -J JB ack - Stop R efresh Home S earch Favorites History lsquo Mail Print

Links A ddress 0 1 h ttp localhost8080servetA ddT oShoppingCart ~3 ltGdeg

Shopping Cart Item s Price

The C++ Programmi ng LanguageB j a r n e S t r o u s t r u p Q u a n t i 1 7 1

Price $ 3 1 4 7 Subtotal $ 3 1 4 7

d e l e t e

Total 31 47

Customer Information Microsoft Internet Explorer

File Edit View Favorites lo o ls Help bull _

bullgt 3i 4 n j j d a 31Back ~-j Stop- R efresh Home S earch Favorites History j Mail Print Edit

Link gtgt j Address ] j j h ttplocalhost SOSOcheekoot html

EMH1

~3

Customer Information

First name jFang

Middle initial |a

Last name Xiao

Email address fxiaomitecnet

Account password pooooc

0 1 Done

Credit card number 1234567891234567

Credit card type VisaC MasterCard

C Bluebir d C Fisher

Credit card holder jr ong Xiao

ard expire date (mmddyy) J010102

Select shipping method UPSO Express

O Normal C Abnormal

J |sect Local intranet

141

lt2] Order List - Microsoft Internet ExplorerFile |d i t View Fayotites lo o t Help

^ 3 ^ S i l S - j S tep R efresh Home Search Favorite History Mail Print h-

HFte-LLinks A ddress I g ] httplocalhost8030servletCustemeilrifoProcess 3 ^Go

Your order reads as followsE - M a i l A d d r e s s f x i a o

F a n g X i a o

ship to

T e l

11 e m s

pound] Pc

10821 W e s t e r n P l a z aOmahaME6 8 1 5 4

( 4 0 2 ) 4 9 6 - 7 5 7 0T i t l e T h e C++ P r o g r a m m i n g L a n g u a g e Q t y 1 P r i c e 31 47 S u b t o t a l 31 47

| a [ Local intianet rsquo

l i

T inyB ookSloiecom - Microsoft Internet Explorer

T 7 ~ J iii 4 a i t Vi 1+ a Si

5 E

P r i te i+ A d d ie r I ig l httplocalhot8080ervletReqCollectauthor

S e a r c h B o o k s

Horne

Ca t e g o r y

A u th o r

Title

ISBN

P ublishe r Date

jS 1 D one

TinyBookStore com

fc t i t e r l i t n o rYou can enter authors full name first name or last name

A u t h o r |sCOtt

O ExactName amp Last F irst Name (or Initial)

T itiv b o o k s to re c o m H o a e | C a te g o ry | A u th o r | T itle | ISBN | P u b lish e r D ate

C opyright and disclaim ercopy 1999-2001 F an g Xiao

T op o f P f

|sect g j Local intranet

142

linyBookStore^com- MiciosoFUnteinet ExplorerFite Edit View Favorites Tools Ftelp

IIl4 rsquojO IjjlI - 3 -Upraquo 8 a c k ltbullltbullbullltlaquo Stop R efresh Home S earch Favorites History Mail Print 1

| Links 1 Address j raquo 3 http7localhost8CI80servletAuthorProcess

l - i f l |x |

S e a r c h B o o k s

Home

C a t e g o r y

Ti t le

ISBN

P ublishe r D a te

D o n e-

TinyB o okStore com

1- Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

I G aleampory I A utho t | I jt te | ISBN | PubH shei^D atg

i t and disclaim erreg 1999-2001 F ang Xiao

Top of

l i Local intranet

j T iny8ookStorecom - M icrosoft Internet Explorer

Fite Edit View Favorites Tools Help

4- 5 ni M m ~ltpound C r =gt 2f|L i p | | | | | iAdiiill|^Thttp7localhost8080seivletD etailContent0201924889

U 3

S e a r c h B o o k s

H ome

C a t e g o r y

A u th o r

Title

ISBN

P u b lish e r P a te

TinyB o okStore com

Effective C++b y Scott Meyers

ISBN 0201924889 Addison-Wesley Pub Co 1995

R eviews

This is the review of Effective C++

R eader Comments

Price 3795 Availability U sually ships within 24 hours

Add to iosil

IIH LdcSiiihttahdt

143

l inyBookStorecom Shopping Cart - Microsoft Internet Explorer

4- -- _ t lS M JJ ltpound I 7 r mdash2--I or- Stop R efiesh Home S ea rch Favorites History Wait PrintBach

Links Y 1^ddtessj-^1 httDvVlocalliostiBOBOyservletMddToShoppinqCart 73 ^

0

Shopping Cart Item s

Effective C + +Scott Meyers Quantity 1

0 1 Done

delete

Price

Price $ 3 7 9 5 Su b to ta l $ 3 7 9 5

Total 3 7 9 5

IB~ht Locai intranet

bull 3 TinyBooKGIoFooom M icrosoft Internet Cxplorcr

Fite Edit View Favorites Tools Help

4- -4gt Lfl 4 r amp J J lt$ i icirsquo s J ~lAB ack Ti(^poundprV aTdV iS^Stop-T SfSjefre^ptr I i - M t s s j r y rvlih- i JPopSnr -JE

i i i l l l P I I I ^ I i l l ] httplocalhost8080servletR eqC ollectauthor

G3SJ

7 ^ Go

S e a r c h B o o k s

H om e

C a t e g o ry

A u th o r

Title

ISBN

Eytoiisiier Date

101 D one

T i n y B o o k S t o r e c o m

E n te r AuthorYou can enter authors full name first narne or last name

A u t h o r jCraig Larmen

E Exact N ante O Last F irst N ame (or Initial)

Search Now 1 Clear Form

I C ategory | A u th o r | j j t l s | ISBN |

C opyright and ctiiclali[er copy 1999-2001 F an g Xiao

T o p o fP ag e

^tDpcafihttangfe-

144

gj TinyBbokSlorecom - Microsoft Internet ExplorerFile Edit View F a v o n te s - Pools

4-1 4 gt_poundj Q Jl3S top R efresh Home S ea rch Favorites History Mail PrintCacl-

lsquo Unko A ddress j ig ] httplocalhostSOSCiservletAuthorProces 71

S e a r c h B o o k s

Home

C a t e o o r v

A u th o r

Tit le

ISBN

P ub l i she r D a t e

Titty Bo okStore com

1 Applying UM L and Pattern Usually ships in 24 hours Craig Larmen Prentice Hall 1997 Our Price 450

T im booksto re com Home | C ateg o ry | A u th o r | Title | I3BM | Publisher P a ts

C opyrigh t and disclaimer copy 1999-2001 F an g X iao IIg ] http7localhost 8080eopyright html Local intranet

7 j T inyBookStorecom - Microsoft Internet Explorer

^ 03 4 31 0 i -_r _j _T B ack ~j~ S top R efresh Hom e Search Favorites History Mail Print Edit

I Links Addiess AocalhcistiiiOciOserv-letCctailConfent0137488S07

u m m

S e a r c h B o o k s

HorneC a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r Date

Tiny Bo okStore com

Applying LOVIL and Patternby Craig Larmen

0 Price 450 Availability TJ sually ships within 24 hours

ISBN 013748880 Prentice Halil 997

R ev iew s

Tins is the review o f Applying UML and Pattern

R ea d er Com ments

Add to cart

01ll iPdSSIihirSdety

145

3 TinyBookStorecom Shopping Cart bull Microsoft internet ExplorerFile Edit View Favorites Tools Help

vJBeck

JStop Refresh

4Home

H Si - iS- -=dSearch Favorites History Mail Pnnt

Links rdquo Address jlti] httpVlocalhostBOSOservletAddToShoppingCart 3 ^ Gc

r o 1

Shopping Cirt J toms Price

A pplying UML and PatternCraig Larmen Quantity 1 Effective C++Scott Meyers Quantity 1

l i l le t e

delete

Price $ 4 5 0 Subtotal $45 0

Price $ 3 7 9 5 Subtotal $ 3 7 9 5

Total 82 95

d f g a j Local intranet

146

lt3 TinyBookStoiecom - Microsoft Internet ExplorerFile Edit View Favorites Io o ls Help

gt j i 4 a - a i [j JB ack Forward Stop Refresh Home S earch Favorites Histeiy Mail Print Edit

Links Address ] pound ] hiipVonahost803CeerveirsquoReqColectlsquoauthor

0 1 i

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r D a te

Tiny Bo okStore com

You can enter authors full name first name or last name

A u t h o r jJeff

O Exact N ame Last First N ame (or Initial)

Search Now i Clear Form

T inybookstorecotti H oinf | Category | A trthor | Title j ISBN | Publisher Date

Copyright and disclaimer copy 1999-2001 Fang Xiao

Top of Page

M Local intraZl

m TinyBook Stote com - Microsoft Internet Explorer

Fife Edit View Favorites Joo ls Help

ISregBack Stop Refresh Home S earch Favorites History Marl Print c

Lirrks Address samp] httplocalhost8080servletAuthorProcess ~z ^ Gc

S e a r c h B o o k s

H ome

CategoryA u th o r

Title

ISBN

P u b lishe r D a te

i M

TinyBookStore com

1 Progi aimning Windows bullwith M FC Usually slaps in 24 hours JeffProsise Microsoft P ress 1999 Our Price 4799

jnybo-okstorscom Homo | Category | A u th or | Title | ISBN | Publisher P a h

C opyright and disclaijRief copy 1999-liOO1 FangX iao

Loccii intranet

147

148

m I myUookSlorecom - Microsoft Internet ExplorerFile- pound d it View Favorite T ools Help

^ J ] 4 U J j j =jgt Stop R efresh Home S e a rc h Favorites History i Mail Print EditBack

Links AddressilaquojigThttplocalhost5 i380ser4eM D etailContent157231 pound350

rfgKxi

ldquo3 gt6deg

S e a r c h B o o k s

HorneC a teg o ry

A u th o r

Ti tle

ISBN

P ub l i she r D a t e

TinyBookStorecom

Programming Windows with M FCby JeffProsise

0

ISB N 1572316950 Micro s oft Pre s s 19 9 9

Price 4799 Availability Usually ships within 24 hours

R e N ew s

This is the review of Programming Windows with MFC

R eader Comments

A dd to cart

D one i jh j Local intranet

lt 3 TjryBook S tore com Shop p in g Cart - M icrosoft Internet Exolorer

File Edit View f a nute T ools Help

r 1B ack

J 3 Q 0J amp poundlr - Jlilip isS h lA ld rS s httpy |ocalhost8U 80AervletA ddToShoppingCait TSIIlli

Shopping Cart Item s

Program m ing W indow s w ith M F CJeffProsise Quantity 1A pplying UML a n d PatternCraig Larmen Quantity 1 E ffective C++Scott Meyers Quantity 1

d e le te

d elete

d elete

Price

Price $ 4 7 9 9 S u b to ta l $ 4 7 9 9

P rice $ 4 5 0 S u b to ta l $ 4 5 0

Price $ 3 7 9 5 S u b to ta l $ 3 7 9 5

Total 1 3 0 9 4

^ h W h e iM

S s i Local intranet

149

File Edit View Favorites lo o ls Help n4- -0 iS - M L U

Back Stop Refresh Home Search FavoritesJ

History I3 H H H B H H H BMail Pm Edit

Links rdquo Addrecs |s] hHplocalhogt5t8080servletReqCollectcategorii ^_____ bulllt bullbull llilltllll

Search Books

Home

Category

Author

Title

ISBNPublisherDate

TinyBookStore com

P r o g r a m m in g

AI g o r i t Lins CampC++ D e l p h i J a v a MFC P e r l s o f t w a r e D e s i g n UML V i s u a l B a s i c M o r e

Done

Web D e v e lo p m e n t

ASP Commercem C y b e r c u l t u r e HTML J a v a S c r i p t S e c u r i t y Web D e s ig n XML more

G r a p h i c s amp S o f t w a r e

Asobe CAD D es k t op P u b l i s h i n g G r a p h i c s M i c r o s o f t More

I J J ig Local intranet

150

finvBookStorecom - Microsoil Internet Explorer - j g j x

j Fite Edit Jfiew Favorites lo o ts Help

bull j 5 a i B ack lsquolti S top Refresh Home S e a tc h Favorites History Mail Print Edit

Links 1 Address |ltg] hitpVocalhostl-i030seryletCateciofyPreceigtVc03 ^ | g

S e a r c h B o o k s

Home CategoQ

A u th o r

Title

ISBN

Publishe r D a te

TinyBookStore com

1 Core Ja v a 2 Usually ships in 24 hoursCay S Horstmaun Prentice Hall 1999 Our Price 2579

2 Ja v a S erv let Programm itig Usually ships in 24 hoursJason Hunter i O Reilly 1993 Our Price 1977

3 Ju st J a v a 2 Usually ships in 24 hoursPerter van der Linden Prentice Hall 1999 Our Price 3149

Tinybookstorecom Home | C ategory | A u th o r | T itle | IbBN | Publisher D ateloRoIEage

n g Local intranet

ta

151

41 Tinytfookbtorecom - Microsoft Internet ExplorerFile gdit y iew Favorites JLools Help

1 ^ hgt a a a amp a j ri i - 3 bull a Back Forward Stop Refresh Home S earch Favorites History Mart Print Edit

lisLinteslsii Address ji^]h ttp localhost8D 8o7serv letD etailC ontent0130319336

M i

3 f^Gc

S e a r c h B o o k s

Homec a t e g o r y

Tiny Bo okStore com

Core Java 2by Cay S Horstmaun

El

ISBN 0130819336 Prentice H alil999

Reviews

This is the review of Core Java

R eader Comments

Price 2579 Availability U sually ships within 24 hours

I Add to car

S ] Done S i Local intranet

TinyBookStorecom Shopping Cart - Microsoft Internet Explorerfel11 File Eefit View Favorite l o o k H e lp

tljH|V| 4 a 3 j 09 c T J

Stop Refresh Home S e a rc h Favorites History j Mail Print

jiiLihkIi87js ^ B ie s S ij^ ] http Z localhost8080servletiddT oShoppirigC art

B I B

3= i

Shopping Cart Item s

Core Java 2Cay S Horstmaun Quantity 1

Icopy

t i l

delete

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Total 2 5 7 9

sal Local intranet

152

a TinvBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites J o o lr Fjelp

NBack

amp Id b iStop Refresh Home

ISearch Favorifes History - Mail Print Edit

Links gty I Address [ jg l httplocalhost8080servletD etailContent156592391 x d

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

T i t le

IS B N

Publisher Date

ampJ Lrl e

Tiny Bo okStore com

J a v a S erv le t Piograitmmigby Jason Hunter

a Price 1977 Availability XT sually ships within 24 hours

ISBN 15659239 lx O Refflvl998

R e N ew s

In this brand-new third edition of Java Servlet Programming author Bjame Stroustrup the creator of Java presents the full specification for the Java language and standard library a spec that will soon become the joint ISOANSI Java standard

j ~2J Local intranetm

dH T iny8ook5torecom Shopping Cart - Microsoft Internet Explorer

File pound d t y iew Favorites Io o ls HelpB H

a $ a i a a -Stop Refresh Home S ea rch Favorites Hi lory Mjl

3- lsquonr I

| j | i | H | g i | i | i d ^ | | | | l Q httplocalhost80S0servletAddToShoppirigCart J P

m

Shopping Cart Item s

Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d e le te

d e le te

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Price $ 1 9 7 7 S y b to ta l $ 1 9 7 7

Total 4 5 5 6

I O I

aiil

153

Lustomer Information - Microsoft Internet Explorerpoundite pounddit View Favorites Xoo|s Help

v- _) _ l 4 J I VB ack - Stop R efresh Home Search Favorites History Mail

Links gty] A ddress ] j i l h ttD localhost8080checkouthtm l

F -iVj ~f

l l i l i i

C u sto m er In fo rm a tio n

First name jFang

Middle initial lA

Last name fXiao

Email address jfxiao m itecnet

Account password jxxxxx

Credit card number ]1234567B91234567

Credit card type C VisaC M asterCard

C Bluebird O Fisher

Credit card holder jFang Xiao

Credit card expire date (mmddyy) jo 10102

Select shipping method c u p sC Express

NormalAbnormal

0 ] D one Local intranet

poundpound Order List - Microsoft Internet Explorer

s

Back

Li il raquo

Yiew Favorites l o o h Help

bullV Y lJ j X I T- lty S to p Refresh H o m e

amp 1 3 J - jrS earch Favorite History lt Mail Print

fcesssaampl httplocalhost8080servletCustom erlnfoProcess

Y o u r ord er reads as fo llow sE-Mail Address 6daomitecnet

Fang Xiao

ship to

Tel

Items

12345 Western PlazaOmahaNE68154(402) 123-4567

Title C ore Java 2 Qty 1 Price2579 Subtotal 2579

Tide Java Servlet ProjammingQty 1 Pnce 1977Subtotal 1977 Total4556

ffl|b ] Done kl Local intranet

154

mammmm 1

File Edit View Favorites lo o ts tieip

E=cl i u F t l H -n e -i i rdquo F j-oiilsquoiBillHistory lsquo gt1 ll Print Edit

iiiiiiiiiiiiiiiiiirsquo Links Address j-copy] http localhust 8080servletReqCollectisbn J

TinyBookStore com

Search Books

Home ISBN

Author

Title

IS B N

S e a r c h Hew C le a r Form

PubnsheuDate

Top o f PageITnjrbooksj^ore^ com Horne I C a te g o rv | ^ i t h o r | T i t Ie I ISBN | Publisher Date

- g ] http locdlho-st SOSOwelcome shtrnl

TinvBookStorecom - Microsoft Internet Exploier

poundaj Local intranetId

| File Edit View Favorites Tools Help

i -e -e u u r5_ _ _ a u ^ 4 - a a j Back Forward S top Refresh Home S earch Favorites History Hail Print Edit

Links A d d re ss ^ hitp rsquoIdcanc-stEtnSOservlltlsquoF-aqZoll-~ntispn z raquo h

TinyB o okStore com

S e a r c h B o o k s

Horne

A utho r

T itle

ISBN

P u b lish e r P a t e

fcntar ISBN

I SB H 1565922840

|sectplli||pbw||l| IliM M pifiillj

T rgU onL cirrti -nr Kini- | Cgtgpound-gg | Agithor | Title | ISBN f uhhe-rt Pete

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top o f Pag e

aipoundbull] O o n e Local intranet

155

File Edit View Favorites Tools Help

HUTinyBookStorecom - MicrosoH InternetExplorer

B ad-J J A J d -2r =3

Stop R efresh Home S e a rc h Favorites History Mail Print

Links ygt A ddress j ^ ] httpVlocalhost8080servletrsquoISBM Process

S e a r c h B o o k s

Horne

C a t e g o r y

A u th o r

T itle

IS B N

Pub l i she r D a t e

TinyB o okStore com

1 Learning Perl Usually ships m 24 hours Randal L Schwartz O Reilly 1997 Our Price 1997

T in vh ooksto re c o m H orne | C at ego tv | A u th o r | Title | ISBM | Publisher D ate

C opy rig h t a n d d isclaim ercopy 1999-2001 F a n g X iao

0 ] Done

yen

ighj Local i

TinyB ookStoiecom - Microsoft Internet Explorer

Erie Edrt View Favorites- lo o ls Help

-s pound] 4 pound1 jLl icArdquo =pound 2 S top Refresh Home S earch Favorites History Marl Print Edit

iilHI

NpBack

httpyiocalhostSOBOservleMDetailContentAI 565922840 ~T] Cm

Tiny Bo okStore com

S e a r c h B o o k s

H o m e i

C a teg o ry

A u th o r

T itle

ISBN

Publishe r D a te

Learning Perlby Randal L Schwartz

I ^

ISBN 1565922840 O Reillvl997

Price 1997 Availability U sually ships within 24 hours

Reviews

This is the review of learning Perl

Reader Comments M0 ] Done lsquofR | Local intranet

156

IHHHHHI _ I f f i x |

File E d t yiew Favorites J o e ls H elp 11v- -__ l

Back ~ rc Stop R efresh Home S earch Favorites HistoryJ rMail

HH1111Pgtnt

Links A ddress | ] http7docalhost8030servleM AddToShoppingCart 3 tgt G o

O S III

Shopping Cart Item s

Learning PeriRandal L Schwartz Quantity 1

delete

Price

Price $ 1 9 9 7 Subtota l $ 1 9 9 7

Total 1 9 9 7

s

Done Local intranet

Eg W illi 1 lttMM41 i H H p n B n 1 0 1 x i

Fite Edit View Favorites Toots Help E H

1$3 L plusmn J8ack Forward Stop Refresh Home Search Favoutes

4History i

- i V -=JMail Print

-Edit

71 Address http7localhost8080lsquoservletFleqCollecVisbn I l f i l l l

TinyBookStore com

Search Books

Home

C ateao rv

Author

Title

ISBN

Publisher D a te

Enter ISSN

i s bit [l 565921496

Search Now I Clear Form

Tinybookstore o n Home | Category | A uthor | Titb | ISBN | Publisher Dte

Copyright arid disclaimer copy 1999-2001 Fang Xiao zl amp j Done Js J Local intranet I

157

H H H r f e i x i File Edit View Favorites Lools Help

- J j j j ] JBack Stop Fiefresh Home Search

J JFavorites-

-J i C rHistory Mail Print

111111811i n

r Links wj i Address |reg] http docalhost 8080servletIS8N Process

S ea rch B ooks

Home

Category-

rdquo A u th o r

T i t l e

IS B fi

P u b l i s h e r D a ta

Tiny Bo okStore com

1 Programtning Perl Usually ships in 24 hours Larry Wall O Reilly 1997 Our Price 2397

T o o k s t o r e c o m H P in e | C a t e g o r y | A u t h o r | Till | IS B N | P -ubtu-hai D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g X ia

T o p o f P a g e

zlamp2 Done Local intranet

158

lt3 l mytfookSlorecom - Microsoft Internet ExplorerF3e Edit View FavoMes lo o ts Help

Back3 U Si S rsquo IStop Refresh Home lt Search Favorites History Mail Print Edit

httplocalhost8080servletDetailContent15S5321496 j3

Search Books

Horns

Category

Author

Title

ISBN

Publisher Date

Done

TinyB o okStore com

Programming Perlby Larry Wall

0 Price 2397 Av ail ability U sually ships within 24 hours

ISBN 1565921496 O Reillyl997

Reviews

This is the review of Programming Perl

Reader Comments

Add to cart

l or=lM

159

Tm vBookSlorecom Shopping Cart - M icrosoft Internet Explorer

i Fite Edit View Favorites lo o k Help

^ Beck R efresh Home

ampS earch Favorites History j Mail Print

E Links I Address ] pound http localhost 8080servletA ddT oShoppingCart rsquo ] O rai

i O

Shopping Cart Jlems

Learning Peri Randal L Schwartz Quantity 1 Program m ing PeriLarry W all Quantity 1

delete

d e le te

Price

Price $ 1 9 9 7 S u b to ta l $ 1 9 9 7

Price $ 2 3 9 7 S u b to ta l $ 2 3 9 7

Total 4 3 9 4

3SJ Done j | s [ Local intranet

160

m m mmmHi mmmHHHHHi1 File Edit View Favorites Tools Help

^ - J J -ih Ji - j| B a d Forward Stop Refresh Home S earch FavoritesHIH ctuv Mjl Print

IHIlllliEd

B l

MbfeifcssfjP Address httplocalhost8080servletFleqCollectpLiblisher_date_ ___ ________ ___________ _ bull bull bull bull_________________ Zi T gt 6 o

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

Title

ISBN

Publishe r P a t e

S ] Done

TinyBo okStore com

T rsquov -

Publisher

sind IPpiIs1iclaquoifciori OsifiC

jAd cl i so n-VVe oI e y Fuo C o ~

P u b l i c a t i o n D a t e 1U97

Search Now Clear Form

T inybookstore com Home | C ategory j A u tho r j I itle | ISBN | Publisher Ds

C opyright and disclaimer copy 1999-2001 F an g Xiao

T op o f Page

g a l Local intranet

161

lt|j TinyBookStoiecom - Microsoft Internet Explorerlsquo Erie Edit View Favorites lo o ls Help

v-1 Q rij - 3 rsquo- a u -=pound Ci Back s lsquoi i 1 Stop Refresh Home S earch Favorites History Mail Print i

jL inks i A ddress 0 1 http7localhost8Q80servletPublisherDateProcess

EMM

3

S e a r c h B o o k s

Home

C a t e g o r y

Author Title

ISBN

Publisher D a te

TinyBookStore com

1- Algorithm s in C Usually ships in 24 hoursRobert Sedgewick Addison-Wesley Pub Co 1997 Our Price 4495

2 The C++ P rogr amming L anguage Usually ships in 24 hourBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

3 Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

4- U M L D istilled Usually ships in 24 horn sMartin Fowler Addison-Wesley Pub Co 1997 Our Price 2995

Done | s j L ocalm

TinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorites l o o k Help

Backamp 3 $ -Q 3 3 AJStop Refresh Home S earch Favorites History Mail Print Edit

Lipikkigt7i Ajddr$esjhttpv7localhost8080-servletDetailCoriterit0201314525

m

3 rgtGc

S earch B ooks

Horne

A uthor

Title

ISBN

Publisher D a te

Tiny BookStore com

Algorithms in Cby Robert Sedgewick

S

ISBN 0201314525 Addison-Wesley Pub Co 1995

Reviews

This is the review of Algorithms in C

Reader Comments

Price 4495 Availability U sually ships within 24 hours

Add to cart

0I reg S a i t^ s a l intranet

162

File Edit View Favorites lo o ls Help

2 ^ iVi ^ ^ t j j B ack gt Stop Refresh Home S ea rch Favorites History ||

- i -Mail Print

WB0BUBSSSI B ifl

Links ygt Addrese |isect ] httpvVlocalhostSOSChservletAddToShoppingCart

Shopping Cart Item s

A lgontfim s in CRobert Sedgewick Quantity 1

0 1 D one

delete-

Price

Price $ 4 4 9 5 Subtota l $ 4 4 9 5

Total 4 4 9 5

Local intranet

163

^ l inyBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

ls31

3 bullrsquo -I- _J _jj - j i_ 3 - j rdquo -= $ ABack Forward Stop Refresh Home Search Favorites History Mail Print Edit

Links rdquo Address 6 J http Vlocalhost SOSOAervletR eqCollectpublisher_date j ^G

Search B o o k s

Home

categoryAutho r

Title

IS B N

Publi sher D a te

TinyBookStore com

liter Publisher and Publication Date

P u b l i s h e r Wrox Press Inc

P u b l i c a t i o n D a t e ]1

Search Now j Clear Form

T invbookstor ecotnHomg | Category | A uthor | Title | ISBN | Pu b lish e rP a t

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top of Page

zD one Local infra

m TinyB ookStoiecom - Microsoft Internet Explorer

R e Edit View Favorites Tools Help

- -i 13 4 St 2J amp t r - JHB-1

fff ij if P S | Address |sjpound~| httpVlocalhost8030servletPublisherDateProcess

S e a r c h B o o k s

Home

C a t e g o r y

A utho r

T itle

ISBN

Publisher D a te

0 ] Done

TinyBookStore com

1 Beginning Visual Basic 6 Database Programming Usually ships in 24 hour John Connell W rox Press Inc 1998 Our Price 3199

2 Befmiung Visual Basic 6 Usually ships in 24 hours Peter Wright Wrox Press Inc 1998 Our Price 3199

T inybookstore com H orae | C ategory | A u thor | Title | ISBN | Publisher Date

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top o f Fas

Local intranet

64

| File Edit Yiew Favorites T ook Help

i A - + - - a S 3 rsquo reg - pound J -3 Back ldquo d Stop Refresh Home Search Favorites History

- vMail Print

i

Edit

IllplBlllll________ g - M

isisfcinbsijp Addre s | g ) httplocalhost8080servletDetailCoritent1861001061 3 Gdeg

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

T itle

ISBN

Publishe r D a te

TinyBookStore com

Beginning Visual Basic 6 Database Programmingby John Connell

a Price 3199 Availability U sually ships within 24 hours

ISBN 1861001061 Wrox Press Inc 1998

Reviews

This is the review of beginning Visual Basic 6 Database Programming

Reader Comments

A d d to c a n

S] pone Local intranet

m u i

lillllEHl ^ bdquo A 3 2tl 4 t M liJ i

Back Forward Stop Refresh Home Search Favorites3

History 4 _ r

M j 1J

Print EditiSillilillllS

httplocalhost8080servletReqCollecttitle

S e a r c h B o o k s

Home

C a t e g o r y

Author

Title

ISBN

Publisher Date

TinyB o okStore com

Enter TicleYou can enter the exact title or part of title

T i t l e C++

O Exact Title Title Words

Search Now Clear Form

Example

bull Entering Java Servlet Programming in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title are related to Java _li

165

lt5 TinyBookStorecom - Microsoft Internet ExplorerFite Edit View Favorites lo o ts Help

Back Stop Refresh Home S earch Favorites History Mail Print

Links gty Addiess http-localhost8080servlet7TitleProcess

i|p1

I

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

Publi sher IS a t e

TinyBookStore com

1 The C++ Programming L anguage Usually ships in 24 hoursBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

2 Effective C+-F Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

3 Programttung Visual C-H- Usually ships in 24 hours David J Kmglinski Microsoft Press 1998 Our Price 3999

T m y h o o k s to e co m H o m e | C a te g o ry | A u th o r | T itle | ISBH | P u b lish er D ate

http iocalhost SOSOservletFleqCollectcategary

T op of P age

~hj Local intranet

bull a TlnjpBflOkStOfecom - Microsoft Internet Explorer

File Edit View Favorite Pools Help

0 3 4 S l i 3 O - J J i t of Stop Refresh Home S earch Favorites History - Mart Print Edit

HBack

i i i i lS i lB i I i f f id i l f f lH Q http Vlocalhost 8080AervletD etailContent1572318570

EEEI

J

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b lis h e r D a f t

TinyBookStore com

Programming Visual C++by David J KrngHnski

[Hj

ISBN 1572318570Microsoft Press 1998

Price 3999 Availability Usually ships within 24 hours

R e v ie w s

This is the review o f Programming Visual1

Reader Comments

Add to cart

if Local intranet

166

mm| File pounddtt View Favorites Jo o ls Help

c J J j j mdash JB ack - J Stop Refresh Home S earch Favorites History

- _ i -M u

J tPrint

t e t a f e w P A ddress | ^ ] httplocalhost8080servletAddToShoppingCart zl -lt1gtSo

Shopping Cart Item s

Programmeng Visual C + +David J Kmgbnski Quantity 1

delete-

Price

Price $ 3 0 9 0 Sub to ta l $ 3 9 9 9

Total 3 0 9 9

D one ^aj Local intranet

TinyBookStorecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

vHBack-

-J a 4 -a si fi- 3 aStop R efresh Home S earch Favorites History j Mail Print- Edit

Links gty A d d re s sL ^ ] hrtpWlocalhostSOSOservleVFIeqCollectAitle

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

ISBN

Pub l i she r Date

TinyBookStore com

Enter TitleYou can enter the exact title or part of title

Title Distil I nrfExact T itle V T itle W o rd s

Search Now | Cle ar Fo rm

Examples

rpound] Done

bull Entering Java Servlet Programming11 in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title arei date 11 j Java JZJ

167

a TlnyBA5kSioiecom - Microsoft Internet Explorergt 0e Edit ifiew Favorites Jock Jd lp

a a amp -a tii j k i Back s - Stop Refresh Home Search Favorites History Mail Print

liilP raquo httpiVlocalhostSOSOservletTitleProcess

E M 3

ldquo3 rgt-

S ea rch B ook s

Horne

C a t e d o r v

A utho r

TiUgt~ ISSN

Publi sher D a te

Tiny BookStore com

1- TJML D istilled Usually ships in 24 nowsMartin Fowler Addis on-Wesley Pub Co 1997 Our Price 2995

| C s rg g o ty | A u th o r | T itle | IStBH I P u b lis h e r D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g Xiao

-jg Local intranetS3

m n ^ i l a i i x l

File Edd View Favorites Joels- Help M Mi r J lt 3 L h f 4 - 0 lt 3

Back i t Stop Refresh Home S earch Favorites History Mail9

PrintM

Edit

Links raquo A ddress j | i ] http do ca lh o d 1030N m letDetailContenr0201325632 Mimas

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

Title

IS B N

Publisher Date

Tiny BookStore com

TJML Distilledby Martin Fowler

0

ISBN 0201325632 Addison-Weslev Pub Co 1997

Reviews

Tins is the review of The UML Distilled

Reader Comments

Price 2995 Avail abilityTJs u ally ships within 24 hours

Add to c a r t

0 3S i] Done |g^iLnealiihfrregei

TinyBookStorecom Shopping Cart Microsoft Internet ExplorerFile Edit View Favorites Jo o ls HetP

IBiiiBlll l l lHBlSglSlllllilMH MlllBliriilllgllSlIlBack - f - i - S top Refresh Home

a J i l ^ j 3 Search Favorites History 1 Mail Print liiii

3 Links ( A ddress j ig j hrtplocalhost803DservletAddToShoppingCart

Shopping Cart Herns Price

UML D istilledMartin Fowler Quantity 1Program m ing Visual C + +David J Kraglinski Quantity 1

Price $ 2 9 9 5 Subtota l $ 2 9 9 5

delete

Price $ 3 9 9 9 Subtota l $ 3 9 9 9d elete

Total 6 9 9 4

  • Electronic Commerce on Business Application
    • Recommended Citation
      • tmp1499779448pdf2JOpQ

Table of Contents

Chapter 1 Introduction 1

Chapter 2 Electronic Commerce 2

21 What Is Electronic Commerce2

22 The Importance of Electronic Commerce3

23 Types of Electronic Commerce3

24 Why Most Internet Based Electronic Commerce Is In

The Business-To-Consumer W orld 6

25 Current State of Business-To-Consumer E-Commerce7

26 The Structure of The On-Line Store8

Chapter 3 Technologies For On-Line Store System11

31 Traditional Web Application - Common Gateway Interface(CGI) 11

32 Active Server Page 12

33 Server-Side Java Application 14

Chapter 4 Design of On-Line Bookstore Using Java Servlets

A Practical Verification18

41 The Design of Home Page of Tiny Book Store18

42 Design of Search by Different Requests27

43 Servlets Chaining To Process Requests In Different Levels28

44 Database Connectivity and Search from Database29

45 Session Tracking 35

46 Check O ut42

47 Customer Information Processing 43

Chapter 5 Future Work50

51 Connection Pooling50

52 More Object-Oriented - Better Encapsulation51

Chapter 6 Conclusion 53

Appendix A Bibliography54

Appendix B The Source Code of An On-Line Store System -

Tiny Book Store57

Appendix C Screen Display of the Test 135

List of Figure

Figure 261 The Structure of An Online Store 10

Figure 321 Handle Requests Flow Chart 13

Figure 331 HttpService of The Java Web Server Using Servlets 15

Figure 411 The Home Page of Tiny Book Store 22

Figure 412 One of The Searching by Author Pages26

Figure 441 One of The Outputs of Servlet AuthorProces 34

Figure 451 A Page Show All Information About A Book 39

Figure 452 A Page Show Items In The Shopping Cart After A User

Added Books To The Shopping Cart 40

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A

Book From The Shopping Cart42

Figure 461 A Check Out Page 43

Figure 471 An Invoice Page48

1

Chapter 1

Introduction

As we step in the year 2000 we can no longer look to the past as the guide for the

future A combination of business social and technical possibilities drives the rapid

progress in electronic commerce

Electronic commerce can offer a company both short-term and long-term benefits

Not only can it open new markets enabling a business firm to reach new customers

but it can also make it easier and faster for the firm to do business with their existing

customer base Moving business practices such as ordering invoicing and customer

support to network-based systems can also reduce the paperwork involved in

business-to-business transactions When more of the information is digitized it

allows that business firm to focus on meeting their customerrsquos needs Tracking

customer feedbacks and presenting customer solutions for their clientele are just

some of the opportunities that can stem from electronic commerce

2

Chapter 2

Electronic- Commerce

21 What Is Electronic Commerce

For some time now large business enterprises have used electronic commerce to conduct

their business-to-business transactions In early 1960 private networks were dedicated

for the use of electronic data interchange (EDI) and electronic funds transfer (EFT) in the

banking industry Recently however with the increased awareness and popularity of the

Internet electronic commerce has come to encompass individual consumers as well as

businesses of all size

To many electronic commerce is defined as the buying and selling of products and

service over the Internet But there are many other aspects Depending on whom you ask

electronic commerce has different definitions

From a communications perspective electronic commerce is the delivery of information

productsservices or payments via telephone lines computer networks or any other

means From a business process perspective electronic commerce is the application of

technology toward the automation of business transactions and workflow From a service

perspective electronic commerce is a tool that addresses the desire of firms consumers

and management to cut service costs while improving the quality of goods and increasing

3

the speed of service delivery From an online perspective electronic commerce provides

the capability of buying and selling products and information on the Internet and other

online services [16]

These definitions are valid with their perspectives It is a matter of which lens is used to

view the electronic commerce landscape Broadly speaking electronic commerce

emphasizes the generation and exploitation of new business opportunities by ldquogenerating

business valuerdquo or ldquodoing more with lessrdquo

22 The Importance of Electronic Commerce

As we approach the year 2000 we can no longer look to the past as guide to the future In

the face of strong market forces created by electronic commerce and mounting

competition corporations can no longer plod along historical tracks or seek the

preservation of the status quo Companies are discovering that old solutions do not work

with new problems The business parameters have changed and so have the risks and

payoffs

23 Types of Electronic Commerce

From a broad view there are three distinct general classes of electronic commerce

applications Inter-organizational (business-to-business) intra-organizational (within

business) and customer-to-business application [16]

4

231 Inter-Organizational Electronic Commerce

Inter-organizational electronic commerce makes business more convenient on the

following aspects

Firstly e-commerce can improve supplier management since electronic applications can

reduce the processing costs and cycle times for each purchase order and it can reduce the

number of people who work on purchase orders

Secondly e-commerce can improve inventory management since electronic applications

make the business partners can fast exchange information and easy track their documents

to ensure that they were received This not only can eliminate out-of-stock occurrences

but also can reduce inventory and improve inventory turn

Thirdly e-commerce can improve distribution management since electronic applications

can make the business partners receive the shipping documents as soon as possible and

enable better resource management by ensuring that the documents contain more accurate

data

Fourthly e-commerce can improve channel management since electronic application can

let the business partner post the information to electronic bulletin boards This can

eliminate repeated telephone calls and countless labor hours

Fifthly e-commerce can improve payment management since the business partner are

linked by network so the payments can be sent and received electronically Electronic

payment is more accurate and fast than traditional payment

232 Intra-Organizational Electronic Commerce

5

Intra-organizational electronic commerce facilities the following business applications

Workgroup communications Electronic applications enable manager to

communicate with employees using electronic mail videoconferencing and

bulletin boards

Electronic publishing Electronic applications enable companies to publish

information by using tools such as the World Wide Web On-line publishing can

show information immediately and clearly and reduce costs for printing and

distributing documentation

Sales promotion Electronic application improve the flow of information between

the production and sales forces and between the firms and customers This can

make companies have greater access to market and competitor information

Today Intranets are primarily set up to publish and access vital corporate information

Some of the most common types of information are Human Resources information

employee communications product development and project management data internal

catalogs sales support data equipment and shipment tracking and accessing corporate

database

233 Consumer-To-Business Electronic Commerce

In consumer-to-business transactions customers learn about products through electronic

publishing buy products with electronic cash and other secure payment systems and

even have information goods delivered over the network

6

From the consumerrsquos perspective there are three transactions

1 Electronic applications enable consumers to communicate with each other through

electronic mail videoconferencing and news groups

2 Electronic applications enable consumers to manage investments and personal finances

using online banking tools

3 Electronic application enable consumers to find online information about existing and

new products services

Consumers consistently demand greater convenience and lower prices Electronic

commerce provides consumers with convenient shopping methods from online catalog

ordering to phone banking both of which eliminate the costs of expensive retail

branches Electronic commerce facilitates factory orders by eliminating many

intermediary steps thereby reducing manufacturersrsquo inventory and distribution costs and

indirectly providing consumers with lower prices

24 Why Most Internet Based Electronic Commerce Is In The Business-To-

Consumer World

For the Business-to-Business e-commerce the lack of well-accepted standards is

hindering the success in promoting Business-to-Business electronic commerce

solutions[5] VAN (Value-Added Networks) EDI (Electronic Data Interchange) based

solutions are only accessible to large organizations due to the cost factor Corporate

buyers and suppliers large and small are looking for Internet based solutions to

streamline the procurement procedures and to reduce the cost of establishing trading

relationship and the trading transactions Such demands put forward some fundamental

challenge on issue like trust infrastructure on the Internet standards and inter-operability

etc

25 Current State of Business-To-Consumer E-Commerce

Business activity on the Internet is currently limited to publicizing the business

opportunity and to catalog based sales but it will rapidly expand to include the

negotiations conducted to settle the price of the goods or commodities being traded

These negotiations are currently conducted by human intermediaries through various

forms of auctions bidding systems for awarding contracts and brokerages The role of

the intermediaries can now be performed by Internet trading applications at a fraction of

the cost[4] Trading on the Internet allows a business to reach a large number of potential

customers and suppliers in a shorter time and a lower cost than possible by other modes

of communication and to settle business transaction with lower cost overhead in a shorter

time

Auctioned or brokered sales are the norm in business world for negotiating trades of large

monetary value But consumer sales and small-scale purchases have used the fixed price

mode perhaps because of the high overhead cost of using the auction or brokerage

method The new economics of the Internet will make auctions popular in consumer and

small business transactions also

Auctions are just one form of business negotiations Other examples are competitive bids

for procurement brokeragesexchangescartels and two party negotiations

Nowadays the free-market economy of software agents is in the embryonic stage But in

the near future the software agents will populate the Internet and provide trade and use

a rich variety of information goods and services in an open free-market economy In a

free-market economy of software agents information is produced traded and consumed

by vast numbers of autonomous self-motivated agents An essential task in such an

economy is the retailing or brokering of information gathering it from the right

producers and distributing it to the right consumers[10] The overall research goal is to

characterize and understand the dynamic behavior of information economies very large

open economies of automated information agents that are likely to come into existence in

the Internet

26 The Structure of The On-Line Store

9

Nowadays there are thousands of on-line stores running on the Internet A few well-

known ones are amazoncom and bookpoolcom Most of such applications involve

common functions which are as following

Searching for product information

Ordering products

Paying for goods and services

Providing online customer service

So they have a similar structure as shown in Figure 261 The system contains the

following components

1 A web server running continuously accepts userrsquos connection gets user requests and

forward requests to business procedure retrieves data (answers to user requests) from

business procedure and send it back to user

2 Business procedure usually consists of a user identification procedure like credit card

check user request analysis procedure analyzing requests calculating discomposing (if

necessary) and dispatching request to different data source component Also in some

case business procedure is responsible to compose data obtained from different data

sources into user-readable format

3 Database is the place to hold relevant data These data not only serve as a data source

describing commercial goods and prices but can be used for data mining to improve

store service quality as well Database is updated and maintained by both customersrsquo

input and system applications A customerrsquos input usually includes order information

10

Figure 261 The Structure of An Online Store

(through browser)

Databas

(through browser)client

client

serverWeb

Systemapplication

Busines

procedu

4 System applications can include a search engine running all the time and searching

relevant information from the internet data mining application deals with mining and

analyzing customer and sale data for management use database maintaining application

handles update data when product information changes Varying from system size to

system size not every system has cleardistinct boundaries between these components

The system can be 3-tired or n-tired but these systems all operate in similar ways

11

Chapter 3

Technologies For On-Line Store System

An on-line store system is different from traditional web publishing It needs customerrsquos

interactive communications and frequent data update The traditional HTML page is

insufficient because all it does is provide static content publishing Other technologies

are required in order to implement the on-line store

Currently there are three mainstream technologies which are widely used Common

Gateway Interface (CGI) Microsoft Active Server Page (ASP) and Server-side Java

application We briefly explore these technologies here

31 Traditional Web Application - Common Gateway Interface (CGI)

The common Gateway Interface normally referred to as CGI is one of the first practical

techniques for creating dynamic content With CGI a web server passes certain requests

to an external program The output of this program is then sent to the client in place of a

static file The advent of CGI makes it possible to implement all sorts of new

functionality in web pages and CGI quickly become a defacto standard implemented on

dozens of web servers Even though a CGI program can be written in almost any

language the Perl programming language is the predominant choice However CGI have

some distinct disadvantages

Firstly CGI program is transient A request is made each time to a CGI program It must

be loaded and executed by the Web server When the CGI program is complete it is

removed from memory and the results are returned to the client All program

initialization (such as connecting to a database) must be repeated each time a CGI

program is used

Secondly when a server receives a request that accesses a CGI program it must create a

new process to run the CGI program and then pass to it via environment variables and

standard input Every bit of information might be necessary to generate a response

Creating a process for every such request requires time and significant server resources

which limits the number of requests a server can handle concurrently

Thirdly a CGI program cannot interact with the web server or take the advantage of the

serverrsquos abilities once it begins execution because it is running in a separate process

32 Active Server Page

As shown in figure 321 the following list walks you step-by-step through what

happens if the client requests the page xyzasp

The client requests the page xyzasp from the server The Web server checks the file

extension to see whether a special program (such as the Active server Pages engine)

13

must be invoked to process the request If therersquos a asp extension the Web server

determines that it should invoke ASP to process this page

Figure 321 Handle Requests Flow Chart

Request

Response

WEB SERVERComponents

Databas

ns

ASP File

CLIENT

Active X Data

VBScript

If this page has never been requested before or has been changed since the last

request it must be parsed and the syntax checked and then be compiled by the Web

server Otherwise the page might be read from a cache of recently processed pages

which aids in performance During the parsing process the HTML and scripting code

14

are separated IIS (Internet Information Server) determines which scripting engine is

responsible for which part of the script and delegates the work of syntax checking and

compiling to the proper scripting engine (such as VB Script)

Now the code is executed by the scripting engine using resources from IIS which is

hosting the scripting engines All objects that the language engine cannot handle are

requested by the IIS which is also responsible for handling inputs and outputs for the

external ActiveX objects that are created and used inside the script If it is not able to

supply the object an error is generated

Script output and static HTML code in the ASP file are merged

The final HTML is sent back to the user in an HTTP response

The important point about ASP is that the Script runs entirely in a server to protect the

intellectual property by shielding it from browser which are different from the account

for when writing client-side code The entire server-side code is processed and only plain

HTML - or whatever kind of content you chose to generate - is sent to the client

33 Server-Side Java Application

The rise of server-side Java applications is one of the latest and most exciting trends in

Java programming A Servlet can be thought of as a server-side applet Servlets are

loaded and executed by a Web server in the same manner that applets are loaded and

executed by a Web browser

15

As shown in Figure 331 a servlet accepts requests from a client (via the Web server)

performs some task and returns the results

The client (mostly likely a Web browser) makes a request via HTTP The Web server

receives the request and forwards it to the servlet If the servlet has not yet been loaded

the Web server will load it into the Java virtual machine and execute it The servlet will

receive the HTTP request perform some type of process and return a response back to

the Web server The Web server will forward the response to the client

Figure 331 HttpService of The Java Web Server Using Servlets

RequestResponseRequestResponse

RequestResponse

Java Web Server

Administrative SERVLET

SERVLETHTTP

SERVLETWeb Proxy

Servlets have distinct advantages over CGI program

Servlets are persistent Servlets are loaded only once by the Web server and can

maintain services (such as a database connection) between requests

Servlets are fast since servlets only need to be loaded once

16

Servlets are platform independent Servlets are written in Java and conform to a well-

defined and widely accepted API They are highly portable across operating systems

and across server implementations A servlet can be developed on a Windows NT

machine running the Java Web Server and later can be deployed effortlessly on a

high-end Unix server running Apache

Servlet portability is not the stumbling block it so often is with applets There are two

reasons Firstly servlet portability is not mandatory Unlike applets which have to be

tested on all possible client platforms servlets have to work only in the server

machines that you are using for development and deployment Unless you are in the

business of selling your servlets you donrsquot have to worry about complete portability

Secondly servlets avoid the most error-prone and inconsistently implemented portion

of the Java language the Abstract Windowing toolkit (AWT) that forms the basis of

Java graphical user interfaces

Servlets are extendable Servlets that are written in Java brings all of the other

benefits of Java to servlet Java is a robust object-oriented programming language

which can be extended easily to suit our needs

Servlets are secure The only way to invoke a servlet from the outside world is

through a Web server This brings a high level of security especially if the Web

server is protected behind a firewall

Servlets can be used with a variety of clients

Servlets are tightly integrated with the server This integration allows a servlet to

cooperate with the server For example a servlet can use the server to translate file

paths to perform logging and to check authorization

Servlets are quite flexible An HTTP servlet can be used to generate a complete web

page it can be added to a static page using a ltSERVLETgt tag in whatrsquos know as a

server-side include and it can be used in cooperation with any number of other

servlets to filter content in something called a servlet chain

18

Chapter 4

Design of On-line Bookstore Using Java Servlets A Practical

Verification

Server-side Java application is one of the latest technologies used to implement an onshy

line store system Servlet is a set of classes that come up from Java language It is

designed to be used for server-side Java applications There are many techniques people

can use when they utilize servlet such as Server-Side Include (SSI) Servlet Chaining

Applet and Servlet communication etc We tried to use as many such techniques as

necessary in our implementation to demonstrate the advantages of servlets

The demonstration system module is same as the one we mentioned above Figure 331

We use this module to show how such system works

The system called Tiny Book Store emulates an on-line bookstore selling computer

books It has the full functionality of other on-line stores The only difference between

this system and the other on-line systems is the database size We donrsquot want to spend

much developing time for database maintaining part because this part is similar to

ordinary database maintaining and it is an independent subsystem The Tiny Book Store

mainly consists of three modules user interface business procedure and data access

19

41 The Design of Home Page of Tiny Book Store

The home page - welcome page - is designed using the Server-Side Include technique

That is embedding a servlet inside HTML file with a specific HTML tag ltSERVLETgt

In our case this servlet when invoked can run a query on database via data access

objects to retrieve most recent top 5 best-seller books and then returns the retrieved data

to the place within the page where the ltSERVLETgt tag was As long as the data in

database update timely it is guaranteed that customer will get the most recent data

The embedded servlet is invoked by Java Web Server before the page is sent back to

client Java Web Server processes any HTML file having shtml extension and invokes

the embedded servlet marked by ltSERVLETgt tags

Server-Side Includes are useful when a page is primarily static but contains a few distinct

dynamic portions One of the servlets produces the ldquo Five Hot Books ldquo which is shown in

the following example

Example 411 A Part of Code of welcomeshtml

lt P gt

lth3xstrongxf ont color= f f 6347 gtWelcome to theltigt

TinyBookStorecomltigtltfontgtltstronggtlth3 gt

20

ltstrongxbxh3gtltcentergtFive Hot

Booksltc e n t e r x h3gtltbgtltstronggt

ltbrgt

ltservlet code=EchoServletTaggt

ltservletgt

The servlet EchoServletTag searches database according to some business rule and gets

data from data access objects to produce the Five Hot Books The following example is

the sample code

Example 412 A Part of Code of The EchoServletTagjava

public void service(HttpServletRequest req

HttpServletResponse res)

throws ServletException IOException

res setContentType ( text Jhtml)

PrintWriter out = resgetWriter()

try

Statement stmt = concreateStatement()

21

ResultSet rs = stmtexecuteQuery(select from

book where

title like Programming)

int count = 1

outprintln(ltdlgt)

while (rsnext() ampamp count lt 6)

out print In ( ltdtxbgt + count + )

String isbn =

rsgetObj ect(ISBN) toString()

outprintln(lta

href=servletDetailContent + isbn +

outprintln(rsgetObj ect(Title) toString()

+ lt a x bgt )

out println ( ltddxnobrxfont color=990033gtUsuallY

ships in 24 hoursltBRxfontxnobrgt )

outprintIn(ltbrgt +

rsgetObject(Author) toString() )

outprintIn( +

r s getObject(Publisher)toString() + +

r s getObj ect(PublicationDate) toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

out println ltbrxbrgt )

22

count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()

The servelt EchoServletTag by the business mle that searching a specific table sends a

request query through data access object stmt and gets search result through another

data access object rs It then passes data to the page The content between ltservletgt and

ltservletgt tags in the HTML of home page is replaced by the search result at run time

The center part of the sample result page in Figure 411 is an example

23

Figure 411 The Home Page of Tiny Book Store

gj Search TinybookstGiecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

^ bullgt o a 4 i a a j ugt- a a Back lt7gtn Stop Refresh Home j Search Favorites History Mail Print Etfe

-Six

sfekinlfeSsI 3 Address |iS1 httpiVlocalhosLSOSCVwelcomeshtrnl Cj

f S M B l TinyBookStorecom

Search B o o k sW e l c o m e tc f l i e

HomeFive H ot Books 1 1

Category i-si

IA uthor

Title1 The C + + Programming L a n g u a g e B

Usually ships in 114 hoursISBN

k

IPublisher D a teBjame Stroustrup Addis on-Wesley Pub Co 1997Our Price 3147

m2 Programming Visual C+ +

Usually ships in 24 hours y

David J Krn^dinski Dlicrosoft Press 1998 c damp Local intranet

From this practice we know Server-Side Include not only can produce dynamic portion

of the page but also prevent from other people spy into your code Since Java servlet runs

entirely on a server thus protecting your intellectual property and shielding you from the

browser This means what the client sees can be totally different from what the server

does From the client side it is difficult to figure out how the server works

The left-hand menu items are implemented by using a characteristic of servlet - extra

path information or virtual path The extra path information can be used as a kind of

parameter passed to a servlet In general this extra path information is used to indicate a

24

file on the server that should use for something We use this feature here in an abnormal

way to manage customer requests and process these requests in a single place

Consider a traditional method When a menu item is selected by a customer it redirects

the customer to another page where it hyperlinks to If we have several ten items we

need to pre-create several ten pages This is the disadvantage of static HTML pages

However with servlet which can dynamically generate page content we can direct all the

customer requests to a central servlet and process the requests there according to some

condition (parameters) and then generate the page which customer need to see In this

way we only need one place to hold the code to save serverrsquos space And this place is

easy to maintain

The following is how it was doing for the Tiny Book Store

The Author item uses the following hyperlink

ltA

href = servlet ReqCo 11 ect author gtAuthorlt fontx AxTDgt

ltTRgt

The ReqCollect is the name of a servlet We pass the ldquoauthorrdquo in the hyperlink as a

parameter to ReqCollect When the Author item is selected ReqCollect is invoked by

lava Web Server ReqCollect generates a html page to let a user input author search

condition The ReqCollect code is listed below

25

Example 413 A part of Source Code of ReqCollectjava

public class ReqCollect extends HttpServlet

protected final String AUTHOR = author

public void service(HttpServletRequest req

HttpServletResponse res) throws ServletException

IOException

PrintWriter out = resgetWriter()

String path = reqgetPathlnfo ()

if (path == null)

error handling

else

Create standard header

CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

26

path = pathsubstring(1)

if (pathequalsIgnoreCase(CATEGORY))

Create category request collect

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

outprintln(ltfont color=CC66 0 0

face-verdana arial helvetica size = + lxbgtEnter

Authorltbgtltfontgt )

outprintln(ltbrgt You can enter

authors full name first name or last nameltpgt)

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess

id=forml name=formlgt)

outprintln(lttable border=0gt)

outprintln(lttrgt lttd valign=middle

align = lef txttgtltbgtAuthor ltbxttxtdgt )

outprintln(lttd valign=middle

align = lef txinput type = text name= author size = 40

value=x tdgt )

outprintln(lttrgt)

27

outprintln(lttrgt lttd colspan=2gt ltfont

size=-lgt)

outprintln(ltcentergt ltinput

type=radio name=author_mode value=exact

checkedgt Exact Name)

outprintln(ltinput type=radio

name=author_mode value=lastgtLast First Name (or

Initial) )

outprintln(ltcentergt)

outprintln(ltfontgt)

outprintln(lttdgt lttrgt)

outprintln(lttrgt lttd colspan=2gt ltpgt

ltbrgt lttdgt lttrgt)

outprintln(lttablegt)

outprintln(ltcentergt)

outprintln(ltinput type=submit

value=Search Now id=submitl name=submitlgt)

outprintln(cinput type=reset

value=Clear Form id=resetl name=resetlxpgt )

outprintln(ltcentergt ltformgt)

Create standard footer

28

CreateFooter(out)

outflush()

outclose()

The generated page looks like this

Figure 412 One of The Searching by Author PagesTinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorite l o o k H e lp

^ 3 4 s j ] S o zdStop Refresh Home Search Favorites History Mail Print EditBack bull

I t i h f e l f f httplocalhost8080servletReqCollectauthor

S ea rch Books

Home

C a t e g o r y

Author

Title

ISBN Publisher Date

poundj

TinyBookStore com

You can enter authors foil name first name or last name

A u t h o r jbjarne

C Exact N ame amp Last First N atne (or Initial)

Search Now | Clear Form

Taw boekstofeeoraH om e | Category | A uthor | Title | IS3M | Publisher Date

jpyright and disclaimer copy 1999-2001 F ang Xiao

ihtterteti

42 Design of Search by Different Requests

29

According to different requests the different pages should be produced There are many

common parts in the produced pages So we donrsquot need to code the common parts for

each page We can design the common parts into standard utility classes or static

functions You can simply call the standard classes or functions when you needed them

An example looks like this

CreateHeader(out)

CreateLeftMenu(out)

CreateFooter(out)

The three lines above invoke the standard functions CreateHeader() CreateFooter() and

CreateLeftMenu() which are developed in this thesis writing The CreateHeader()

function produces the top part of the pages The CreateLeftMenu() function produces the

left part of the pages The Createfooter() function produces the bottom part of the pages

You can find the source code in several servlets in Appendix

43 Servlet Chaining To Process Requests In Different Levels

A request can be handled by a sequence of servlets This system is designed to use the

first level servlets to handle the search requests If needed the first level servlets can

cooperates with the second level servlets by passing their processing result to the second

level servlets and let them to proceed the request until the final result is obtained The

final result is returned by the last servlet This is called servlet chaining The request

30

from the client browser is sent to the first servlet in the chain The response from the last

servlet in the chain is returned to the browser In between the output from each servlet is

passed as an input to the next servlet Each servlet in the chain has the option to change

or extend the content W e can see the example in the ReqCollect code

Example 431 A Part of Code of The ReqCollectjava

if (pathequalsIgnoreCase(AUTHOR))

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess id=forml

name=formlgt)

The ReqCollect servlet uses the getPathInfo() method to get the extra path information

This method returns the extra path information associated with request According to the

different extra path information the first level servlet invokes the different servlet of the

second level In this case ReqCollect invokes AuthorProcess servlet The final output

has been listed in Figure 412

31

44 Database Connectivity and Search from Database

The biggest advantage for servlets with regard to database connectivity is that the servlet

life cycle allows servlets to maintain open database connections An existing connection

can trim several seconds from a response time compared to a CGI program that has to

reestablish its connection for every invocation

Another advantage of the servlets over CGI and many other technologies is that JDBC is

database-independent JDBC is a SQL-level API - one that allows you to execute SQL

statements and retrieve the results if any The API itself is a set of interfaces and classes

designed to perform action against any database

An individual database system is accessed via a specific JDBC driver that implements the

javasqlDrivers interface Drivers exist for nearly all-popular RDBMS systems The

database connection used for Tiny Book Store uses a JDBC-ODBC bridge driver coming

along with the JDK 12 to allow access to standard ODBC data source such as the

Microsoft Access database

The first step in using a JDBC driver to get a database connection involves loading the

specific driver class into the applicationrsquos Java Virtual Machine This makes the driver

available later when we need it for opening the connection An easy way to load the

driver class is to use the ClassforNameQ method

32

ClassforName(sunj dbcodbcJdbcOdbcDriver)

When the driver is loaded into memory it registers itself with the javasqlDriverManager

class as an available database driver

The next step is to ask the DriverManager class to open a connection to a given database

where the database is specified by a specified formatted URL The method used to open

the connection is DriverManagergetConnection() It returns a class that implements the

javasqlConnection interface

Connection con =

DriverManagergetConnection(j dbcodbcsomedb

user passwd)

A JDBC URL identifies an individual database in a driver-specific manner Different

drivers may need different information in the URL to specify the host database

During the call to getConnection() the DriverManager object asks each registered driver

if it recognizes the URL If a driver says yes the driver manager uses that driver to create

the Connection object Here is an example

Example 441 A Part of Code of AuthorProcessjava

public void init() throws ServletException

try

ClassforNamesunj dbcodbcJdbcOdbcDriver)

con =

DriverManagergetConnection(j dbcodbcfxbookstore null

null)

catch (ClassNotFoundException e)

catch (SQLException e)

After we got the database connection we need to have some way to execute queries The

simplest way to execute a query is to use the javasqlStatement class Statement objects

are never instantiated directly instead a program calls the createStatement() method of

Connection to obtain a new Statement object

Statement stmt = concreateStatement()

34

A query that returns data can be executed using the executeQuery() method of Statement

This method executes the statement and returns a javasqlResultSet that encapsulates the

retrieved data

Example 442 A Part of Code of AuthorProcessjava

String sqlStmt =

if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where author= + name +II i n

else

sqlStmt = select from BOOK where author like +

name +

ResultSet rs = null

Statement stmt = concreateStatement()

rs = stmtexecuteQuery(sqlStmt)

35

A ResultSet object can be thought as a representation of the query result returned one row

at a time The next() method of ResultSet is used to move from row to row The

ResultSet interface also boasts a multitude of methods designed for retrieving data from

the current row The getStringO and getObject() methods can be used for retrieving

column values

Example 443 A Part of Code of AuthorProcessjava

while (rsnextO )

count++

outprintln(ltdtgtltbgt + count + )

String isbn = rsgetObject(ISBN)toString()

outprintln(lta href=servletDetailContent + isbn +

gt )

outprintln(rsgetObj ect(Title) toString() +

ltagtltbgt)

outprintln (ltnobrxfont color=990033gtUsually ships

in 24 hoursltBRgtltfontxnobrgt)

outprintln(ltddgt +

rsgetObj ect(Author) toString() )

36

outprintln( +

rs getOb j ect ( Publisher) toString () + +

rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

outprintln(ltbrgtltbrgt)

One of the outputs of servlet AuthorProcess is show in Figure 421 and Figure 441

Figure 441 One of The Outputs of Servlet AuthorProcess

37

File Edit View Favorites lo o k - Help M i

T 1 bdquo - 0 L Q 4 pound $ L L lBack r s Stop Refresh Home S earch Favorites History

A - Mail Print

Links rdquo Address | jyen j http7ocalhost808O$ervletAuthorProcess 3

Search B ooks

Home

CategoryA uthor

Title

ISBN

P u b l i sh e r D a te

Tiny Bookstore com

1 The C++ Prograitmuitg Language Usually ships in 24 hour Bjame Stroustrup Addison-Wesley Pub Co i 1997 Our Price 3147

T in yb o oks to re c om H ora e | Category | A uthor | Till | ISBN | Publisher P a t

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top of Page

gk j Local intranet

45 Session Tracking

Session Tracking is one of the most important techniques for any on-line store systems

This is because that HTTP protocol is a stateless protocol A HTTP server sees only a

series of requests and it by itself has no way to know exactly who is making the request

This means that when a customer puts a book in his shopping cart and then goes to other

pages to find more books next time when he puts another book in his shopping cart there

is no guarantee that he puts the book in the same cart It is very possible that he uses

another customerrsquos shopping cart at this time

38

To solve this problem session-tracking is introduced Traditional techniques used by

CGI include hidden form fields URL rewriting user authorization and persistent cookies

For server-side Java applications a built-in class supplied servlet can be used easily to

handle such tasks

When a user first accesses the site web server assigns a new HttpSession object and a

unique session ID to the user The session ID identifies the user and is used to match the

user with the HttpSession object in subsequent requests Usually the session ID is saved

on the client in a cookie or sent as part of a rewritten URL The Tiny Book Store uses this

technique

The Tiny Book Store is a classic shopping cart application A client can put items in his

virtual cart accumulating them until he checks out several page requests later How to

make sure a userrsquos shopping items will be put in his shopping cart or delete from his

shopping cart The Java Servlet API provide built in session tracking to handle this

problem Every user of a site is associated with a javaxservlethttpHttpSession object

that servlets can use to store or retrieve information about that user We can save any set

of arbitrary Java objects in a session object For example a userrsquos session object provides

a convenient location for a servlet to store the userrsquos shopping cart contents An example

shows below

Example 451 A Part of Code of AddToShoppingCartjava

39

1 Get current session object create one if necessary

2 HttpSession session = reqgetSession(true)

3 m_cart = (ShoppingCart)sessiongetValue(cart)

4 if (ra_cart == null) need new cart

5 create a shopping cart

6 m_cart = new ShoppingCart()

7 add to current session

8 sessionputValue(cart m_cart)

9

10

11 try

12 Statement stmt = m_concreateStatement()

13 ResultSet rs = stmtexecuteQuery(select from

book where ISBN= + isbn +)

14 if (rsnext())

15 book - new

BookDetails(rsgetObj ect(ISBN) toString()

16 rsgetObject(Title)toString()

rsgetObj ect(Authorrdquo) toString()

17 rsgetDouble(Price)

rsgetObj ect(PublicationDate) toString() )

18

40

1 9

2 0 catch (SQLException e)

21 e printStackTrace()

22

23 m_cartadd(bookgetlSBN() book)

The servlet uses its request objectrsquos getSession() method to retrieve the current

httpSession object

public HttpSession HttpServeltRequestgetSession (boolean create)

This method returns the current session associated with the user making the request If

the user has no current valid session this method creates one if create is true or return

null if create is false To ensure the session is properly maintained this method must be

called at least once before any output is written to the response Please look at the line 2

in the example 451

If you want to add data to an HttpSession object you can use the putValueQ method

public void HttpSessionputValue(String name Object value)

41

This method binds the specified object value under the specified name Any existing

binding with the same name is replaced This specifies at line 8 of the example 451

If you want to retrieve an object from a session you can use getValue() method

public Object HttpSessiongetValue(String name)

This method specified at line 3 of example 451 returns the object bound under the

specified name or null if there is no binding

From line 4 to line 9 the servlet checks whether the user already has a shopping cart If

the user didnrsquot have a shopping cart the servlet assigns a shopping cart to this user and

add the shopping cart to the current session to keep tracking The ShoppingCartjava class

is developed in this thesis writing code is provided in the appendix

From line 10 to line 21 the servlet knows the user already has a shopping cart m_con is

a data member of AddtoShoppingCart class Lines 12-13 have been discussed in the

previous section Lines 16-20 get some information of the book which the user selected

The information will be the data members of the ldquobookrdquo object that is an instance object

of BookDetailsjava class BookDetailsjava class is developed in this thesis writing the

source code is provided in the Appendix

Line 25 puts the book which is selected by the user into the shopping cart

42

Please see a set of pages are shown below

Figure 451 A Page Show All Information About A Book

TinjiRnfikStnre com - M inrnsnfl Interned Explnrpr

File Edit View Favorites Tools Help-

^ O 4 4 1 f i tStop Refresh Home I Search Favorites History Mail Print Edit

I Link gtgt Address [gl hgtplocalhos9l]IBrit-rvetDetailConetit-Ll20183l)544

S e a r c h B o o k s

Home-

C a t e g o r y

Author

Title

ISSNPublisher Pate

TinyBookStore com

The C++ Programming Languageby Bjarne Stroustrup

aISBN 0201889544 Addison-Wesley Pub Co 1997

Price 3147 Availability U sually ships within 24 hours

Add to cart

Done

R ev iew s

In tins brand-new third edition of The C + + Programming Language author Bjame Stroustrup the creator of C++ presents the full specification for the C++ language and standard library a spec that will soon become the joint ISOANSI C++ standard

g ig L o ca l in tranet

43

Figure 452 A Page Show Items In The Shopping Cart after A User Added Books To The Shopping Cart

H H I H I - I I

j File Edit View Favorites l o o k Help I f

| S ack Stop Refresh Home Search FavoritesJ V

History Wail Print

j Links Address |S1 http7localhost8O80servletAddToShoppingCart i i i i a i i i

( O ldquo ii

Shopping Cart Item s Price

An Introduction to fen e tic Algorithm sMelanie MteheU Quantity 1 Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

drle trgt

delete

delete

Price $ 2 2 0 Subtotal $ 2 2 0

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 6 7 5 6

|euro

rfuj Local intranet

44

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A Book From The Shopping Cart

^ A m a z o n c o m Shopping Cart - Microsoft Internet Explorer

- J A l 4Stop Refresh Home

gtH bdquo ] Back bdquo

httplocalhost8080servletDeleteFromShoppingCartitemgetltem()getlSBN()

Ji _J 3Search Favorites History

j - JMarl Print

~U ccdeg

Shopping Cart Item s

Core Java 2Cay S Horstrnaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d elete

delete

Price

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 4 5 5 6

rsquo0 1 Done gSsfLocat intranet

46 Check Out

This part is designed only using the HTML It collects all information from a user The

information will be written into the database

An important line in this HTML file is shown below

45

ltform method=POST

action=httplocalhost808 0servletCustomerlnfoProcessgt

This line will invoke the servlet CustomerlnfoProcess that will process all data collected

from the user This servlet will discuss in the next section The check out page shows in

Figure 461

Figure 461 A Check Out Page

M M iH M M M i M MmmrnfrnM File Edit View Favorites too ls Help

^ gt a 3 A hi -ltamp f V j HISllll mmB ack S lop R efresh H em e S earch 1 i l lie History M 1 Print Edit

^Links A ddrecs j ig ] h ltp localhostSO SO checkouth tm l i i i l a s

Custom er Information

First name (Fang

Middle initial |a

Last name [Xiao

Email address |fgtdaomitecnet

Account password Jxxxxx

C red it card num ber jl 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7

Credit card type ttV isa O BluebirdO MasterCard O Fisher

Credit card holder jFarig Xiao

Credit card expire date (tnmddyy) joi 0102 ~

Select shipping method t UPS 0 NormalO Express C Abnormal

| | ] Dorraquo raquo f j^ I o c a l intranet

47 Customer Information Processing

The customer information processing is handled by a servlet CustomerlnfoProces Its

source code is provided in the appendix

46

All information collected from the user should be written into the database therefore we

have to open a connection to a given database at first Example 461 is given for this

purpose

Example 471 A Part of Code of CustomerlnfoProcessjava

public void init() throws ServletException

try

ClassforName(sunjdbcodbcJdbcOdbcDriver)

m_con = riverManagergetConnection(jdbcodbcfxbookstore

null null)

catch (ClassNotFoundException e)

e printStackTrace()

catch (SQLException e)

e printStackTrace( )

There is a PO ST request in the check out page The servlet CustomerlnfoProcess will

handle the PO ST request by doPost function which is demonstrated in the following

example

47

Example 472 A Part of Source Code of CustomerlnfoProcessjava

public void doPost (HttpServletRequest req HttpServletResponse res)

throws ServletException IOException

ressetContentType(texthtml)

PrintWriter out = resgetWriter()

get information

String[] values = reqgetParameterValues(firstname)

if (values = null)

firstname = values[0]

values = reqgetParameterValues(middleinit)

if (values = null)

middleinit = values[0]

In the example the HttpServletRequest object res will get each data which was input by

the user by the getParameterValues() function

If the user is a returned user we donrsquot need open a new account again If the returned user

use the same credit card as previous we also donrsquot need to insert the credit card

48

information into the CREDITCARD table Otherwise we should insert all related

information into related table This is shown in the following example

Example 473 A Part of Source Code of CustomerlnfoProcessjava

Statement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where EmailAddress= +

email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext())

sql = insert into CUSTOMERACCOUNT (emailaddress password

firstname middleinit lastname) values ( + + email +

password + + firstname + + middleinit + lastname +

)

stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber= + creditcard

+

rs = stmtexecuteQuery (sql)

if (rsnext())

49

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype

HolderName ExpirationDate) values( + + creditcard + +

cardtype + + cardholder + 11 + expiredate + )

stmtexecute (sql)

All information related the books selected by the user can be obtained from the

shopping cart as shown in the following example

Example 474 A Part of Source Code of CustomerlnfoProcessjava

BookDetails book = null

ShoppingCartltern bookAndQuantity = null

Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getltems()

int aQuantity =0

String alSBN = null

while (itemshasMoreElements())

insert into Orderltems

bookAndQuantity = (ShoppingCartItem)itemsnextElement()

book = bookAndQuantitygetltem()

50

aQuantity = bookAndQuantitygetQuantity()

alSBN = book getISBN()

sql = insert into ORDERITEMS (shoppingCartID ISBN quantity)

values ( + + m_cartID + + aISBN + + aQuantity + )

stmtexecute (sql)

After all information inserted into related tables the servlet CustomerlnfoProcess will

produce invoice page The example page shows in Figure 471

51

Figure 471 An Invoice Page 3 Order List Microsoft Internet Explorer

is File Edit View Favorites Tools Help

J J J U r PS to p Refresh Hom e i -S earch Favorites History s Mai Print

Links Address iff 1 httpVlocalhostBOSOservletCustomerlnfoProcess 3

s5al Local intranet

Y ou r order reads as fo llow sE-MailAddress fiiiaomitecnet

ship to

Tel

Items

F ang Xiao12345 Western Plaza 23OmahaNE68154(402)123-4567

TitleCore Java 2Qtyl Price2579Subtotal2579

TitleJava Servlet PrograrnmingQtyl Price 1977 Sub total 1977 Total4556

i|51 D one

52

Chapter 5

Future Work

In this chapter we discuss two major problems for our future work They are the

Connection Pooling and Object-Oriented for better encapsulation

51 Connection Pooling

After we have used JDBC for a short time it will become evident that the major

performance bottleneck often comes right at the beginning when you are opening a

database connection This is because that opening a connection might involve a series of

low level communications between network protocols and database connection protocols

such as TCPIP ODBC etc

Servlet life cycle allows for extremely fast database access Servlet is loaded into Web

server only once Once it is loaded it can hold a connection to database all its life cycle

Every time it receives a request to read from or write data to database it can just use the

connection to do this

Here comes a problem however Suppose that a customer comes to the on-line store

During the period of selecting some items from the store he leaves his desktop and do

something else leaving this connection to database idling This will waste the precious

resource on the database From database port of view the connection to the database will

assign a space to hold corresponding status and to cache data For example Microsoft

SQL-Servertrade assigns about 36K bytes for each of its connection Resource on the

53

database is limited and idling connection causes such resource unable to be reused for

other users

To solve this problem we can use the technique called connection pooling Essentially a

connection pool is an object holding connections to backend database and managing the

number and status of connections For example if a connection in the pool idles over a

certain time of period the pool can terminate this connection if the requests are not the

same size of the connection pool the pool can dynamically shrink or expand the size of

itself A connection pool can run on a separate thread and is initialized when the server

starts or when a request to database is arrived

To implement a connection pool is pretty straight-forward Because of time constraint

however we did not do it in this paper and leave it as a possible future improvement

52 More Object-Oriented - Better Encapsulation

Another improvement might be done in the future is to create a HTML-related utility

class We have seen in this thesis that there are some duplicated code processing HTML

output such as ldquoout printIn ( lttbxtrgt lttrxtbgt)rdquo All these HTML-

related processes right now are used in a raw way That is they are not encapsulated A

better way to do this is to create a utility class or classes to deal with all HTML-related

processes and hide all HTML tags and format inside the class or classes For example

suppose that we create a Table class then we can use it in a way like

Table table = new Table()

54

table(somerow somecol contents)

table(somerow somecol some_image)

In this way we do not need to use HTML tags in our program and concentrate on the

programming logic The implementation is enriched with more object-oriented property

and therefore it is easy to maintain

55

Chapter 6

Conclusion

The increased awareness and popularity of the Internet make all kinds of electronic

commerce grow vigorously The most popular Web applications are the on-line stores

An on-line store system usually contains four components Web server business

procedure Database system application An on-line store system is different from web

publishing Currently there are three mainstream technologies which are widely used to

develop the on-line store systems CGI Microsoft ASP and Server-side Java application

Introducing the server-side Java application is one of the latest and most exciting trends

in Java programming We have discussed this technology in detail in this thesis The

server-side Java applications have many distinct advantages over CGI and other

technologies We present plenty of examples and figures to analysis the characteristics of

the server-side Java application

As a glance into the future electronic commerce will continue to grow driven by

purchases of home computers and other Web-enabled devices as well as new business

opportunities Electronic commerce is changing whole business procedures The future of

electronic commerce will be exciting and full of opportunities

56

APPENDIX A

Bibliography

57

[1] Karl Moss 1998 Java Servlets Mcgraw-Hill

[2] Jason Hunter William Crawford 1998 Java Servlet Programming O rsquoReilly

[3] Manoj Kumar Anand Rangachari Anant Jhingran Rakesh Mohan 1998 Sales Promitions on the Internet h ttpwwwibmcomiactech-paperhtml

[4] Manoj Kumar Stuart I Feldman 1998 Business Negotiations on the Internet httpwwwibmcomiactech-paperhtml

[5] Manoj Kumar Stuart I Feldman 1998 Internet Auction httpwwwibmcomiactech-paperhtml

[6] Shiwa Fu Jen-Yao Chung Walter Dietrich Vibby Gottemukkala Mitchell Cohen Shyhkwei Chen 1999 A Practical Approach to Web-Based Internet EDI httpwwwibmcomiacpapersicdcsws99indexhtml

[7] Zhong Tian Leo Y Liu Jing Li Jen-Yao Chung Vibby Guttemukkala 1999 Business-to-Business e-Commerce with Open Buying on the Internethttpw w w ibm comi acpapersobi -paperindex html

[8] Gerald J Tesauro Jeffrey O Kephart 1998 Foresight-Based Pricing Algorithms in an Economy os Software Agents http wwwi bm comi actech - paper html

[10] Jeffrey O Kephart James E Hanson Jakka Sairamesh 1998 Price and Niche Wars in a Free-Market Economy o f Software Agents httpwwwibmcomiactech-paperhtml

[11] Jeffrey O Kephart James E Hanson David W Levine Benjamin N Grosof Jakka Sairamesh Richard B Segal Steve R White 1998 Dynamics o f an Information-filtering Economy httpwwwibmcomiactech-paperhtml

[12] James E Hanson Jeffrey O Kephart 1998 Spontaneous Specialization in a Free-Market Economy os Agents httpwwwibmcomiactech-paperhtml

[13] Jakka Sairamesh Jeffrey O Kephart 1998 Price Dynamics o f Vertically differentiated Information Markets httpwwwibmcomiactech-paperhtml

[14] David Kosiur 1997 Understanding Electronic Commerce Microsoft Press

[15] Gunther Birznieks Selena Sol 1997 CGI fo r Commerce MampT Books - A Division of MIS Pres

58

[16] Ravi Kalakota Andrew B Whinston 1997 Electronic Commerce Addison Wesley

[17] Alex Fedorov Richard Harrison Dave Sussman Brian Francis Stephen Wood 1998 Profession Active Server Page 20 Wrox Press

[18] Calvin Austin Minica Pawlan 1999 Writing Advanced Application for the Java PlatformhttpVdeveloper iavasuncomdeveloperonlineTrainingProgrammin gJDCBooki ndexhtml

59

APPENDIX B

The Source Code of An On-Line Store System - Tiny Book Store

60

1 welcomeshtml

lthtmlgtltheadgtlttitlegtSearch Tinybookstorecomlttitlegtltheadgtltbodygt

lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=eeeeccgtlttrgtlttd rowspan=2 align=left valign=top width=15 cellspacing=0 cellpadding=0xIM G border=0 hspace=0 id=IMGl src=flowergif gtlttdgtlttd rowspan=2 align=left valign=centergtltstronggtlth2gtltigtTinyBookStorecomltigtlth2gtltstrongxtdgtlt trx tab legt

lttable border=0 width=100 cellspacing=0 cellpadding=0gtlttrgtlttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtltPgt

lttable width=100 cellspacing=0 cellpadding=5 border=0gtltTRgt ltTDgt ltTDgt ltTD colspan=2gt ltFONT FACE=verdanaarialhelvetica SIZE=-1 gtampnbsp ltFONTgt ltTDgt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD co lsp an = 2 x stro n g x fo n t face=verdanaarialhelvetica size=-lgtSearch B ooksltfontxstronggt ltTDgt ltTRgtltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt ltTD x f o n t face=verdanaarialhelvetica size=-l gt

lta href=w elcom eshtm lgtH om eltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt c T D x fo n t face=verdanaarialhelvetica size=-1 gt

lt A href= servletReqC ol 1 ec tc ategory gtC ate gory ltf o n tx A x T D gtltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollectauthorgtA uthorltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollecttitlengtTitleltorfo n tx A x T D gt ltTRgt

61

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectisbngtISBN ltA xfontxTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectpublisher_dategtPublisherD a telt A x fo n tx T D gtltTRgtlt tab lex p gtlttdgt

lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgtlttd valign=top align=leftgt

ltbr clear=allgtltPgtlt h 3 x s tro n g x fo n t color=ff6347gtWelcome to theltigt T in y B o o k S to rex o m lt ix fo n tx s tro n g x h 3 gt

ltbrgtlt s tro n g x b x h 3 x c e n te rgt F iv e Hot B o o k slt cen te rx h 3 x B x s tro n g gt

ltbrgtltservlet code=EchoServetTag myArgI=myValuel myArg2=myValue2gt ltparam name=myParm 1 value=Hellogtltparam name=myParml value=Worldgtltparam name=myParm2 value=myParmValue2gtltservletgt

lt td x trgt

lttablegt

ltTABLE width=100gtltTRgt ltTD width=50 valign=top align=Ieftgt ltTDgtltTD width=50 valign=top align=rightgtltfont size=-lgtltA href=topgtTop of P ag elt A x fo n tx T D gt ltTRgt

62

ltTABLEgt

ltcentergtltfont size=-lgtltA href=indexhtml gtTinybookstorecom HomeltAgt ampnbsplampnbsp ltA href=categoryhtml gtCategoryltAgt ampnbsplampnbspltA href= author html gtAuthorltAgt ampnbsplampnbspltA href= title html gtTitleltAgt ampnbsplampnbspltA href=7isbnhtml gtISBNltAgt ampnbsplampnbspltA href=publisherhtmrgtPublisher DateltAgtltpgtltfontgtltcentergt

ltPgtltcentergtlt b rx fo n t size=-lgtltA href=copyrighthtml gtCopyright and disclaimerltAgt copy 1999-2001 Fang Xiao ltfontgtltcentergt

ltbodygtlthtmlgt

63

2 AddToShoppingCartjava

ltpgt AddToShoppingCart is the servlet that process the action of adding item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javasql import javautil import javaxservlet import javaxservlethttp

public class AddToShoppingCart extends HttpServlet

protected Connection m_con = null protected ShoppingCart m_cart protected BookDetails book

public void initQ throws ServletException try

Class forName( sunj dbc odbc JdbcOdbcDriver)m_con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintstackTrace ()catch (SQLException e)

e prints tackT race ()

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

String[] params = reqgetParameterValues(isbn)

64

String isbn = get isbn from extra path infomationif (params = null)

isbn = params [0]

Get current session object create one if necessary HttpSession session = reqgetSession(true) m_cart = (ShoppingCart)sessiongetValue(cart)

if (m_cart == null) need new cart create a shopping cart m_cart = new ShoppingCart() add to current session sessionputValue(cart m_cart)

try Statement stmt = m_concreateStatement()ResultSet rs = stmtexecuteQuery(select from book where

ISBN=rsquo + isbn + rsquo)

if (rsnext()) book = new BookDetails(rsgetObject(ISBN)toString()

rsgetObject(TitIe)toStringOrsgetObject( Author) toStringO

rsgetDouble( Price) rs getObj ect( PublicationDate) toStringO)

catch (SQLException e)

eprintStackTrace()m_cartadd(bookgetISBN() book)

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lt h tm lxheadx titlegt T inyB ookS tore com S hopping

Cartlttitlexheadgt)outprintln(ltbody bgcolor=FFFFFF lmk=003399

alink=FF9933 vlink=996633 text=000000ngt)outprintln(lta nam e= topxmdashTop of Pagemdashx a gt )

65

outprin tln(ltpxa href=httplocalhost8080checkouthtmlximg src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=cccc99 gt)ou tp rin tln (lt tdxbrx tdgt )ou tp rin tln (lt tdxbrx tdgt )o u tp rin tln (lt tdxbrx tdgt )outprintln(lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=2xfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=left valign=topxfont

face=verdanaaria lhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=cccc99gt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lt td x b rx td gt ) outprintln(lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantityQ

outprintln(lttr bgcolor=FFFFFFgt) ou tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt )outprintln(ltbrgt + item getltem() get Author()) outprintln(ltbrgtQuantity + itemgetQuantityO) outprintln( ltbrgt) outprintln(lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=POST

action=7servletDeleteFromShoppingCartitemgetItem()getISBN()gt)

66

outprintln(ltpgt cinput type=hidden name=isbn value= + itemgetItem()getISBN())

outprintln(ltpgt ltinput type=submit name=ditemvalue=deletegt)

outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelve tica color=000000gt)

outprintln(ltNOBRgtltbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fon tx bx N O B R gt ltbrgt )

outprintln(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantity() + lt fo n tx b x N O B R x b rgt )

outprintln(ltfontgt) out println( lttdgt)

out printl n( lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)out println( lt fo n tx fo n tgt )outprintln(lttdxtrgt)outprintln(lttablegt)outprin tln(ltpxa href=httplocalhost8080checkouthtmlYximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)outprintln(ltbodygt lthtmlgt)

outflush()outclose()

67

3 AuthorProcessjava

bull ltpgt AuthorProcessbull This is the servlet that process the Author-search request and generatebull search resultbull Author Fang Xiao Purpose Thesis project Copyrightcopy Fang Xiao 1999-2001

import javaxservlet import jav ax servlet http import javaio import javasql

public class AuthorProcess extends HttpServlet protected final String EXACT = ldquoexactrdquo protected final String OTHERS = ldquolastrdquo

protected Connection con = null

public void init() throws ServletException try

ClassforName(ldquosunjdbcodbcJdbcOdbcDriverrdquo)con = DriverManagergetConnection(ldquojdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(ldquotexthtmlrdquo)PrintWriter out = resgetWriterQ

68

String[] valuesString name =

values = reqgetParameterValues(ldquoauthorrdquo) if (values = null)

name = values [0]

String mode = ldquordquovalues = reqgetParameterValues(ldquoauthor_moderdquo) if (values = null)

mode = values [0]

String sqlStmt = ldquordquo if (modeequalsIgnoreCase(EXACT))

sqlStmt = ldquoselect from BOOK where author=rsquordquo + name +else

sqlStmt = ldquoselect from BOOK where author like lsquordquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

ldquoYour Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ldquoltdlgtrdquo) 11 start Glossary List

while (rsnext()) count++outprintln(ldquolt d tx b gt rdquo + count + ldquo ldquo)String isbn = rsgetObject(ldquoISBNrdquo)toString()

69

outprintln(ldquolta href=servletDetailContentrdquo + isbn+

outprintln(rsgetObject(ldquoTitlerdquo)toString() +ldquolt a x b gt rdquo)

outprintln(ldquolt n o b rx fo n t color=990033gtUsually ships in 24 h o u rslt B R x fo n tx n o b rgt rdquo)

outprintln(ldquoltddgtrdquo +rsgetObject(ldquoAuthorrdquo)toString())

outprintln(ldquo ldquo +rsgetObject(ldquoPublisherrdquo)toString() + ldquo ldquo + rsgetObject(ldquoPublicationDaterdquo)toString())

outprintln(ldquoltbrgt Our Price ldquo +rsgetObject(ldquoPrice)toString())

outprintln(ldquolt b rx b rgt rdquo)

if (count == 0) outprintln(ldquoltdtgt No matched data foundrdquo)

outprintln(ldquoltdlgtrdquo) end Glossary List

catch (SQLException e) create footer here outprintln(ldquolttdgt lttrgtrdquo) outprintln(ldquolttablegtrdquo)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(ldquolthtmlgtrdquo) outprintln(ldquoltheadgtrdquo) outprintln(ldquolttitlegt TinyBookStorecom lttitlegtrdquo) outprintln(ldquoltheadgtrdquo)

outprintln(ldquoltbodygtrdquo)

70

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspacing=0 cellpadding=0 bgcolor=rdquoEEEECCYrsquogtrdquo)

outprintln(ldquolttrgtrdquo)outprintln(ldquolttd align=left valign=top width=90 gtrdquo) outprintln(ldquoltIMG border=0 hspace=0 id=IMGl

src=rdquodJavaWebServer20public_htmlflowergifrdquogtlttdgtrdquo) outprintln (ldquolttd width=30gtlttdgtrsquorsquo) outprintln(ldquolttd align=left valign=center width=300gtrdquo)

outprintln(ldquolt stro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x s tro n g x td gt rdquo) outprintln(ldquolttd align=right valign=centergtrdquo) outprintln(ldquolttdgtrdquo) outprintln(ldquolttd w id th= 20x tdgt rdquo) out pri ntln (ldquolttrgtrsquo rsquo) outprintln(ldquolttablegtrdquo)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ldquolttable width= 100gtrdquo)outprintln(ldquolttrgt lttd width=50 valign=top align=leftgt lttdgtrdquo) outprintln(ldquolttd width=50 valign=top align=rightgtrdquo) outprintln(ldquoltfont s iz e = - lx a href=rdquotoprdquogtTop of P agelt ax fon tgt rdquo) outprintln(ldquolttrgtrdquo) outprintln(ldquolttablegtrdquo)

outprintln(ldquoltcentergtrdquo) outprintln(ldquoltfont size=-lgtrdquo) outprintln(ldquolta

href=rdquohttplocalhost 8080welcomeshtmlrdquogtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080$ervletReqCollectcategoryrdquogtCategoryltagtampnbsplampnbsprdquo)

outprintln(ldquoltahref=Yhttplocalhost8080servletReqCollectauthorrdquogtAuthorltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_daterdquogtPublisheramp44Dateltagtrdquo)

outprintln(ldquoltpgtrdquo)

71

outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltpgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquolt b rx fo n t size=-lgtrdquo)outprintln(ldquoltA href=Y7copyrighthtmlrdquogtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiaordquo)outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltbodygtrdquo) outprintln(ldquolthtmlgtrdquo)

i

protected void CreateLeftMenu(PrintWriter out) System out println(ldquoLeftMenurdquo)

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspaeing=0 cellpadding=0gtrdquo)

outprintln(ldquolttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtrdquo)

outprintln(ldquoltpgtrdquo)

outprintln(ldquolttable width=rdquo 100rdquo cellspaeing=0 cellpadding=5border=0gtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquoltfont face=verdanaarialhelvetica SIZE=rdquo- l rdquogtampnbsp

ltfontgtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquolt strongxfon t face=verdanaarialhelvetica size=rdquo-

1 rdquogtSearch B ooksltfontxstronggtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd ldquo) outprintln(ldquoltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080welcomeshtmlYgt H o m elt fo n tx ax td gt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=rdquo-1rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080servletReqColIectcategoryrdquogt C ateg o ry lt fo n tx ax td gtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

72

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectauthorrdquogtAuthorltfontgtltagtlttdgtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width-2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l W rsquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltfontgtltagtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo-lYgtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_dateVrsquogtPublisher Dateltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolt tab lex p gt rdquo)

outprintln(lsquolsquolttdgtrdquo)outprintln(ldquolttd rowspan=4 width=5gtampnbspampnbspltbrgtlttdgtrdquo) outprintln(ldquolttd valign=top align=leftgtrdquo) outprintln(ldquoltbr clear=allgtrdquo)

73

4 BookTeatailsjava

ltpgt This is the class describing a book item in shopping cart

Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class BookDetails private String m_isbn = null private String m_title = null private String m_author = null private double m_price = 00 private String m_year = null

public BookDetails(String isbn String title String author double price String year)

thism_isbn = isbn thism_title = title thism_author = author thism_price = price thism_year = year

public String getISBN() return m_isbn

public String getTitle() return m_title

public String getAuthor() return m_author

public double getPrice() return m_price

ipublic String getYearQ

return m_year

75

5 CategoryProcessjava

ltpgt CategoryProcess This is the servlet that process the Category-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql import javautil

public class CategoryProcess extends FlttpServlet protected final String EXACT = exactprotected final String OTF1ERS = last

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

76

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentType( texthtml)Print Writer out = resgetWriterQ

String[] values String name = String sqlStmt =

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

else

path = pathsubstring(l) if (pathequalsIgnoreCase(cO 1))

sqlStmt = select from BOOK wherecategoryid=rsquo + cOl +

else if (pathequalsIgnoreCase(c02))sqlStmt = select from BOOK where

categoryid=rsquo + c02 +else if (pathequalsIgnoreCase(c03))

sqlStmt = select from BOOK wherecategoryid=rsquo + c03 +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftM enu(out)

Your Book Search Results try

77

if (con = null) Statement stmt = concreateStatement() rs = stmt executeQuery (sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn

+outprintln(rsgetObject(Title)toString() +

lt ax bgt )outprintln(ltnobrxfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltddgt +

rsgetObject( Author)toStringO)outprintln( +

rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)outprintln(ltbrgt Our Price +

rsgetObject( Price) toStringO) ltfont color=990000gtYou Save $1100

(20)ltfontgtoutprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

78

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)out println( lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20publicbdquohtmlflowergifgtlttdgt) outprintln(lttd width=3 0gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln( lt s tro n g x h 2 x igt T inyB ookS to re com lt ix h2x s tro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlngtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

79

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYrsquogtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln( ltfontgt)outprintln(ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rOwspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt)

outprintln(lttablewidth= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=Y2Ygt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y-1 Yrsquogtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2Yrsquogt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=Y-

lYrsquogtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=Y-lYgt)

80

outprintln(ltahref=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqColIectcategorygtCategoryltfontxagtlttdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(nltahref=httplocalhost8080servletReqCollectauthorVrsquogt A u th o rlt fo n tx ax td gtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httpIocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

6 CustomerlnfoProcessjava

ltpgt CustomerlnfoProcessThis servlet is responsible to process userrsquos information when heshe check out

Author Fang Xiao

Purpose Thesis projectCopyright (C) Fang Xiao 1999-2001

import javasql import javaio import j avau til import javaxservlet import javaxservlethttp

public class CustomerlnfoProcess extends HttpServlet protected Connection m_con = null protected HttpSession m_session = null protected static int m_cartID = 1 protected String firstname =protected String middleinit =protected String lastname =protected String email =protected String password =protected String creditcard =protected String cardtype =protected String cardholder =protected String expiredate =protected String shipping =protected String receiver =protected String address =protected String city =protected String state =protected String zipcode =protected String phone =

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)

82

m_con = DriverManagergetConnection(jdbcodbcfxbookstorenull null)

catch (ClassNotFoundException e)

eprintStackTrace()catch (SQLException e)

eprintStackTrace()i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

get informationString[] values = reqgetParameterValues(firstname) if (values = null)

firstname = values [0]

values = reqgetParameterValues(middleinit) if (values = null)

middleinit = values [0]

values = reqgetParameterValues(lastnameM) if (values = null)

lastname = values [0]

values = reqgetParameterValues(email) if (values = null)

email = values [0]

values = reqgetParameterValues(password) if (values = null)

password = values [0]

values = reqgetParameterValues(creditcard)

if (values = null) (creditcard = values [0]

values = reqgetParameterValues(cardtype) if (values = null)

cardtype = values [0]

values = reqgetParameterValues(cardholder) if (values = null) (

cardholder = values [0]

values = reqgetParameterValues(expiredate) if (values 1= null)

expiredate = values [0]

values = reqgetParameterValues(shippingrdquo) if (values = null)

shipping = values [0]

values = reqgetParameter Values (receiver) if (values = null)

receiver = values [0]

values = reqgetParameterValues(address) if (values = null)

address = values [0]

values = reqgetParameterValues(city) if (values = null) (

city = values [0])

values = reqgetParameterValues(state) if (values = null) (

state = values [0]

84

values = reqgetParameterValues(zipcode) if (values = null) (

zipcode = values [0]

values = reqgetParameterValues(phone) if (values = null)

phone = values[0]i

get session object m_session = reqgetSessionQ

try update databaseStatement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where Email Address=rsquo + email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext()) Systemoutprintln(insert customeraccount)

sql = insert into CUSTOMERACCOUNT (emailaddress password firstname middleinit lastname) values ( +

+ email + + password + + firstname +V + middleinit + + lastname + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber=rsquo +creditcard +

rs = stmtexecuteQuery (sql)

if (rsnext()) Systemoutprintln(insert creditcart)

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype HolderName ExpirationDate) values( +

+ creditcard + + cardtype + +cardholder + + expiredate + rdquo)

Systemoutprintln(sql)stmtexecute (sql)

i

85

sql = insert into SHOPPINGCART (ShoppingCartIDEmail Address CreditCardNumber ShippingType ReceiverName ReceiverAddress ReceiverCity ReceiverState ReceiverZipcode ReceiverPhone) values ( + m_cartID + V + email + Vrdquo +

creditcard + V + shipping + + receiver ++ address + V +

city + V + state + V + zipcode + V + phone +gt gt

Systemoutprintln(sql)stmtexecute (sql)

BookDetails book = nullShoppingCartltem bookAndQuantity = null Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

int aQuantity =0 String alSBN = null

while (itemshasMoreElementsO) insert into Orderltems bookAndQuantity =

(ShoppingCartItem)itemsnextElement()book = bookAndQuantitygetItem()

aQuantity = bookAndQuantitygetQuantity() alSBN - book getISBN()

Systemoutprintln(insert Orderltems)sql = insert into ORDERITEMS (shoppingCartED ISBN

quantity) values ( + m_cartID + +alSBN + + aQuantity + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

im_cartID++ must increase by one

86

catch (SQLException e) eprintS tackTrace()

printOrder(out)

public void printOrder(PrintWriter out) outprintln( lthtmlgt ltheadgt lttitlegt Order List lttitlegt ltheadgt) outprintln( ltbodygt)outprintln(lthlgt Your order reads as follows lthlgt)outprintln(lttablegt)outprintln( lttrgt)outprintln( lttdgtE-Mail Addres s lttdgt) outprintln(lttdgt+ em ail+lttdxtrgt) outprintln(lttrgt) outprintln(lttdgtship tolttdgt) outprintln(lttdgt+ receiver +ltbrgt) outprintln(address +ltbrgt) outprintln(city +ltbrgt) outprintln(state +ltbrgt) outprintln(zipcode + lt b rx td x trgt ) outprintln(lttrgt) outprintln( lttdgtTel lttdgt) outprintln(lttdgt+ phone +lttdxtrgt) outprintln(lttrgt) outprintln( lttdgtItems lttdgt)

BookDetails book = nullShoppingCartltem bookAndQuantity = nullEnumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

double total = 00

while (itemshasMoreElements()) bookAndQuantity = (ShoppingCartItem)itemsnextElement()

total += bookAndQuantitygetItem()getPrice() bookAndQuantitygetQuantityO

book = bookAndQuantitygetltem()

87

outprintln(lttdgtTitle+ bookgetTitle() + Qty + bookAndQuantitygetQuantity() + ltbrgt)

outprintln(Price + bookgetPrice() + Subtotal + bookAndQuantitygetQuantityO bookgetPrice() +ltbrgt)

outprintln(Total + total )outprintln(lttdxtrgt)outprintln(lttablegt)outflush()outclose()

7 DeleteFromShoppingCartjava

ltpgt DeleteFromShoppingCart is the servlet that process the action of deleting item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javautil import javaxservlet imp ort j avax servlet http

public class DeleteFromShoppingCart extends HttpServlet

protected ShoppingCart m_cart protected BookDetails book

public void doPost(HttpServletRequest req FIttpServletResponse res) throws ServletException IOException res setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String[] params = reqgetParameterValues(isbnrsquo) String isbn = get isbn hidden fieldif (params = null)

isbn = params [0]

Systemoutprintlnfisbn = + isbn)

Get current session objectHttpSession session = reqgetSession()m_cart = (ShoppingCart)sessiongetValue(carf)

m_cartremove(isbn)

89

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lthtm lgtltheadxtitlegtAm azoncom Shopping

C artlt titlexheadgt)out pri ntln ( ltb ody bgcolor=FFFFFF link=003399

alink=FF9933 vlink=Yrsquo996633Y text=rdquo000000rdquogtrdquo)outprintln(lta nam e= top xmdashTop of Pagemdashx a gt ) ou tp rin tln (lt pxa href=httplocalhost8080checkouthtmlximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=Yrsquocccc99Yrsquo gt)ou tp rin tln (lt tdxbrx tdgt )out pri ntln ( lt td x b r x td gt )outprintln( lt td x b r x td gt )out println (rsquo1 lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=Y2Yxfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=YleftY valign=YtopYxfont

face=verdanaarialhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=Ycccc99Yrsquogt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantity()

outprintln(lttr bgcolor=FFFFFFgt) o u tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt)outprintln(ltbrgt + itemgetItem()getAuthor())

90

outprintln(ltbrgtQuantity + itemgetQuantityO)outprintln(ltbrgt)outprintln( lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=VPOST

action=7servletDeleteFromShoppingCartVgt)outprintln(ltpgt ltinput type=hidden name=isbn value= +

itemgetItem()getISBN())outprintln(ltpgt cinput type=submit name=ditem

value=Y rsquo deletegt rsquo rsquo)outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelvetica color=000000gt)

outprintln(ltNOBRxbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fo n tx b x N O B R x b rgt )

outprintin(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantityO + lt fo n tx b x N O B R x b rgt )

outprintln( ltfontgt) outprintln( lttdgt)

i

outprintln(lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)outprintln(ltfontxfontgt)outprintln( lt td x trgt ) outprintln(lttablegt)ou tp rin tln (lt pxa href=Yhttplocalhost8080checkouthtmlYximg

src=YdYJavaWebServer20servletsimageproceed-to-checkoutgifYxagt)outprintln(ltbodygt lthtmlgt)

outflushOoutcloseQ

91

8 Detailcontentjava

ltpgt DetailContent is the servlet responsible for generating detailed information page for a book The book is identified by its ISBN Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaio import javasql import jav ax servlet import javaxservlethttp

public class DetailContent extends FIttpServlet protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String isbn = reqgetPathInfo()isbn = isbnsubstring(l) skip over rsquo rsquo

92

try String sql = select from book where ISBN=rsquo + isbn +

Statement stmt = concreateStatement()ResultSet rs = stmtexecuteQuery(sql)

create header here CreateHeader(out)

create left menu here CreateLeftMenu(out)

outprintlnfctd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintlnfctd valign=top align=leftgt)

cellpadding=0gt)

outprintln(ltbrgt)

create detailcontent here while (rsnext())

String strlSBN = rsgetObject(ISBN)toString() outprintln(lttable width=100 border=0 cellspacing=0

+ltbgtlttdxtrgt)

+ lt tdx trgt)

outprintln(lttrgt lttd colspan=3 align=leftxbgt) outprintln( rsgetObject(Title)toString()

outprin tln(lt trxtd colspan=3 align= leftxbgt by ltbgt) out println( rs getObj ec t( Author) toS tringQ

cellpadding=0gt)

outprin tln(lt trx td x i m g src=xtdgt) outprintln( lttd valign=topgt) outprintln( lttable border=0 cellspacing=0

outprintln( lt t r x td valign=topxbgtPrice )outprintln(

rsgetObject(Price)toString() + lt b x td x trgt ) outprintln(

lt trx td x b gt A v ailab ility lt b gt U su a lly lt td x trx b rgt )outprintln( lt t r x td vlign=topgtships within 24

hou rs lt td x trgt )outprintln( lt tab lextdgt)

93

outprintln( lttd align=rightgt) outprintln( lttable border=0 cellspacing=0

cellpadding=0gt)outprintln( lt trx td gt )outprintln( ltform

method=POST action=httplocalhost8080servletAddToShoppingCartgt)outprintln( ltinput

type=hidden name=isbn value= + strlSBN +outprintln( cinput

type=submit value=Add to cart )outprintln( lt tdx trgt )

outprintln( lt tab lex tdgt ) outprintln(rdquolttrgt)outprintln(lttrgt lttd clospan=3 align=leftgt ISBN ) outprintln( strlSBN +lttdxtrgt)outprintln(lttrgt lttd clospan=3 align=leftgt) outprintln( rsgetObject(Publisher)toString()

+rsgetObject(PublicationDate)toString() + lt tdx trgt )outprintln(lttablegt)outprintln(ltbrgt)outprintln(ltbrgt)

output reviewString review = rsgetObject(BookReview)toString() if (review = null)

review =DJavaWebServer20servletsreview + review

outprintln(ltbgtReviewsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(review))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprin tin (thisLine) ou t println( ltpgt)

)

icatch (IOException e)

need do something here eprintstackTrace ()

94

outprintln(ltbrgt)String comment =

rsgetObject(BookComment)toString()if (comment = null) comment = DJavaWebServer20servletscomment +

commentoutprintln(ltbgtReader Commentsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(comment))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprintln(thisLine) outprintln(ltpgt)

catch (IOException e)

need do something here eprintstackTrace ()

ou t pri ntln ( ltb rgt)

catch (SQLException e)

need to do something here

add table end tab outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt)

95

ou t pri ntln ( lthe adgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=YTOO cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d J avaW eb S erver 2 Opublic_htmlflo wer gif gtlttdgt) outprintln(lttd width=30gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyBookStorecomltigtlth2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln( lttd width=20gtlttdgt) out pri ntln ( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-1 gt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

96

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsptampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out prin tin ( ltcen tergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

eellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=Yhttplocalhost8080Avelcom eshtm lgtHom eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-1gt)

97

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=http7localhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref-httpIocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lVgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

98

9 EchoServlettagjava

import javaio import j avasql import javaxservlet import javaxservlethttp

public class EchoServletTag extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintStackTrace ()catch (SQLException e)

eprintStackTrace()

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

try Statement stmt = concreateStatementQResultSet rs = stmtexecuteQuery(select from book where title

like rsquoProgrammingrsquo)int count = 1outprintln(ltdlgt)while (rsnext() ampamp count lt 6)

outprintln(ltdtxbgt + count + )

99

String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn + outprintln(rsgetObject(Title)toString() + lt ax bgt ) outprintln(ltddxnobrgtltfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltbrgt + rs getObject( Author) toStringO) outprintln( + rsgetObject(Publisher)toStringO +

+ rsgetObject(PublicationDate)toStringO)outprintIn(ltbrgt Our Price +

rsgetObject(Price)-toStringO)

out println( lt b rx b rgt ) count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()outprintln(lttdgt lttrgt) outprintln(lttablegt) outflush() outcloseO

ii

100

10 ISBNProcessjava

ltpgt ISBNProcess This is the servlet that process the ISBN-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javax servlet import javaxservlethttp import javaio import j a vasql

public class ISBNProcess extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forN ame( sun j dbc odbc J dbcOdbcDri ver)con = DriverManagergetConnection(j dbc odbc fxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s s e tC on te n tTy pe ( tex th tm l)PrintWriter out = resgetWriter()

String[] values

String alSBN =

values = reqgetParameterValues(isbn) if (values = null)

alSBN = values [0]

String sqlStmt = select from BOOK where ISBN= + alSBN

ResultSet rs = null int count = 0

create header here bullCreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject( IS BN) toStringO

outprintln(lta href=servletDetailContent + isbn+ gt)

outprintln(rsgetObject(Title)toStringO +lt ax bgt )

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toStringO)

outprintln( +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

102

outprintln(ltbrgt Our Price +rsgetObject(rdquoPrice) toStringO)

outprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width= 100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d Uava WebS erver2 Opubhc_htmlflo wer gif gtlttdgt) outprintln(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS tore com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt)

103

out println( lttdgt) outprintln(lttd w id th= 20x tdgt ) out pri ntln( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)out pri ntln (lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) out pri ntln ( lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsp1ampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out println( ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

104

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 eellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Books lt fontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocaihost8080servletReqCollectcategorygtCategoryltfontxaxtdgt lttr gt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

105

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lttablegtltpgt)

o u t println( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

ii

106

11 PublisherDataProcessjava

ltpgt AuthorProcess This is the servlet that process the PublisherampDate-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql

public class PublisherDateProcess extends FIttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbc odbc JdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentT ype ( texthtml)PrintWriter out = resgetWriterQ

String[] valuesString namel =

107

values = reqgetParameterValues(publisher) if (values = null)

nam el = values [0]

String name2 =values = reqgetParameterValues(rdquopublication_date) if (values = null)

name2 = values [0]

String sqlStmt =sqlStmt = select from BOOK where publisher=rsquo + namel + rsquoand

publicationdate=rsquo +name2

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprin tln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toStringO outprintln(lta href=servletDetailContent + isbn

+ gt)outprintln(rsgetObject(Title)toString() + (

lt ax bgt )

108

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rs getObj ect( Author) toS tring())

outprintln(V +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

outprintln(ltbrgt Our Price +rsgetObject( Price) toStringO)

outprintln( lt b rx b rgt )

if (count == 0) (outprintln(ltdtgt No matched data found)

outprintln(rdquoltdlgt) end Glossary List

catch (SQLException e) ( create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 celipadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt)

109

outprintln(ltIMG border=0 hspace=0 id=IM Gl src=dJavaW ebServer20public_htmlflowergifxtdgt)

outprintln(lttd width=3 0 x td gt ) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS to re com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ctable w idths 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt) outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) ou t println( ltcentergt)

no

outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaim er^A gt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) out pri ntln ( lthtml gt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-1 gtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=V-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-1gt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

I l l

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitleYrsquogt T itle lt fo n tx a x td gt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(nltahref=Yhttplocalhost8080servletReqCollectisbnY gtISBNltaxfontxtdgt lttrgt)

outprindn(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdana arial helvetica size=Y -1 gt)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYgtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

1 12

12 ReqCollectjava

ltpgt This is a servlet responsible for generating search request collection page It read extra path information from URL and then according to the extra path information it generates corresponding page format Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001import javaxservlet import javaxservlethttp import javautil import javaio

public class ReqCollect extends HttpServlet

protected final String CATEGORY = categoryrdquo protected final String AUTHOR = author protected final String TITLE = titlerdquo protected final String ISBN = isbnprotected final String PUBLISHER_DATE = publisher_date

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentType( texthtml)PrintWriter out = resgetWriter()

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

)else

Create standard header CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

path = pathsubstring(l) if (pathequalsIgnoreCase(CATEGORY))

I I Create category request collect

outprintln(ltpgt)outprintln(lth3xstronggtProgrammingltstronggtlth3gt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc01gtAlgorithmsltagt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc02gtCampC++ltagt)outprintln( Delphi) outprintln(lta

href=httplocalhost8080servletCategoryProcessc03gtJavaltagt)outprintln( MFC Perl)

outprintln(software Design UML Visual Basic More)

outprintln(lth3xstronggtW eb Developm entltstrongxh3gt) outprintln(ASP Commercem Cyberculture HTML

JavaScript)

outprintln(Security Web Design XML more)

outprintln(lth3xstronggtGraphics amp Softwareltstrongxh3gt) outprintln(Asobe CAD Desktop Publishing Graphics)

outprintln(Microsoft More)

outprintln(lth3xstronggtNetW orking amp O Sltstrongxh3gt) outprintln(Linux Macs Oracle PCs SAp R3 SQL)

outprintln(TCPIP Unix WindowsampDOS W indowsNT)

out println( More)

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

1 14

outprintln(ltfont color-CC6600 face=verdana arial helvetic a size=+1 gtltbgtEnter Authorltbgtltfontgt)

outprintln(ltbrgt You can enter authorrsquos full name firstname or last nameltpgt)

outprintln(ltform method=POST action=httplocalhost 8080servletAuthorProcessY id=form 1 name=form 1 gt)

outprintln( lttable border=0gt) outprintln(lttrgt lttd valign=middle

ahgn= leftx ttx b gt A u th o rlt b gt lt ttx td gt )outprintln(lttd valign=middle align= leftx input

type=YtextY name=author size=40 value=YYxtdgt)outprintln(lttrgt)outprintln(lttrgt lttd colspan=2gt ltfont size=-lgt) outprintln(ltcentergt ltinput type=radio

name=Yauthor_modeY value=YexactY checkedgt Exact Name)outprintln(ltinput type=radio name=author_mode

value=lastgtLast First Name (or Initial))outprintln(ltcentergt) outprintln(ltfontgt) outprintln(lttdgt lttrgt)outprintln(lttrgt lttd colspan=2gt ltpgt ltbrgt lttdgt lttrgt)outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search NowY

id=submitl name=submitlgt)outprintln(cinput type=reset value=YClear Form

id=resetl nam e= rese tlxpgt )outprintln(ltcentergt ltformgt)

else if (pathequalsIgnoreCase(TITLE))

Create title request collect

outprintln(ltfont color=CC6600 face=verdanaarialhelvetica s ize= + lxbgt E n ter T itlelt bxfontgt)lsquo

outprintln(ltbrgtYou can enter the exact title or part oftitleltPgt)

outprintln(ltform method=YPOSTY action=Yhttplocalhost8080servletTitleProcessY id=form l name=formlgt)

outprintln(lttable border=0gt) outprintln(lt trxtd valign=middle

a lig n = le ftx ttx b gt T itle lt b x t tx td gt )

115

outprintln(lttd valign=middle align= leftx input type=text name=title size=40 value=xtdgt)

outprintln(lttrgt) outprintln(lttrgt) outprintln( lttd colspan=2gt) outprintln( ltfont size=-lgt) outprintln( ltcentergt)outprintln( ltinput type=radio name=title-mode

outprintln(value=exact checkedgt) outprintln( Exact Title)outprintln( ltinput type=radio name=title-mode

outprintln( value=titlewords gt ) outprintln( Title Words )outprintln(ltcentergt ltfontgt lttdgt lttrgt)outprin tln(lt trxtd c o ls p a n = 2 x p x b r x td x tr gt ) outprintln(lttablegt)

outprintln(ltcentergt)outprintln( ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln( ltinput type=reset value=Clear Form

id=resetl nam e= resetlxP gt )outprintln(ltcentergt) ou t println ( ltformgt)

outprintln(lthr noshade size=lgt)

outprintln(ltBgtExamplesltBgt)outprintln(ltULgt)outprintln(ltLIgtEntering ltbgtampquotJava Servlet

Programmingampquotltbgt in the title field )outprintln(and choosing ltemgtExact Titleltemgt finds the

book without also finding the many books)

outprintln(ltLIgtEntering ltbgtampquotJavaampquotltbgt in the Title field and choosing ltemgtTitle Wordsltemgt)

outprintln( finds all books whose title are related toltigtJavaltigt)

outprintln(ltULgt)

out printl n( lttdgtlttrgt) outprintln(lttablegt)

ielse if (pathequalsIgnoreCase(ISBN))

Create isbn request collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n ter ISBN ltbxfontgt)outprintln(ltbrgt) outprintln(ltform method=POSTY

action=httplocalhost8080servletISBNProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

a lig n = le ftx ttx b gt IS B N lt b x t tx td gt ) outprintln(lttd valign=middle a lign= leftx input

type=text name=isbn size=40 value=xtdgt)outprintln(lttrgt)

outprin tln(lt trxtd c o ls p a n = 2 x p x b rx td x trgt ) outprintln(lttablegt)

out println( ltcentergt)outprintln(ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln(ltinput type=reset value=Clear

FormV id=resetl nam e= resetlxP gt )outprintln(ltcentergt)outprintln(ltformgt)

outprintln(lthr noshade size=lgt)

outpiintln(ltULgtrdquo)outprintln(lttdxtrgt)outprintln(lttablegt)

else if (pathequalsIgnoreCase(PUBLISHER_DATE))

Create publisher date collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n te r Publisher and Publication D ate ltb gtltfontgt)

1 17

outprintln( ltbrgt) outprintln(ltform method=POST

action=httplocalhost8080servletPublisherDateProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

align=leftgtlt ttxbgt P ub lisher lt b x t t x t d gt )outprintln(lttd valign=middle align= leftx input

type=text name=publisher size=40 value=xtdgt)outprintln(lttrgt) outprintln(lttrgt lttd valign=middle

a lign= leftx ttxbgt P ub lica tion D a te lt b x ttx td gt )outprintln(lttd valign=middle align= leftx input

type=text name=publication_date size=40 value=xtdgt)outprintln(lttrgt)outprintln( c t r x td c o l s p a n = 2 x p x b r x td x t r gt )outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search Now

id=submitl name=submitlgt)outprintln(ltinput type=reset value=VClear FormYrsquo

id=resetl nam e= resetlxpgt )outprintln(ltcentergt) outprintln(ltformgt) outprintln(lthr noshade size=lgt)

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush()outclose()

)

protected void CreateHeader(PrintWriter out) outprintln(lthtmigt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding bgcolor=EEEECCgt)

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20pubiic_htmlflowergifgtlttdgt) outprindn(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(lt s tro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x stro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt)outprintln(lttd w idth=20xtdgt) ou t println ( rsquo lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

out pri ntln ( ltfon tgt) outpri ntln( ltcentergt ) out pri ntln ( ltpgt) outprintln(ltcentergt) outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)out pri ntln ( ltf on tgt) outprintln(irltcentergt) out println ( ltbodygt) out pri ntln( lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

cellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=YT00 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE= -lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

1 gtS earch B ookslt fontx stronggt)outprintln(lttdgt lttrgt)out pri ntln (lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=l-lgt)

outpri ntln(ltahref=httplocalhost8080servletReqCoilectauthorgtA uthorltfontxaxtdgtlttrgt)

120

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprindn(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=V-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln(lttablexpgt)outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

121

13 ShoppingCartjava

ltpgt This is the definition for ShoppingCart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import Javautil

public class ShoppingCart Hashtable items = null int numberOfltems = 0

public ShoppingCart() items = new Hashtable()

add BookDetails to cart param bookID isbn param book book need to be added to cart copyreturn void

public void add(String bookld BookDetails book) if(itemscontainsKey(bookId))

ShoppingCartltem scitem = (ShoppingCartltem)itemsget(bookld) scitemincrementQuantity ()

else ShoppingCartltem newltem = new ShoppingCartltem(book) itemsput(bookId newltem)

numberOftems++

param bookld isbn

public void remove(String bookld) if(itemscontainsKey(bookd))

items remove (bookld) numberOfltems - -

public Enumeration getltems() return itemselements()

protected void finalize() throws Throwable items clear()

public int getNumberOfItems() return numberOfltems

public void clear() items clear() numberOfltems = 0

123

14 ShoppingCartltemjava

ltpgt This is the definition for the shoppingcart item Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class ShoppingCartltem BookDetails item int quantity

public ShoppingCartItem(BookDetails anltem) this item = anltem this quantity = 1

public void decrementQuantity() if (quantity gt 0)

quantitymdash

public void incrementQuantity() thisquantity++

i

public BookDetails getltem() return thisitem

public int getQuantity() ( return thisquantity

i

124

15 StandardFooterjava

package servlets

import j avax servlet

ltpgt This is a server side include servlet that will format the TinyBookStore HTML footer

public class StandardFooter extends GenericServlet

ltpgtPerform the servlet service

param req The request from the client param res The response from the servlet public void service (ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the response javaioPrintW riter out = new

javaioPrintWriter(resgetOutputStream())

Format the standard footeroutprintln(ctable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(rdquoltfont s iz e = - lx a href=topgtTop of

P agelt ax fon tgt )outprintln(lttrgt) out println( lttablegt) outprintln(ltcentergt) outprintln(rsquoltfont size=-lgt)outprintln(lta href=7welcomeshtmlYgtTinybookstorecom

Homeltagt ampnbsplampnbsp)outprintln(lta href=categoryhtmlgtCategoryltagt

ampnbsplampnbsp)outprintln(lta href-authorhtmlgtAuthorltagt

ampnbsplampnbsp)outprintln(lta href=titlehtmlrdquogtTitleltagt ampnbsplampnbsp)

125

outprintln(lta href=isbnhtmlgtISBNltagt ampnbsplampnbsp) outprintln(lta href=7publisherhtmlgtPublisheramp44

Dateltagt)outprintln(ltpgt)outprintln(ltfontgt)ou t println ( ltcen tergt)outprintln(ltpgt)out println (ltcentergt )outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and

disclaim er^A gt ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln( ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

outflush()outclose()

126

16 StandardHeaderjava

package servlets

import javaxservlet

ltpgt This is a server side include servlet that will format the standard TinyBookStore HTML header The Title of the page will be set to the value of the title property

public class StandardHeader extends Generic Servlet

ltpgt Performs the servlet service param req The request from the client param res The response from the servlet

public void service(ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the responsejavaioPrintWriter out = new javaioPrintWriter(resgetOutputStream())

Get the title of the page Set to empty string if no title parameter was givenString titles[] = reqgetParameterValues(title)String title = if (titles = null)

if (titleslength gt 0) title = titles [0]

outprintln(lthtmlgt) outprintln(ltheadgt) outprintln(lttitlegt + title + lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=T00 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)

127

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src=dJavaWebS erver2 Opublic_htmlflower gi A gtlttdgt) out println(lttd width=3 O x td gt ) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyB ookStorecom ltigtlth2xstrongxtdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) out printl n ( lttd width=20gtlttdgt) out printl n( lttrgt) outprintln(lttablegt)

outflush()outclose()

128

17 TitleProcessjava

ltpgt TltleProcess This is the servlet that process the Tltle-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import j avax servlet import javaxservlethttp import javaio import j avasql

public class TitleProcess extends HttpServlet protected final String EXACT = exact protected final String OTFIERS = titleWords

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

129

String[] valuesString name =

values = reqgetParameterValues(title) if (values = null)

name = values [0]

String mode =values = reqgetParameterValues(title_mode) if (values = null)

mode = values [0]

String sqlStmt =if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where title=rdquo + name +else

sqlStmt = select from BOOK where title like rsquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString()

130

outprintln(lta href=servletDetailContent + isbn+

outprintln(rsgetObject(Title)toString() +ltagtltbgt)

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toString())

outprintln( +rsgetObject(Publisher)toString() + + rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +rsgetObject(Price)toString())

outprintln(ltbrxbrgt)i

if (count == 0) outprintln(ltdtgt No matched data found)

ioutprintln(ltdlgt) II end Glossary List

catch (SQLException e) i create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

131

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=EEEECCgt)

outprintln(rdquolttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaW ebServer20public_htmlflowergifxtdgt) outprintln(lttd w idth=30xtdgt) outprintln(rdquolttd align=left valign=center width=300gt)

outprintln(ltstronggtlth2gtltigtTinyBookStorecomltixh2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(rdquolttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln( lttrgt)outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(rdquolta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(rdquoltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

132

out println( ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) outprintln( ltcentergt) outprin tln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disciaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) S y s te m out println( LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt )

outprintln(lttable width= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y- lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost 8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

133

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lt tab lex pgt )

ou t pri ntl n ( lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

134

18 checkouthtml

lthtmlgtltheadgt lttitlegtCustomer Informationlttitlegt ltheadgtltbodygt

lt hlgt ltcentergt ltbgt Customer Information ltbgt ltcentergt lt hlgt

ltform method=POST action=httplocalhost8080servletCustomerInfoProcessgt lttable border=0gt

lttrgtlttd align=rightgtFirst namelttdgtlttd colspan=2 align= leftx input type=text name=firstname size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtMiddle initiallttdgtlttd colspan=2 align= leftx input type-text name=middleinit s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtLast namelttdgtlttd colspan=2 align= leftx input type-text name=lastname size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtEmail addresslttdgtlttd colspan=2 align= leftx input type=text name=email s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgt Account pass word lttdgtlttd colspan=2 align= leftx input type=text name=password s ize= 40x tdgt

lttrgtlttrgt

lthrgtlttrgt

lttablegtltbrgt

ctable border=0gtlttrgt

lttd align=rightgtCredit card numberlttdgtlttd colspan=2 align= leftx input type=text name=creditcard s ize= 40x tdgt

lttrgtlttr valign=topgt

135

lttd align=rightgtCredit card typelttdgtlttd align=leftgtltinput type=radio name=cardtype value=visagtVisaltbrgtltinput type=radio name=cardtype value= mastercard gtMasterCardltbrgt lttdgtlttd align=leftgtltinput type=radio name=cardtype value=bluebirdgtBluebirdltbrgtltinput type=radio name=cardtype value=fishergtFisherltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtCredit card holderlttdgtlttd colspan=2 a lign= leftx input type=text name=cardholder s ize= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCredit card expire date (mmddyy)lttdgtlttd colspan=2 align= leftx inpu t type=text name=expiredate size= 40x tdgt

lttrgtlt trx trgtlt trx trgtlttr valign=topgt

lttd align=rightgtSelect shipping methodlttdgtlttd align=leftgtltinput type=radio name=shipping value=upsgtUPSltbrgtltinput type=radio name=shipping value=expressgtExpressltbrgtlttdgtlttd align=leftgtcinput type=radio name=shipping value=normalgtNormalltbrgtltinput type=radio name=shipping value=abnormalgtAbnormalltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtReceiver Namelttdgtlttd col span=2 a lign= leftx inpu t type=text name=receiver size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtAddresslttdgtlttd colspan=2 align= leftx input type=text name=address size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCitylttdgtlttd colspan=2 align= leftx inpu t type=text name=city size= 4 0 x td gt

lttrgtlttrgt

136

lttd align=rightgtStatelttdgtlttd colspan=2 align= leftx inpu t type=text name=state s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtZipcodelttdgtlttd colspan=2 align= leftx inpu t type=text name=zipcode size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtPhonelttdgtlttd colspan=2 align= leftx input type=text name=phone size= 40x tdgt

lttrgtlttablegtlt b rx b rgtcinput type=submit value=Process name=actiongt

ltformgt

ltbodygtlthtmlgt

137

APPENDIX C

Screen Display of the Test

138

mmm File Edit View Favorites T o d s Help

^ Jit j j ^ LJ U 3) ~ pound=J _Am Back - S top Refresh Home j Search Favorites History Mait Print Edit

Links gtgt Address |4S ] httDVIocalhost808QAvdcorne shtml

TinyBookStore com

Welcome to the TJnyBoakStoro com

F i v e H o t B o o k s

1 T h e C + + Programming LanguageU s u a l l y s h i p s i n 24 h o u r s

B j a r n e S t r o u s t r u p A d d i s o n - W e s l e y Pub Co 1997 Our P r i c e 31 47

2 - P r o g r a m m i n g V i s u a l C + +U s u a l l y s h i p s i n 24 h ou r I I

Local intranet

Search BooksHorne

Category

Author

Title

ISBNPublisherDate

3 iigt60

3 1 S earch T inybooksloiecom - Microsoft Internet Explorer

139

T inyB ookStorecom - Microsoft Internet Explorer

j File Edit View Favorites lo o k Help

q a a H 3 1 d B ack S top R efresh Home S earch Favorite History j M aJ Print

Links gtgt A ddress httpV localhost 308QoryleV PetailCorterV 020i8SC l4

MM

Edit

Search Books

Home

Category

Author

Title

ISBN

PublisherDate

TinyBookStore com

The C++ Programming Languageby B j a r n e S t r o u s t r u p

0

ISBN 0 2 0 1 8 8 9 5 4 4 A d d i s o n - W e s 1e y P ub Co 199 7

Reviews

P r i c e 31 47A v a i 1ab i 1i t y U s u a l 1 ys h i p s w i t h i n 24h o u r s

Aic t o c a r t

ijgJ Local intranet

140

^ | I myBook5torecom Shopping Cart - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

[v] I ^ -J JB ack - Stop R efresh Home S earch Favorites History lsquo Mail Print

Links A ddress 0 1 h ttp localhost8080servetA ddT oShoppingCart ~3 ltGdeg

Shopping Cart Item s Price

The C++ Programmi ng LanguageB j a r n e S t r o u s t r u p Q u a n t i 1 7 1

Price $ 3 1 4 7 Subtotal $ 3 1 4 7

d e l e t e

Total 31 47

Customer Information Microsoft Internet Explorer

File Edit View Favorites lo o ls Help bull _

bullgt 3i 4 n j j d a 31Back ~-j Stop- R efresh Home S earch Favorites History j Mail Print Edit

Link gtgt j Address ] j j h ttplocalhost SOSOcheekoot html

EMH1

~3

Customer Information

First name jFang

Middle initial |a

Last name Xiao

Email address fxiaomitecnet

Account password pooooc

0 1 Done

Credit card number 1234567891234567

Credit card type VisaC MasterCard

C Bluebir d C Fisher

Credit card holder jr ong Xiao

ard expire date (mmddyy) J010102

Select shipping method UPSO Express

O Normal C Abnormal

J |sect Local intranet

141

lt2] Order List - Microsoft Internet ExplorerFile |d i t View Fayotites lo o t Help

^ 3 ^ S i l S - j S tep R efresh Home Search Favorite History Mail Print h-

HFte-LLinks A ddress I g ] httplocalhost8030servletCustemeilrifoProcess 3 ^Go

Your order reads as followsE - M a i l A d d r e s s f x i a o

F a n g X i a o

ship to

T e l

11 e m s

pound] Pc

10821 W e s t e r n P l a z aOmahaME6 8 1 5 4

( 4 0 2 ) 4 9 6 - 7 5 7 0T i t l e T h e C++ P r o g r a m m i n g L a n g u a g e Q t y 1 P r i c e 31 47 S u b t o t a l 31 47

| a [ Local intianet rsquo

l i

T inyB ookSloiecom - Microsoft Internet Explorer

T 7 ~ J iii 4 a i t Vi 1+ a Si

5 E

P r i te i+ A d d ie r I ig l httplocalhot8080ervletReqCollectauthor

S e a r c h B o o k s

Horne

Ca t e g o r y

A u th o r

Title

ISBN

P ublishe r Date

jS 1 D one

TinyBookStore com

fc t i t e r l i t n o rYou can enter authors full name first name or last name

A u t h o r |sCOtt

O ExactName amp Last F irst Name (or Initial)

T itiv b o o k s to re c o m H o a e | C a te g o ry | A u th o r | T itle | ISBN | P u b lish e r D ate

C opyright and disclaim ercopy 1999-2001 F an g Xiao

T op o f P f

|sect g j Local intranet

142

linyBookStore^com- MiciosoFUnteinet ExplorerFite Edit View Favorites Tools Ftelp

IIl4 rsquojO IjjlI - 3 -Upraquo 8 a c k ltbullltbullbullltlaquo Stop R efresh Home S earch Favorites History Mail Print 1

| Links 1 Address j raquo 3 http7localhost8CI80servletAuthorProcess

l - i f l |x |

S e a r c h B o o k s

Home

C a t e g o r y

Ti t le

ISBN

P ublishe r D a te

D o n e-

TinyB o okStore com

1- Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

I G aleampory I A utho t | I jt te | ISBN | PubH shei^D atg

i t and disclaim erreg 1999-2001 F ang Xiao

Top of

l i Local intranet

j T iny8ookStorecom - M icrosoft Internet Explorer

Fite Edit View Favorites Tools Help

4- 5 ni M m ~ltpound C r =gt 2f|L i p | | | | | iAdiiill|^Thttp7localhost8080seivletD etailContent0201924889

U 3

S e a r c h B o o k s

H ome

C a t e g o r y

A u th o r

Title

ISBN

P u b lish e r P a te

TinyB o okStore com

Effective C++b y Scott Meyers

ISBN 0201924889 Addison-Wesley Pub Co 1995

R eviews

This is the review of Effective C++

R eader Comments

Price 3795 Availability U sually ships within 24 hours

Add to iosil

IIH LdcSiiihttahdt

143

l inyBookStorecom Shopping Cart - Microsoft Internet Explorer

4- -- _ t lS M JJ ltpound I 7 r mdash2--I or- Stop R efiesh Home S ea rch Favorites History Wait PrintBach

Links Y 1^ddtessj-^1 httDvVlocalliostiBOBOyservletMddToShoppinqCart 73 ^

0

Shopping Cart Item s

Effective C + +Scott Meyers Quantity 1

0 1 Done

delete

Price

Price $ 3 7 9 5 Su b to ta l $ 3 7 9 5

Total 3 7 9 5

IB~ht Locai intranet

bull 3 TinyBooKGIoFooom M icrosoft Internet Cxplorcr

Fite Edit View Favorites Tools Help

4- -4gt Lfl 4 r amp J J lt$ i icirsquo s J ~lAB ack Ti(^poundprV aTdV iS^Stop-T SfSjefre^ptr I i - M t s s j r y rvlih- i JPopSnr -JE

i i i l l l P I I I ^ I i l l ] httplocalhost8080servletR eqC ollectauthor

G3SJ

7 ^ Go

S e a r c h B o o k s

H om e

C a t e g o ry

A u th o r

Title

ISBN

Eytoiisiier Date

101 D one

T i n y B o o k S t o r e c o m

E n te r AuthorYou can enter authors full name first narne or last name

A u t h o r jCraig Larmen

E Exact N ante O Last F irst N ame (or Initial)

Search Now 1 Clear Form

I C ategory | A u th o r | j j t l s | ISBN |

C opyright and ctiiclali[er copy 1999-2001 F an g Xiao

T o p o fP ag e

^tDpcafihttangfe-

144

gj TinyBbokSlorecom - Microsoft Internet ExplorerFile Edit View F a v o n te s - Pools

4-1 4 gt_poundj Q Jl3S top R efresh Home S ea rch Favorites History Mail PrintCacl-

lsquo Unko A ddress j ig ] httplocalhostSOSCiservletAuthorProces 71

S e a r c h B o o k s

Home

C a t e o o r v

A u th o r

Tit le

ISBN

P ub l i she r D a t e

Titty Bo okStore com

1 Applying UM L and Pattern Usually ships in 24 hours Craig Larmen Prentice Hall 1997 Our Price 450

T im booksto re com Home | C ateg o ry | A u th o r | Title | I3BM | Publisher P a ts

C opyrigh t and disclaimer copy 1999-2001 F an g X iao IIg ] http7localhost 8080eopyright html Local intranet

7 j T inyBookStorecom - Microsoft Internet Explorer

^ 03 4 31 0 i -_r _j _T B ack ~j~ S top R efresh Hom e Search Favorites History Mail Print Edit

I Links Addiess AocalhcistiiiOciOserv-letCctailConfent0137488S07

u m m

S e a r c h B o o k s

HorneC a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r Date

Tiny Bo okStore com

Applying LOVIL and Patternby Craig Larmen

0 Price 450 Availability TJ sually ships within 24 hours

ISBN 013748880 Prentice Halil 997

R ev iew s

Tins is the review o f Applying UML and Pattern

R ea d er Com ments

Add to cart

01ll iPdSSIihirSdety

145

3 TinyBookStorecom Shopping Cart bull Microsoft internet ExplorerFile Edit View Favorites Tools Help

vJBeck

JStop Refresh

4Home

H Si - iS- -=dSearch Favorites History Mail Pnnt

Links rdquo Address jlti] httpVlocalhostBOSOservletAddToShoppingCart 3 ^ Gc

r o 1

Shopping Cirt J toms Price

A pplying UML and PatternCraig Larmen Quantity 1 Effective C++Scott Meyers Quantity 1

l i l le t e

delete

Price $ 4 5 0 Subtotal $45 0

Price $ 3 7 9 5 Subtotal $ 3 7 9 5

Total 82 95

d f g a j Local intranet

146

lt3 TinyBookStoiecom - Microsoft Internet ExplorerFile Edit View Favorites Io o ls Help

gt j i 4 a - a i [j JB ack Forward Stop Refresh Home S earch Favorites Histeiy Mail Print Edit

Links Address ] pound ] hiipVonahost803CeerveirsquoReqColectlsquoauthor

0 1 i

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r D a te

Tiny Bo okStore com

You can enter authors full name first name or last name

A u t h o r jJeff

O Exact N ame Last First N ame (or Initial)

Search Now i Clear Form

T inybookstorecotti H oinf | Category | A trthor | Title j ISBN | Publisher Date

Copyright and disclaimer copy 1999-2001 Fang Xiao

Top of Page

M Local intraZl

m TinyBook Stote com - Microsoft Internet Explorer

Fife Edit View Favorites Joo ls Help

ISregBack Stop Refresh Home S earch Favorites History Marl Print c

Lirrks Address samp] httplocalhost8080servletAuthorProcess ~z ^ Gc

S e a r c h B o o k s

H ome

CategoryA u th o r

Title

ISBN

P u b lishe r D a te

i M

TinyBookStore com

1 Progi aimning Windows bullwith M FC Usually slaps in 24 hours JeffProsise Microsoft P ress 1999 Our Price 4799

jnybo-okstorscom Homo | Category | A u th or | Title | ISBN | Publisher P a h

C opyright and disclaijRief copy 1999-liOO1 FangX iao

Loccii intranet

147

148

m I myUookSlorecom - Microsoft Internet ExplorerFile- pound d it View Favorite T ools Help

^ J ] 4 U J j j =jgt Stop R efresh Home S e a rc h Favorites History i Mail Print EditBack

Links AddressilaquojigThttplocalhost5 i380ser4eM D etailContent157231 pound350

rfgKxi

ldquo3 gt6deg

S e a r c h B o o k s

HorneC a teg o ry

A u th o r

Ti tle

ISBN

P ub l i she r D a t e

TinyBookStorecom

Programming Windows with M FCby JeffProsise

0

ISB N 1572316950 Micro s oft Pre s s 19 9 9

Price 4799 Availability Usually ships within 24 hours

R e N ew s

This is the review of Programming Windows with MFC

R eader Comments

A dd to cart

D one i jh j Local intranet

lt 3 TjryBook S tore com Shop p in g Cart - M icrosoft Internet Exolorer

File Edit View f a nute T ools Help

r 1B ack

J 3 Q 0J amp poundlr - Jlilip isS h lA ld rS s httpy |ocalhost8U 80AervletA ddToShoppingCait TSIIlli

Shopping Cart Item s

Program m ing W indow s w ith M F CJeffProsise Quantity 1A pplying UML a n d PatternCraig Larmen Quantity 1 E ffective C++Scott Meyers Quantity 1

d e le te

d elete

d elete

Price

Price $ 4 7 9 9 S u b to ta l $ 4 7 9 9

P rice $ 4 5 0 S u b to ta l $ 4 5 0

Price $ 3 7 9 5 S u b to ta l $ 3 7 9 5

Total 1 3 0 9 4

^ h W h e iM

S s i Local intranet

149

File Edit View Favorites lo o ls Help n4- -0 iS - M L U

Back Stop Refresh Home Search FavoritesJ

History I3 H H H B H H H BMail Pm Edit

Links rdquo Addrecs |s] hHplocalhogt5t8080servletReqCollectcategorii ^_____ bulllt bullbull llilltllll

Search Books

Home

Category

Author

Title

ISBNPublisherDate

TinyBookStore com

P r o g r a m m in g

AI g o r i t Lins CampC++ D e l p h i J a v a MFC P e r l s o f t w a r e D e s i g n UML V i s u a l B a s i c M o r e

Done

Web D e v e lo p m e n t

ASP Commercem C y b e r c u l t u r e HTML J a v a S c r i p t S e c u r i t y Web D e s ig n XML more

G r a p h i c s amp S o f t w a r e

Asobe CAD D es k t op P u b l i s h i n g G r a p h i c s M i c r o s o f t More

I J J ig Local intranet

150

finvBookStorecom - Microsoil Internet Explorer - j g j x

j Fite Edit Jfiew Favorites lo o ts Help

bull j 5 a i B ack lsquolti S top Refresh Home S e a tc h Favorites History Mail Print Edit

Links 1 Address |ltg] hitpVocalhostl-i030seryletCateciofyPreceigtVc03 ^ | g

S e a r c h B o o k s

Home CategoQ

A u th o r

Title

ISBN

Publishe r D a te

TinyBookStore com

1 Core Ja v a 2 Usually ships in 24 hoursCay S Horstmaun Prentice Hall 1999 Our Price 2579

2 Ja v a S erv let Programm itig Usually ships in 24 hoursJason Hunter i O Reilly 1993 Our Price 1977

3 Ju st J a v a 2 Usually ships in 24 hoursPerter van der Linden Prentice Hall 1999 Our Price 3149

Tinybookstorecom Home | C ategory | A u th o r | T itle | IbBN | Publisher D ateloRoIEage

n g Local intranet

ta

151

41 Tinytfookbtorecom - Microsoft Internet ExplorerFile gdit y iew Favorites JLools Help

1 ^ hgt a a a amp a j ri i - 3 bull a Back Forward Stop Refresh Home S earch Favorites History Mart Print Edit

lisLinteslsii Address ji^]h ttp localhost8D 8o7serv letD etailC ontent0130319336

M i

3 f^Gc

S e a r c h B o o k s

Homec a t e g o r y

Tiny Bo okStore com

Core Java 2by Cay S Horstmaun

El

ISBN 0130819336 Prentice H alil999

Reviews

This is the review of Core Java

R eader Comments

Price 2579 Availability U sually ships within 24 hours

I Add to car

S ] Done S i Local intranet

TinyBookStorecom Shopping Cart - Microsoft Internet Explorerfel11 File Eefit View Favorite l o o k H e lp

tljH|V| 4 a 3 j 09 c T J

Stop Refresh Home S e a rc h Favorites History j Mail Print

jiiLihkIi87js ^ B ie s S ij^ ] http Z localhost8080servletiddT oShoppirigC art

B I B

3= i

Shopping Cart Item s

Core Java 2Cay S Horstmaun Quantity 1

Icopy

t i l

delete

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Total 2 5 7 9

sal Local intranet

152

a TinvBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites J o o lr Fjelp

NBack

amp Id b iStop Refresh Home

ISearch Favorifes History - Mail Print Edit

Links gty I Address [ jg l httplocalhost8080servletD etailContent156592391 x d

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

T i t le

IS B N

Publisher Date

ampJ Lrl e

Tiny Bo okStore com

J a v a S erv le t Piograitmmigby Jason Hunter

a Price 1977 Availability XT sually ships within 24 hours

ISBN 15659239 lx O Refflvl998

R e N ew s

In this brand-new third edition of Java Servlet Programming author Bjame Stroustrup the creator of Java presents the full specification for the Java language and standard library a spec that will soon become the joint ISOANSI Java standard

j ~2J Local intranetm

dH T iny8ook5torecom Shopping Cart - Microsoft Internet Explorer

File pound d t y iew Favorites Io o ls HelpB H

a $ a i a a -Stop Refresh Home S ea rch Favorites Hi lory Mjl

3- lsquonr I

| j | i | H | g i | i | i d ^ | | | | l Q httplocalhost80S0servletAddToShoppirigCart J P

m

Shopping Cart Item s

Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d e le te

d e le te

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Price $ 1 9 7 7 S y b to ta l $ 1 9 7 7

Total 4 5 5 6

I O I

aiil

153

Lustomer Information - Microsoft Internet Explorerpoundite pounddit View Favorites Xoo|s Help

v- _) _ l 4 J I VB ack - Stop R efresh Home Search Favorites History Mail

Links gty] A ddress ] j i l h ttD localhost8080checkouthtm l

F -iVj ~f

l l i l i i

C u sto m er In fo rm a tio n

First name jFang

Middle initial lA

Last name fXiao

Email address jfxiao m itecnet

Account password jxxxxx

Credit card number ]1234567B91234567

Credit card type C VisaC M asterCard

C Bluebird O Fisher

Credit card holder jFang Xiao

Credit card expire date (mmddyy) jo 10102

Select shipping method c u p sC Express

NormalAbnormal

0 ] D one Local intranet

poundpound Order List - Microsoft Internet Explorer

s

Back

Li il raquo

Yiew Favorites l o o h Help

bullV Y lJ j X I T- lty S to p Refresh H o m e

amp 1 3 J - jrS earch Favorite History lt Mail Print

fcesssaampl httplocalhost8080servletCustom erlnfoProcess

Y o u r ord er reads as fo llow sE-Mail Address 6daomitecnet

Fang Xiao

ship to

Tel

Items

12345 Western PlazaOmahaNE68154(402) 123-4567

Title C ore Java 2 Qty 1 Price2579 Subtotal 2579

Tide Java Servlet ProjammingQty 1 Pnce 1977Subtotal 1977 Total4556

ffl|b ] Done kl Local intranet

154

mammmm 1

File Edit View Favorites lo o ts tieip

E=cl i u F t l H -n e -i i rdquo F j-oiilsquoiBillHistory lsquo gt1 ll Print Edit

iiiiiiiiiiiiiiiiiirsquo Links Address j-copy] http localhust 8080servletReqCollectisbn J

TinyBookStore com

Search Books

Home ISBN

Author

Title

IS B N

S e a r c h Hew C le a r Form

PubnsheuDate

Top o f PageITnjrbooksj^ore^ com Horne I C a te g o rv | ^ i t h o r | T i t Ie I ISBN | Publisher Date

- g ] http locdlho-st SOSOwelcome shtrnl

TinvBookStorecom - Microsoft Internet Exploier

poundaj Local intranetId

| File Edit View Favorites Tools Help

i -e -e u u r5_ _ _ a u ^ 4 - a a j Back Forward S top Refresh Home S earch Favorites History Hail Print Edit

Links A d d re ss ^ hitp rsquoIdcanc-stEtnSOservlltlsquoF-aqZoll-~ntispn z raquo h

TinyB o okStore com

S e a r c h B o o k s

Horne

A utho r

T itle

ISBN

P u b lish e r P a t e

fcntar ISBN

I SB H 1565922840

|sectplli||pbw||l| IliM M pifiillj

T rgU onL cirrti -nr Kini- | Cgtgpound-gg | Agithor | Title | ISBN f uhhe-rt Pete

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top o f Pag e

aipoundbull] O o n e Local intranet

155

File Edit View Favorites Tools Help

HUTinyBookStorecom - MicrosoH InternetExplorer

B ad-J J A J d -2r =3

Stop R efresh Home S e a rc h Favorites History Mail Print

Links ygt A ddress j ^ ] httpVlocalhost8080servletrsquoISBM Process

S e a r c h B o o k s

Horne

C a t e g o r y

A u th o r

T itle

IS B N

Pub l i she r D a t e

TinyB o okStore com

1 Learning Perl Usually ships m 24 hours Randal L Schwartz O Reilly 1997 Our Price 1997

T in vh ooksto re c o m H orne | C at ego tv | A u th o r | Title | ISBM | Publisher D ate

C opy rig h t a n d d isclaim ercopy 1999-2001 F a n g X iao

0 ] Done

yen

ighj Local i

TinyB ookStoiecom - Microsoft Internet Explorer

Erie Edrt View Favorites- lo o ls Help

-s pound] 4 pound1 jLl icArdquo =pound 2 S top Refresh Home S earch Favorites History Marl Print Edit

iilHI

NpBack

httpyiocalhostSOBOservleMDetailContentAI 565922840 ~T] Cm

Tiny Bo okStore com

S e a r c h B o o k s

H o m e i

C a teg o ry

A u th o r

T itle

ISBN

Publishe r D a te

Learning Perlby Randal L Schwartz

I ^

ISBN 1565922840 O Reillvl997

Price 1997 Availability U sually ships within 24 hours

Reviews

This is the review of learning Perl

Reader Comments M0 ] Done lsquofR | Local intranet

156

IHHHHHI _ I f f i x |

File E d t yiew Favorites J o e ls H elp 11v- -__ l

Back ~ rc Stop R efresh Home S earch Favorites HistoryJ rMail

HH1111Pgtnt

Links A ddress | ] http7docalhost8030servleM AddToShoppingCart 3 tgt G o

O S III

Shopping Cart Item s

Learning PeriRandal L Schwartz Quantity 1

delete

Price

Price $ 1 9 9 7 Subtota l $ 1 9 9 7

Total 1 9 9 7

s

Done Local intranet

Eg W illi 1 lttMM41 i H H p n B n 1 0 1 x i

Fite Edit View Favorites Toots Help E H

1$3 L plusmn J8ack Forward Stop Refresh Home Search Favoutes

4History i

- i V -=JMail Print

-Edit

71 Address http7localhost8080lsquoservletFleqCollecVisbn I l f i l l l

TinyBookStore com

Search Books

Home

C ateao rv

Author

Title

ISBN

Publisher D a te

Enter ISSN

i s bit [l 565921496

Search Now I Clear Form

Tinybookstore o n Home | Category | A uthor | Titb | ISBN | Publisher Dte

Copyright arid disclaimer copy 1999-2001 Fang Xiao zl amp j Done Js J Local intranet I

157

H H H r f e i x i File Edit View Favorites Lools Help

- J j j j ] JBack Stop Fiefresh Home Search

J JFavorites-

-J i C rHistory Mail Print

111111811i n

r Links wj i Address |reg] http docalhost 8080servletIS8N Process

S ea rch B ooks

Home

Category-

rdquo A u th o r

T i t l e

IS B fi

P u b l i s h e r D a ta

Tiny Bo okStore com

1 Programtning Perl Usually ships in 24 hours Larry Wall O Reilly 1997 Our Price 2397

T o o k s t o r e c o m H P in e | C a t e g o r y | A u t h o r | Till | IS B N | P -ubtu-hai D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g X ia

T o p o f P a g e

zlamp2 Done Local intranet

158

lt3 l mytfookSlorecom - Microsoft Internet ExplorerF3e Edit View FavoMes lo o ts Help

Back3 U Si S rsquo IStop Refresh Home lt Search Favorites History Mail Print Edit

httplocalhost8080servletDetailContent15S5321496 j3

Search Books

Horns

Category

Author

Title

ISBN

Publisher Date

Done

TinyB o okStore com

Programming Perlby Larry Wall

0 Price 2397 Av ail ability U sually ships within 24 hours

ISBN 1565921496 O Reillyl997

Reviews

This is the review of Programming Perl

Reader Comments

Add to cart

l or=lM

159

Tm vBookSlorecom Shopping Cart - M icrosoft Internet Explorer

i Fite Edit View Favorites lo o k Help

^ Beck R efresh Home

ampS earch Favorites History j Mail Print

E Links I Address ] pound http localhost 8080servletA ddT oShoppingCart rsquo ] O rai

i O

Shopping Cart Jlems

Learning Peri Randal L Schwartz Quantity 1 Program m ing PeriLarry W all Quantity 1

delete

d e le te

Price

Price $ 1 9 9 7 S u b to ta l $ 1 9 9 7

Price $ 2 3 9 7 S u b to ta l $ 2 3 9 7

Total 4 3 9 4

3SJ Done j | s [ Local intranet

160

m m mmmHi mmmHHHHHi1 File Edit View Favorites Tools Help

^ - J J -ih Ji - j| B a d Forward Stop Refresh Home S earch FavoritesHIH ctuv Mjl Print

IHIlllliEd

B l

MbfeifcssfjP Address httplocalhost8080servletFleqCollectpLiblisher_date_ ___ ________ ___________ _ bull bull bull bull_________________ Zi T gt 6 o

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

Title

ISBN

Publishe r P a t e

S ] Done

TinyBo okStore com

T rsquov -

Publisher

sind IPpiIs1iclaquoifciori OsifiC

jAd cl i so n-VVe oI e y Fuo C o ~

P u b l i c a t i o n D a t e 1U97

Search Now Clear Form

T inybookstore com Home | C ategory j A u tho r j I itle | ISBN | Publisher Ds

C opyright and disclaimer copy 1999-2001 F an g Xiao

T op o f Page

g a l Local intranet

161

lt|j TinyBookStoiecom - Microsoft Internet Explorerlsquo Erie Edit View Favorites lo o ls Help

v-1 Q rij - 3 rsquo- a u -=pound Ci Back s lsquoi i 1 Stop Refresh Home S earch Favorites History Mail Print i

jL inks i A ddress 0 1 http7localhost8Q80servletPublisherDateProcess

EMM

3

S e a r c h B o o k s

Home

C a t e g o r y

Author Title

ISBN

Publisher D a te

TinyBookStore com

1- Algorithm s in C Usually ships in 24 hoursRobert Sedgewick Addison-Wesley Pub Co 1997 Our Price 4495

2 The C++ P rogr amming L anguage Usually ships in 24 hourBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

3 Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

4- U M L D istilled Usually ships in 24 horn sMartin Fowler Addison-Wesley Pub Co 1997 Our Price 2995

Done | s j L ocalm

TinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorites l o o k Help

Backamp 3 $ -Q 3 3 AJStop Refresh Home S earch Favorites History Mail Print Edit

Lipikkigt7i Ajddr$esjhttpv7localhost8080-servletDetailCoriterit0201314525

m

3 rgtGc

S earch B ooks

Horne

A uthor

Title

ISBN

Publisher D a te

Tiny BookStore com

Algorithms in Cby Robert Sedgewick

S

ISBN 0201314525 Addison-Wesley Pub Co 1995

Reviews

This is the review of Algorithms in C

Reader Comments

Price 4495 Availability U sually ships within 24 hours

Add to cart

0I reg S a i t^ s a l intranet

162

File Edit View Favorites lo o ls Help

2 ^ iVi ^ ^ t j j B ack gt Stop Refresh Home S ea rch Favorites History ||

- i -Mail Print

WB0BUBSSSI B ifl

Links ygt Addrese |isect ] httpvVlocalhostSOSChservletAddToShoppingCart

Shopping Cart Item s

A lgontfim s in CRobert Sedgewick Quantity 1

0 1 D one

delete-

Price

Price $ 4 4 9 5 Subtota l $ 4 4 9 5

Total 4 4 9 5

Local intranet

163

^ l inyBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

ls31

3 bullrsquo -I- _J _jj - j i_ 3 - j rdquo -= $ ABack Forward Stop Refresh Home Search Favorites History Mail Print Edit

Links rdquo Address 6 J http Vlocalhost SOSOAervletR eqCollectpublisher_date j ^G

Search B o o k s

Home

categoryAutho r

Title

IS B N

Publi sher D a te

TinyBookStore com

liter Publisher and Publication Date

P u b l i s h e r Wrox Press Inc

P u b l i c a t i o n D a t e ]1

Search Now j Clear Form

T invbookstor ecotnHomg | Category | A uthor | Title | ISBN | Pu b lish e rP a t

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top of Page

zD one Local infra

m TinyB ookStoiecom - Microsoft Internet Explorer

R e Edit View Favorites Tools Help

- -i 13 4 St 2J amp t r - JHB-1

fff ij if P S | Address |sjpound~| httpVlocalhost8030servletPublisherDateProcess

S e a r c h B o o k s

Home

C a t e g o r y

A utho r

T itle

ISBN

Publisher D a te

0 ] Done

TinyBookStore com

1 Beginning Visual Basic 6 Database Programming Usually ships in 24 hour John Connell W rox Press Inc 1998 Our Price 3199

2 Befmiung Visual Basic 6 Usually ships in 24 hours Peter Wright Wrox Press Inc 1998 Our Price 3199

T inybookstore com H orae | C ategory | A u thor | Title | ISBN | Publisher Date

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top o f Fas

Local intranet

64

| File Edit Yiew Favorites T ook Help

i A - + - - a S 3 rsquo reg - pound J -3 Back ldquo d Stop Refresh Home Search Favorites History

- vMail Print

i

Edit

IllplBlllll________ g - M

isisfcinbsijp Addre s | g ) httplocalhost8080servletDetailCoritent1861001061 3 Gdeg

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

T itle

ISBN

Publishe r D a te

TinyBookStore com

Beginning Visual Basic 6 Database Programmingby John Connell

a Price 3199 Availability U sually ships within 24 hours

ISBN 1861001061 Wrox Press Inc 1998

Reviews

This is the review of beginning Visual Basic 6 Database Programming

Reader Comments

A d d to c a n

S] pone Local intranet

m u i

lillllEHl ^ bdquo A 3 2tl 4 t M liJ i

Back Forward Stop Refresh Home Search Favorites3

History 4 _ r

M j 1J

Print EditiSillilillllS

httplocalhost8080servletReqCollecttitle

S e a r c h B o o k s

Home

C a t e g o r y

Author

Title

ISBN

Publisher Date

TinyB o okStore com

Enter TicleYou can enter the exact title or part of title

T i t l e C++

O Exact Title Title Words

Search Now Clear Form

Example

bull Entering Java Servlet Programming in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title are related to Java _li

165

lt5 TinyBookStorecom - Microsoft Internet ExplorerFite Edit View Favorites lo o ts Help

Back Stop Refresh Home S earch Favorites History Mail Print

Links gty Addiess http-localhost8080servlet7TitleProcess

i|p1

I

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

Publi sher IS a t e

TinyBookStore com

1 The C++ Programming L anguage Usually ships in 24 hoursBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

2 Effective C+-F Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

3 Programttung Visual C-H- Usually ships in 24 hours David J Kmglinski Microsoft Press 1998 Our Price 3999

T m y h o o k s to e co m H o m e | C a te g o ry | A u th o r | T itle | ISBH | P u b lish er D ate

http iocalhost SOSOservletFleqCollectcategary

T op of P age

~hj Local intranet

bull a TlnjpBflOkStOfecom - Microsoft Internet Explorer

File Edit View Favorite Pools Help

0 3 4 S l i 3 O - J J i t of Stop Refresh Home S earch Favorites History - Mart Print Edit

HBack

i i i i lS i lB i I i f f id i l f f lH Q http Vlocalhost 8080AervletD etailContent1572318570

EEEI

J

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b lis h e r D a f t

TinyBookStore com

Programming Visual C++by David J KrngHnski

[Hj

ISBN 1572318570Microsoft Press 1998

Price 3999 Availability Usually ships within 24 hours

R e v ie w s

This is the review o f Programming Visual1

Reader Comments

Add to cart

if Local intranet

166

mm| File pounddtt View Favorites Jo o ls Help

c J J j j mdash JB ack - J Stop Refresh Home S earch Favorites History

- _ i -M u

J tPrint

t e t a f e w P A ddress | ^ ] httplocalhost8080servletAddToShoppingCart zl -lt1gtSo

Shopping Cart Item s

Programmeng Visual C + +David J Kmgbnski Quantity 1

delete-

Price

Price $ 3 0 9 0 Sub to ta l $ 3 9 9 9

Total 3 0 9 9

D one ^aj Local intranet

TinyBookStorecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

vHBack-

-J a 4 -a si fi- 3 aStop R efresh Home S earch Favorites History j Mail Print- Edit

Links gty A d d re s sL ^ ] hrtpWlocalhostSOSOservleVFIeqCollectAitle

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

ISBN

Pub l i she r Date

TinyBookStore com

Enter TitleYou can enter the exact title or part of title

Title Distil I nrfExact T itle V T itle W o rd s

Search Now | Cle ar Fo rm

Examples

rpound] Done

bull Entering Java Servlet Programming11 in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title arei date 11 j Java JZJ

167

a TlnyBA5kSioiecom - Microsoft Internet Explorergt 0e Edit ifiew Favorites Jock Jd lp

a a amp -a tii j k i Back s - Stop Refresh Home Search Favorites History Mail Print

liilP raquo httpiVlocalhostSOSOservletTitleProcess

E M 3

ldquo3 rgt-

S ea rch B ook s

Horne

C a t e d o r v

A utho r

TiUgt~ ISSN

Publi sher D a te

Tiny BookStore com

1- TJML D istilled Usually ships in 24 nowsMartin Fowler Addis on-Wesley Pub Co 1997 Our Price 2995

| C s rg g o ty | A u th o r | T itle | IStBH I P u b lis h e r D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g Xiao

-jg Local intranetS3

m n ^ i l a i i x l

File Edd View Favorites Joels- Help M Mi r J lt 3 L h f 4 - 0 lt 3

Back i t Stop Refresh Home S earch Favorites History Mail9

PrintM

Edit

Links raquo A ddress j | i ] http do ca lh o d 1030N m letDetailContenr0201325632 Mimas

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

Title

IS B N

Publisher Date

Tiny BookStore com

TJML Distilledby Martin Fowler

0

ISBN 0201325632 Addison-Weslev Pub Co 1997

Reviews

Tins is the review of The UML Distilled

Reader Comments

Price 2995 Avail abilityTJs u ally ships within 24 hours

Add to c a r t

0 3S i] Done |g^iLnealiihfrregei

TinyBookStorecom Shopping Cart Microsoft Internet ExplorerFile Edit View Favorites Jo o ls HetP

IBiiiBlll l l lHBlSglSlllllilMH MlllBliriilllgllSlIlBack - f - i - S top Refresh Home

a J i l ^ j 3 Search Favorites History 1 Mail Print liiii

3 Links ( A ddress j ig j hrtplocalhost803DservletAddToShoppingCart

Shopping Cart Herns Price

UML D istilledMartin Fowler Quantity 1Program m ing Visual C + +David J Kraglinski Quantity 1

Price $ 2 9 9 5 Subtota l $ 2 9 9 5

delete

Price $ 3 9 9 9 Subtota l $ 3 9 9 9d elete

Total 6 9 9 4

  • Electronic Commerce on Business Application
    • Recommended Citation
      • tmp1499779448pdf2JOpQ

45 Session Tracking 35

46 Check O ut42

47 Customer Information Processing 43

Chapter 5 Future Work50

51 Connection Pooling50

52 More Object-Oriented - Better Encapsulation51

Chapter 6 Conclusion 53

Appendix A Bibliography54

Appendix B The Source Code of An On-Line Store System -

Tiny Book Store57

Appendix C Screen Display of the Test 135

List of Figure

Figure 261 The Structure of An Online Store 10

Figure 321 Handle Requests Flow Chart 13

Figure 331 HttpService of The Java Web Server Using Servlets 15

Figure 411 The Home Page of Tiny Book Store 22

Figure 412 One of The Searching by Author Pages26

Figure 441 One of The Outputs of Servlet AuthorProces 34

Figure 451 A Page Show All Information About A Book 39

Figure 452 A Page Show Items In The Shopping Cart After A User

Added Books To The Shopping Cart 40

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A

Book From The Shopping Cart42

Figure 461 A Check Out Page 43

Figure 471 An Invoice Page48

1

Chapter 1

Introduction

As we step in the year 2000 we can no longer look to the past as the guide for the

future A combination of business social and technical possibilities drives the rapid

progress in electronic commerce

Electronic commerce can offer a company both short-term and long-term benefits

Not only can it open new markets enabling a business firm to reach new customers

but it can also make it easier and faster for the firm to do business with their existing

customer base Moving business practices such as ordering invoicing and customer

support to network-based systems can also reduce the paperwork involved in

business-to-business transactions When more of the information is digitized it

allows that business firm to focus on meeting their customerrsquos needs Tracking

customer feedbacks and presenting customer solutions for their clientele are just

some of the opportunities that can stem from electronic commerce

2

Chapter 2

Electronic- Commerce

21 What Is Electronic Commerce

For some time now large business enterprises have used electronic commerce to conduct

their business-to-business transactions In early 1960 private networks were dedicated

for the use of electronic data interchange (EDI) and electronic funds transfer (EFT) in the

banking industry Recently however with the increased awareness and popularity of the

Internet electronic commerce has come to encompass individual consumers as well as

businesses of all size

To many electronic commerce is defined as the buying and selling of products and

service over the Internet But there are many other aspects Depending on whom you ask

electronic commerce has different definitions

From a communications perspective electronic commerce is the delivery of information

productsservices or payments via telephone lines computer networks or any other

means From a business process perspective electronic commerce is the application of

technology toward the automation of business transactions and workflow From a service

perspective electronic commerce is a tool that addresses the desire of firms consumers

and management to cut service costs while improving the quality of goods and increasing

3

the speed of service delivery From an online perspective electronic commerce provides

the capability of buying and selling products and information on the Internet and other

online services [16]

These definitions are valid with their perspectives It is a matter of which lens is used to

view the electronic commerce landscape Broadly speaking electronic commerce

emphasizes the generation and exploitation of new business opportunities by ldquogenerating

business valuerdquo or ldquodoing more with lessrdquo

22 The Importance of Electronic Commerce

As we approach the year 2000 we can no longer look to the past as guide to the future In

the face of strong market forces created by electronic commerce and mounting

competition corporations can no longer plod along historical tracks or seek the

preservation of the status quo Companies are discovering that old solutions do not work

with new problems The business parameters have changed and so have the risks and

payoffs

23 Types of Electronic Commerce

From a broad view there are three distinct general classes of electronic commerce

applications Inter-organizational (business-to-business) intra-organizational (within

business) and customer-to-business application [16]

4

231 Inter-Organizational Electronic Commerce

Inter-organizational electronic commerce makes business more convenient on the

following aspects

Firstly e-commerce can improve supplier management since electronic applications can

reduce the processing costs and cycle times for each purchase order and it can reduce the

number of people who work on purchase orders

Secondly e-commerce can improve inventory management since electronic applications

make the business partners can fast exchange information and easy track their documents

to ensure that they were received This not only can eliminate out-of-stock occurrences

but also can reduce inventory and improve inventory turn

Thirdly e-commerce can improve distribution management since electronic applications

can make the business partners receive the shipping documents as soon as possible and

enable better resource management by ensuring that the documents contain more accurate

data

Fourthly e-commerce can improve channel management since electronic application can

let the business partner post the information to electronic bulletin boards This can

eliminate repeated telephone calls and countless labor hours

Fifthly e-commerce can improve payment management since the business partner are

linked by network so the payments can be sent and received electronically Electronic

payment is more accurate and fast than traditional payment

232 Intra-Organizational Electronic Commerce

5

Intra-organizational electronic commerce facilities the following business applications

Workgroup communications Electronic applications enable manager to

communicate with employees using electronic mail videoconferencing and

bulletin boards

Electronic publishing Electronic applications enable companies to publish

information by using tools such as the World Wide Web On-line publishing can

show information immediately and clearly and reduce costs for printing and

distributing documentation

Sales promotion Electronic application improve the flow of information between

the production and sales forces and between the firms and customers This can

make companies have greater access to market and competitor information

Today Intranets are primarily set up to publish and access vital corporate information

Some of the most common types of information are Human Resources information

employee communications product development and project management data internal

catalogs sales support data equipment and shipment tracking and accessing corporate

database

233 Consumer-To-Business Electronic Commerce

In consumer-to-business transactions customers learn about products through electronic

publishing buy products with electronic cash and other secure payment systems and

even have information goods delivered over the network

6

From the consumerrsquos perspective there are three transactions

1 Electronic applications enable consumers to communicate with each other through

electronic mail videoconferencing and news groups

2 Electronic applications enable consumers to manage investments and personal finances

using online banking tools

3 Electronic application enable consumers to find online information about existing and

new products services

Consumers consistently demand greater convenience and lower prices Electronic

commerce provides consumers with convenient shopping methods from online catalog

ordering to phone banking both of which eliminate the costs of expensive retail

branches Electronic commerce facilitates factory orders by eliminating many

intermediary steps thereby reducing manufacturersrsquo inventory and distribution costs and

indirectly providing consumers with lower prices

24 Why Most Internet Based Electronic Commerce Is In The Business-To-

Consumer World

For the Business-to-Business e-commerce the lack of well-accepted standards is

hindering the success in promoting Business-to-Business electronic commerce

solutions[5] VAN (Value-Added Networks) EDI (Electronic Data Interchange) based

solutions are only accessible to large organizations due to the cost factor Corporate

buyers and suppliers large and small are looking for Internet based solutions to

streamline the procurement procedures and to reduce the cost of establishing trading

relationship and the trading transactions Such demands put forward some fundamental

challenge on issue like trust infrastructure on the Internet standards and inter-operability

etc

25 Current State of Business-To-Consumer E-Commerce

Business activity on the Internet is currently limited to publicizing the business

opportunity and to catalog based sales but it will rapidly expand to include the

negotiations conducted to settle the price of the goods or commodities being traded

These negotiations are currently conducted by human intermediaries through various

forms of auctions bidding systems for awarding contracts and brokerages The role of

the intermediaries can now be performed by Internet trading applications at a fraction of

the cost[4] Trading on the Internet allows a business to reach a large number of potential

customers and suppliers in a shorter time and a lower cost than possible by other modes

of communication and to settle business transaction with lower cost overhead in a shorter

time

Auctioned or brokered sales are the norm in business world for negotiating trades of large

monetary value But consumer sales and small-scale purchases have used the fixed price

mode perhaps because of the high overhead cost of using the auction or brokerage

method The new economics of the Internet will make auctions popular in consumer and

small business transactions also

Auctions are just one form of business negotiations Other examples are competitive bids

for procurement brokeragesexchangescartels and two party negotiations

Nowadays the free-market economy of software agents is in the embryonic stage But in

the near future the software agents will populate the Internet and provide trade and use

a rich variety of information goods and services in an open free-market economy In a

free-market economy of software agents information is produced traded and consumed

by vast numbers of autonomous self-motivated agents An essential task in such an

economy is the retailing or brokering of information gathering it from the right

producers and distributing it to the right consumers[10] The overall research goal is to

characterize and understand the dynamic behavior of information economies very large

open economies of automated information agents that are likely to come into existence in

the Internet

26 The Structure of The On-Line Store

9

Nowadays there are thousands of on-line stores running on the Internet A few well-

known ones are amazoncom and bookpoolcom Most of such applications involve

common functions which are as following

Searching for product information

Ordering products

Paying for goods and services

Providing online customer service

So they have a similar structure as shown in Figure 261 The system contains the

following components

1 A web server running continuously accepts userrsquos connection gets user requests and

forward requests to business procedure retrieves data (answers to user requests) from

business procedure and send it back to user

2 Business procedure usually consists of a user identification procedure like credit card

check user request analysis procedure analyzing requests calculating discomposing (if

necessary) and dispatching request to different data source component Also in some

case business procedure is responsible to compose data obtained from different data

sources into user-readable format

3 Database is the place to hold relevant data These data not only serve as a data source

describing commercial goods and prices but can be used for data mining to improve

store service quality as well Database is updated and maintained by both customersrsquo

input and system applications A customerrsquos input usually includes order information

10

Figure 261 The Structure of An Online Store

(through browser)

Databas

(through browser)client

client

serverWeb

Systemapplication

Busines

procedu

4 System applications can include a search engine running all the time and searching

relevant information from the internet data mining application deals with mining and

analyzing customer and sale data for management use database maintaining application

handles update data when product information changes Varying from system size to

system size not every system has cleardistinct boundaries between these components

The system can be 3-tired or n-tired but these systems all operate in similar ways

11

Chapter 3

Technologies For On-Line Store System

An on-line store system is different from traditional web publishing It needs customerrsquos

interactive communications and frequent data update The traditional HTML page is

insufficient because all it does is provide static content publishing Other technologies

are required in order to implement the on-line store

Currently there are three mainstream technologies which are widely used Common

Gateway Interface (CGI) Microsoft Active Server Page (ASP) and Server-side Java

application We briefly explore these technologies here

31 Traditional Web Application - Common Gateway Interface (CGI)

The common Gateway Interface normally referred to as CGI is one of the first practical

techniques for creating dynamic content With CGI a web server passes certain requests

to an external program The output of this program is then sent to the client in place of a

static file The advent of CGI makes it possible to implement all sorts of new

functionality in web pages and CGI quickly become a defacto standard implemented on

dozens of web servers Even though a CGI program can be written in almost any

language the Perl programming language is the predominant choice However CGI have

some distinct disadvantages

Firstly CGI program is transient A request is made each time to a CGI program It must

be loaded and executed by the Web server When the CGI program is complete it is

removed from memory and the results are returned to the client All program

initialization (such as connecting to a database) must be repeated each time a CGI

program is used

Secondly when a server receives a request that accesses a CGI program it must create a

new process to run the CGI program and then pass to it via environment variables and

standard input Every bit of information might be necessary to generate a response

Creating a process for every such request requires time and significant server resources

which limits the number of requests a server can handle concurrently

Thirdly a CGI program cannot interact with the web server or take the advantage of the

serverrsquos abilities once it begins execution because it is running in a separate process

32 Active Server Page

As shown in figure 321 the following list walks you step-by-step through what

happens if the client requests the page xyzasp

The client requests the page xyzasp from the server The Web server checks the file

extension to see whether a special program (such as the Active server Pages engine)

13

must be invoked to process the request If therersquos a asp extension the Web server

determines that it should invoke ASP to process this page

Figure 321 Handle Requests Flow Chart

Request

Response

WEB SERVERComponents

Databas

ns

ASP File

CLIENT

Active X Data

VBScript

If this page has never been requested before or has been changed since the last

request it must be parsed and the syntax checked and then be compiled by the Web

server Otherwise the page might be read from a cache of recently processed pages

which aids in performance During the parsing process the HTML and scripting code

14

are separated IIS (Internet Information Server) determines which scripting engine is

responsible for which part of the script and delegates the work of syntax checking and

compiling to the proper scripting engine (such as VB Script)

Now the code is executed by the scripting engine using resources from IIS which is

hosting the scripting engines All objects that the language engine cannot handle are

requested by the IIS which is also responsible for handling inputs and outputs for the

external ActiveX objects that are created and used inside the script If it is not able to

supply the object an error is generated

Script output and static HTML code in the ASP file are merged

The final HTML is sent back to the user in an HTTP response

The important point about ASP is that the Script runs entirely in a server to protect the

intellectual property by shielding it from browser which are different from the account

for when writing client-side code The entire server-side code is processed and only plain

HTML - or whatever kind of content you chose to generate - is sent to the client

33 Server-Side Java Application

The rise of server-side Java applications is one of the latest and most exciting trends in

Java programming A Servlet can be thought of as a server-side applet Servlets are

loaded and executed by a Web server in the same manner that applets are loaded and

executed by a Web browser

15

As shown in Figure 331 a servlet accepts requests from a client (via the Web server)

performs some task and returns the results

The client (mostly likely a Web browser) makes a request via HTTP The Web server

receives the request and forwards it to the servlet If the servlet has not yet been loaded

the Web server will load it into the Java virtual machine and execute it The servlet will

receive the HTTP request perform some type of process and return a response back to

the Web server The Web server will forward the response to the client

Figure 331 HttpService of The Java Web Server Using Servlets

RequestResponseRequestResponse

RequestResponse

Java Web Server

Administrative SERVLET

SERVLETHTTP

SERVLETWeb Proxy

Servlets have distinct advantages over CGI program

Servlets are persistent Servlets are loaded only once by the Web server and can

maintain services (such as a database connection) between requests

Servlets are fast since servlets only need to be loaded once

16

Servlets are platform independent Servlets are written in Java and conform to a well-

defined and widely accepted API They are highly portable across operating systems

and across server implementations A servlet can be developed on a Windows NT

machine running the Java Web Server and later can be deployed effortlessly on a

high-end Unix server running Apache

Servlet portability is not the stumbling block it so often is with applets There are two

reasons Firstly servlet portability is not mandatory Unlike applets which have to be

tested on all possible client platforms servlets have to work only in the server

machines that you are using for development and deployment Unless you are in the

business of selling your servlets you donrsquot have to worry about complete portability

Secondly servlets avoid the most error-prone and inconsistently implemented portion

of the Java language the Abstract Windowing toolkit (AWT) that forms the basis of

Java graphical user interfaces

Servlets are extendable Servlets that are written in Java brings all of the other

benefits of Java to servlet Java is a robust object-oriented programming language

which can be extended easily to suit our needs

Servlets are secure The only way to invoke a servlet from the outside world is

through a Web server This brings a high level of security especially if the Web

server is protected behind a firewall

Servlets can be used with a variety of clients

Servlets are tightly integrated with the server This integration allows a servlet to

cooperate with the server For example a servlet can use the server to translate file

paths to perform logging and to check authorization

Servlets are quite flexible An HTTP servlet can be used to generate a complete web

page it can be added to a static page using a ltSERVLETgt tag in whatrsquos know as a

server-side include and it can be used in cooperation with any number of other

servlets to filter content in something called a servlet chain

18

Chapter 4

Design of On-line Bookstore Using Java Servlets A Practical

Verification

Server-side Java application is one of the latest technologies used to implement an onshy

line store system Servlet is a set of classes that come up from Java language It is

designed to be used for server-side Java applications There are many techniques people

can use when they utilize servlet such as Server-Side Include (SSI) Servlet Chaining

Applet and Servlet communication etc We tried to use as many such techniques as

necessary in our implementation to demonstrate the advantages of servlets

The demonstration system module is same as the one we mentioned above Figure 331

We use this module to show how such system works

The system called Tiny Book Store emulates an on-line bookstore selling computer

books It has the full functionality of other on-line stores The only difference between

this system and the other on-line systems is the database size We donrsquot want to spend

much developing time for database maintaining part because this part is similar to

ordinary database maintaining and it is an independent subsystem The Tiny Book Store

mainly consists of three modules user interface business procedure and data access

19

41 The Design of Home Page of Tiny Book Store

The home page - welcome page - is designed using the Server-Side Include technique

That is embedding a servlet inside HTML file with a specific HTML tag ltSERVLETgt

In our case this servlet when invoked can run a query on database via data access

objects to retrieve most recent top 5 best-seller books and then returns the retrieved data

to the place within the page where the ltSERVLETgt tag was As long as the data in

database update timely it is guaranteed that customer will get the most recent data

The embedded servlet is invoked by Java Web Server before the page is sent back to

client Java Web Server processes any HTML file having shtml extension and invokes

the embedded servlet marked by ltSERVLETgt tags

Server-Side Includes are useful when a page is primarily static but contains a few distinct

dynamic portions One of the servlets produces the ldquo Five Hot Books ldquo which is shown in

the following example

Example 411 A Part of Code of welcomeshtml

lt P gt

lth3xstrongxf ont color= f f 6347 gtWelcome to theltigt

TinyBookStorecomltigtltfontgtltstronggtlth3 gt

20

ltstrongxbxh3gtltcentergtFive Hot

Booksltc e n t e r x h3gtltbgtltstronggt

ltbrgt

ltservlet code=EchoServletTaggt

ltservletgt

The servlet EchoServletTag searches database according to some business rule and gets

data from data access objects to produce the Five Hot Books The following example is

the sample code

Example 412 A Part of Code of The EchoServletTagjava

public void service(HttpServletRequest req

HttpServletResponse res)

throws ServletException IOException

res setContentType ( text Jhtml)

PrintWriter out = resgetWriter()

try

Statement stmt = concreateStatement()

21

ResultSet rs = stmtexecuteQuery(select from

book where

title like Programming)

int count = 1

outprintln(ltdlgt)

while (rsnext() ampamp count lt 6)

out print In ( ltdtxbgt + count + )

String isbn =

rsgetObj ect(ISBN) toString()

outprintln(lta

href=servletDetailContent + isbn +

outprintln(rsgetObj ect(Title) toString()

+ lt a x bgt )

out println ( ltddxnobrxfont color=990033gtUsuallY

ships in 24 hoursltBRxfontxnobrgt )

outprintIn(ltbrgt +

rsgetObject(Author) toString() )

outprintIn( +

r s getObject(Publisher)toString() + +

r s getObj ect(PublicationDate) toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

out println ltbrxbrgt )

22

count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()

The servelt EchoServletTag by the business mle that searching a specific table sends a

request query through data access object stmt and gets search result through another

data access object rs It then passes data to the page The content between ltservletgt and

ltservletgt tags in the HTML of home page is replaced by the search result at run time

The center part of the sample result page in Figure 411 is an example

23

Figure 411 The Home Page of Tiny Book Store

gj Search TinybookstGiecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

^ bullgt o a 4 i a a j ugt- a a Back lt7gtn Stop Refresh Home j Search Favorites History Mail Print Etfe

-Six

sfekinlfeSsI 3 Address |iS1 httpiVlocalhosLSOSCVwelcomeshtrnl Cj

f S M B l TinyBookStorecom

Search B o o k sW e l c o m e tc f l i e

HomeFive H ot Books 1 1

Category i-si

IA uthor

Title1 The C + + Programming L a n g u a g e B

Usually ships in 114 hoursISBN

k

IPublisher D a teBjame Stroustrup Addis on-Wesley Pub Co 1997Our Price 3147

m2 Programming Visual C+ +

Usually ships in 24 hours y

David J Krn^dinski Dlicrosoft Press 1998 c damp Local intranet

From this practice we know Server-Side Include not only can produce dynamic portion

of the page but also prevent from other people spy into your code Since Java servlet runs

entirely on a server thus protecting your intellectual property and shielding you from the

browser This means what the client sees can be totally different from what the server

does From the client side it is difficult to figure out how the server works

The left-hand menu items are implemented by using a characteristic of servlet - extra

path information or virtual path The extra path information can be used as a kind of

parameter passed to a servlet In general this extra path information is used to indicate a

24

file on the server that should use for something We use this feature here in an abnormal

way to manage customer requests and process these requests in a single place

Consider a traditional method When a menu item is selected by a customer it redirects

the customer to another page where it hyperlinks to If we have several ten items we

need to pre-create several ten pages This is the disadvantage of static HTML pages

However with servlet which can dynamically generate page content we can direct all the

customer requests to a central servlet and process the requests there according to some

condition (parameters) and then generate the page which customer need to see In this

way we only need one place to hold the code to save serverrsquos space And this place is

easy to maintain

The following is how it was doing for the Tiny Book Store

The Author item uses the following hyperlink

ltA

href = servlet ReqCo 11 ect author gtAuthorlt fontx AxTDgt

ltTRgt

The ReqCollect is the name of a servlet We pass the ldquoauthorrdquo in the hyperlink as a

parameter to ReqCollect When the Author item is selected ReqCollect is invoked by

lava Web Server ReqCollect generates a html page to let a user input author search

condition The ReqCollect code is listed below

25

Example 413 A part of Source Code of ReqCollectjava

public class ReqCollect extends HttpServlet

protected final String AUTHOR = author

public void service(HttpServletRequest req

HttpServletResponse res) throws ServletException

IOException

PrintWriter out = resgetWriter()

String path = reqgetPathlnfo ()

if (path == null)

error handling

else

Create standard header

CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

26

path = pathsubstring(1)

if (pathequalsIgnoreCase(CATEGORY))

Create category request collect

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

outprintln(ltfont color=CC66 0 0

face-verdana arial helvetica size = + lxbgtEnter

Authorltbgtltfontgt )

outprintln(ltbrgt You can enter

authors full name first name or last nameltpgt)

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess

id=forml name=formlgt)

outprintln(lttable border=0gt)

outprintln(lttrgt lttd valign=middle

align = lef txttgtltbgtAuthor ltbxttxtdgt )

outprintln(lttd valign=middle

align = lef txinput type = text name= author size = 40

value=x tdgt )

outprintln(lttrgt)

27

outprintln(lttrgt lttd colspan=2gt ltfont

size=-lgt)

outprintln(ltcentergt ltinput

type=radio name=author_mode value=exact

checkedgt Exact Name)

outprintln(ltinput type=radio

name=author_mode value=lastgtLast First Name (or

Initial) )

outprintln(ltcentergt)

outprintln(ltfontgt)

outprintln(lttdgt lttrgt)

outprintln(lttrgt lttd colspan=2gt ltpgt

ltbrgt lttdgt lttrgt)

outprintln(lttablegt)

outprintln(ltcentergt)

outprintln(ltinput type=submit

value=Search Now id=submitl name=submitlgt)

outprintln(cinput type=reset

value=Clear Form id=resetl name=resetlxpgt )

outprintln(ltcentergt ltformgt)

Create standard footer

28

CreateFooter(out)

outflush()

outclose()

The generated page looks like this

Figure 412 One of The Searching by Author PagesTinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorite l o o k H e lp

^ 3 4 s j ] S o zdStop Refresh Home Search Favorites History Mail Print EditBack bull

I t i h f e l f f httplocalhost8080servletReqCollectauthor

S ea rch Books

Home

C a t e g o r y

Author

Title

ISBN Publisher Date

poundj

TinyBookStore com

You can enter authors foil name first name or last name

A u t h o r jbjarne

C Exact N ame amp Last First N atne (or Initial)

Search Now | Clear Form

Taw boekstofeeoraH om e | Category | A uthor | Title | IS3M | Publisher Date

jpyright and disclaimer copy 1999-2001 F ang Xiao

ihtterteti

42 Design of Search by Different Requests

29

According to different requests the different pages should be produced There are many

common parts in the produced pages So we donrsquot need to code the common parts for

each page We can design the common parts into standard utility classes or static

functions You can simply call the standard classes or functions when you needed them

An example looks like this

CreateHeader(out)

CreateLeftMenu(out)

CreateFooter(out)

The three lines above invoke the standard functions CreateHeader() CreateFooter() and

CreateLeftMenu() which are developed in this thesis writing The CreateHeader()

function produces the top part of the pages The CreateLeftMenu() function produces the

left part of the pages The Createfooter() function produces the bottom part of the pages

You can find the source code in several servlets in Appendix

43 Servlet Chaining To Process Requests In Different Levels

A request can be handled by a sequence of servlets This system is designed to use the

first level servlets to handle the search requests If needed the first level servlets can

cooperates with the second level servlets by passing their processing result to the second

level servlets and let them to proceed the request until the final result is obtained The

final result is returned by the last servlet This is called servlet chaining The request

30

from the client browser is sent to the first servlet in the chain The response from the last

servlet in the chain is returned to the browser In between the output from each servlet is

passed as an input to the next servlet Each servlet in the chain has the option to change

or extend the content W e can see the example in the ReqCollect code

Example 431 A Part of Code of The ReqCollectjava

if (pathequalsIgnoreCase(AUTHOR))

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess id=forml

name=formlgt)

The ReqCollect servlet uses the getPathInfo() method to get the extra path information

This method returns the extra path information associated with request According to the

different extra path information the first level servlet invokes the different servlet of the

second level In this case ReqCollect invokes AuthorProcess servlet The final output

has been listed in Figure 412

31

44 Database Connectivity and Search from Database

The biggest advantage for servlets with regard to database connectivity is that the servlet

life cycle allows servlets to maintain open database connections An existing connection

can trim several seconds from a response time compared to a CGI program that has to

reestablish its connection for every invocation

Another advantage of the servlets over CGI and many other technologies is that JDBC is

database-independent JDBC is a SQL-level API - one that allows you to execute SQL

statements and retrieve the results if any The API itself is a set of interfaces and classes

designed to perform action against any database

An individual database system is accessed via a specific JDBC driver that implements the

javasqlDrivers interface Drivers exist for nearly all-popular RDBMS systems The

database connection used for Tiny Book Store uses a JDBC-ODBC bridge driver coming

along with the JDK 12 to allow access to standard ODBC data source such as the

Microsoft Access database

The first step in using a JDBC driver to get a database connection involves loading the

specific driver class into the applicationrsquos Java Virtual Machine This makes the driver

available later when we need it for opening the connection An easy way to load the

driver class is to use the ClassforNameQ method

32

ClassforName(sunj dbcodbcJdbcOdbcDriver)

When the driver is loaded into memory it registers itself with the javasqlDriverManager

class as an available database driver

The next step is to ask the DriverManager class to open a connection to a given database

where the database is specified by a specified formatted URL The method used to open

the connection is DriverManagergetConnection() It returns a class that implements the

javasqlConnection interface

Connection con =

DriverManagergetConnection(j dbcodbcsomedb

user passwd)

A JDBC URL identifies an individual database in a driver-specific manner Different

drivers may need different information in the URL to specify the host database

During the call to getConnection() the DriverManager object asks each registered driver

if it recognizes the URL If a driver says yes the driver manager uses that driver to create

the Connection object Here is an example

Example 441 A Part of Code of AuthorProcessjava

public void init() throws ServletException

try

ClassforNamesunj dbcodbcJdbcOdbcDriver)

con =

DriverManagergetConnection(j dbcodbcfxbookstore null

null)

catch (ClassNotFoundException e)

catch (SQLException e)

After we got the database connection we need to have some way to execute queries The

simplest way to execute a query is to use the javasqlStatement class Statement objects

are never instantiated directly instead a program calls the createStatement() method of

Connection to obtain a new Statement object

Statement stmt = concreateStatement()

34

A query that returns data can be executed using the executeQuery() method of Statement

This method executes the statement and returns a javasqlResultSet that encapsulates the

retrieved data

Example 442 A Part of Code of AuthorProcessjava

String sqlStmt =

if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where author= + name +II i n

else

sqlStmt = select from BOOK where author like +

name +

ResultSet rs = null

Statement stmt = concreateStatement()

rs = stmtexecuteQuery(sqlStmt)

35

A ResultSet object can be thought as a representation of the query result returned one row

at a time The next() method of ResultSet is used to move from row to row The

ResultSet interface also boasts a multitude of methods designed for retrieving data from

the current row The getStringO and getObject() methods can be used for retrieving

column values

Example 443 A Part of Code of AuthorProcessjava

while (rsnextO )

count++

outprintln(ltdtgtltbgt + count + )

String isbn = rsgetObject(ISBN)toString()

outprintln(lta href=servletDetailContent + isbn +

gt )

outprintln(rsgetObj ect(Title) toString() +

ltagtltbgt)

outprintln (ltnobrxfont color=990033gtUsually ships

in 24 hoursltBRgtltfontxnobrgt)

outprintln(ltddgt +

rsgetObj ect(Author) toString() )

36

outprintln( +

rs getOb j ect ( Publisher) toString () + +

rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

outprintln(ltbrgtltbrgt)

One of the outputs of servlet AuthorProcess is show in Figure 421 and Figure 441

Figure 441 One of The Outputs of Servlet AuthorProcess

37

File Edit View Favorites lo o k - Help M i

T 1 bdquo - 0 L Q 4 pound $ L L lBack r s Stop Refresh Home S earch Favorites History

A - Mail Print

Links rdquo Address | jyen j http7ocalhost808O$ervletAuthorProcess 3

Search B ooks

Home

CategoryA uthor

Title

ISBN

P u b l i sh e r D a te

Tiny Bookstore com

1 The C++ Prograitmuitg Language Usually ships in 24 hour Bjame Stroustrup Addison-Wesley Pub Co i 1997 Our Price 3147

T in yb o oks to re c om H ora e | Category | A uthor | Till | ISBN | Publisher P a t

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top of Page

gk j Local intranet

45 Session Tracking

Session Tracking is one of the most important techniques for any on-line store systems

This is because that HTTP protocol is a stateless protocol A HTTP server sees only a

series of requests and it by itself has no way to know exactly who is making the request

This means that when a customer puts a book in his shopping cart and then goes to other

pages to find more books next time when he puts another book in his shopping cart there

is no guarantee that he puts the book in the same cart It is very possible that he uses

another customerrsquos shopping cart at this time

38

To solve this problem session-tracking is introduced Traditional techniques used by

CGI include hidden form fields URL rewriting user authorization and persistent cookies

For server-side Java applications a built-in class supplied servlet can be used easily to

handle such tasks

When a user first accesses the site web server assigns a new HttpSession object and a

unique session ID to the user The session ID identifies the user and is used to match the

user with the HttpSession object in subsequent requests Usually the session ID is saved

on the client in a cookie or sent as part of a rewritten URL The Tiny Book Store uses this

technique

The Tiny Book Store is a classic shopping cart application A client can put items in his

virtual cart accumulating them until he checks out several page requests later How to

make sure a userrsquos shopping items will be put in his shopping cart or delete from his

shopping cart The Java Servlet API provide built in session tracking to handle this

problem Every user of a site is associated with a javaxservlethttpHttpSession object

that servlets can use to store or retrieve information about that user We can save any set

of arbitrary Java objects in a session object For example a userrsquos session object provides

a convenient location for a servlet to store the userrsquos shopping cart contents An example

shows below

Example 451 A Part of Code of AddToShoppingCartjava

39

1 Get current session object create one if necessary

2 HttpSession session = reqgetSession(true)

3 m_cart = (ShoppingCart)sessiongetValue(cart)

4 if (ra_cart == null) need new cart

5 create a shopping cart

6 m_cart = new ShoppingCart()

7 add to current session

8 sessionputValue(cart m_cart)

9

10

11 try

12 Statement stmt = m_concreateStatement()

13 ResultSet rs = stmtexecuteQuery(select from

book where ISBN= + isbn +)

14 if (rsnext())

15 book - new

BookDetails(rsgetObj ect(ISBN) toString()

16 rsgetObject(Title)toString()

rsgetObj ect(Authorrdquo) toString()

17 rsgetDouble(Price)

rsgetObj ect(PublicationDate) toString() )

18

40

1 9

2 0 catch (SQLException e)

21 e printStackTrace()

22

23 m_cartadd(bookgetlSBN() book)

The servlet uses its request objectrsquos getSession() method to retrieve the current

httpSession object

public HttpSession HttpServeltRequestgetSession (boolean create)

This method returns the current session associated with the user making the request If

the user has no current valid session this method creates one if create is true or return

null if create is false To ensure the session is properly maintained this method must be

called at least once before any output is written to the response Please look at the line 2

in the example 451

If you want to add data to an HttpSession object you can use the putValueQ method

public void HttpSessionputValue(String name Object value)

41

This method binds the specified object value under the specified name Any existing

binding with the same name is replaced This specifies at line 8 of the example 451

If you want to retrieve an object from a session you can use getValue() method

public Object HttpSessiongetValue(String name)

This method specified at line 3 of example 451 returns the object bound under the

specified name or null if there is no binding

From line 4 to line 9 the servlet checks whether the user already has a shopping cart If

the user didnrsquot have a shopping cart the servlet assigns a shopping cart to this user and

add the shopping cart to the current session to keep tracking The ShoppingCartjava class

is developed in this thesis writing code is provided in the appendix

From line 10 to line 21 the servlet knows the user already has a shopping cart m_con is

a data member of AddtoShoppingCart class Lines 12-13 have been discussed in the

previous section Lines 16-20 get some information of the book which the user selected

The information will be the data members of the ldquobookrdquo object that is an instance object

of BookDetailsjava class BookDetailsjava class is developed in this thesis writing the

source code is provided in the Appendix

Line 25 puts the book which is selected by the user into the shopping cart

42

Please see a set of pages are shown below

Figure 451 A Page Show All Information About A Book

TinjiRnfikStnre com - M inrnsnfl Interned Explnrpr

File Edit View Favorites Tools Help-

^ O 4 4 1 f i tStop Refresh Home I Search Favorites History Mail Print Edit

I Link gtgt Address [gl hgtplocalhos9l]IBrit-rvetDetailConetit-Ll20183l)544

S e a r c h B o o k s

Home-

C a t e g o r y

Author

Title

ISSNPublisher Pate

TinyBookStore com

The C++ Programming Languageby Bjarne Stroustrup

aISBN 0201889544 Addison-Wesley Pub Co 1997

Price 3147 Availability U sually ships within 24 hours

Add to cart

Done

R ev iew s

In tins brand-new third edition of The C + + Programming Language author Bjame Stroustrup the creator of C++ presents the full specification for the C++ language and standard library a spec that will soon become the joint ISOANSI C++ standard

g ig L o ca l in tranet

43

Figure 452 A Page Show Items In The Shopping Cart after A User Added Books To The Shopping Cart

H H I H I - I I

j File Edit View Favorites l o o k Help I f

| S ack Stop Refresh Home Search FavoritesJ V

History Wail Print

j Links Address |S1 http7localhost8O80servletAddToShoppingCart i i i i a i i i

( O ldquo ii

Shopping Cart Item s Price

An Introduction to fen e tic Algorithm sMelanie MteheU Quantity 1 Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

drle trgt

delete

delete

Price $ 2 2 0 Subtotal $ 2 2 0

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 6 7 5 6

|euro

rfuj Local intranet

44

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A Book From The Shopping Cart

^ A m a z o n c o m Shopping Cart - Microsoft Internet Explorer

- J A l 4Stop Refresh Home

gtH bdquo ] Back bdquo

httplocalhost8080servletDeleteFromShoppingCartitemgetltem()getlSBN()

Ji _J 3Search Favorites History

j - JMarl Print

~U ccdeg

Shopping Cart Item s

Core Java 2Cay S Horstrnaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d elete

delete

Price

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 4 5 5 6

rsquo0 1 Done gSsfLocat intranet

46 Check Out

This part is designed only using the HTML It collects all information from a user The

information will be written into the database

An important line in this HTML file is shown below

45

ltform method=POST

action=httplocalhost808 0servletCustomerlnfoProcessgt

This line will invoke the servlet CustomerlnfoProcess that will process all data collected

from the user This servlet will discuss in the next section The check out page shows in

Figure 461

Figure 461 A Check Out Page

M M iH M M M i M MmmrnfrnM File Edit View Favorites too ls Help

^ gt a 3 A hi -ltamp f V j HISllll mmB ack S lop R efresh H em e S earch 1 i l lie History M 1 Print Edit

^Links A ddrecs j ig ] h ltp localhostSO SO checkouth tm l i i i l a s

Custom er Information

First name (Fang

Middle initial |a

Last name [Xiao

Email address |fgtdaomitecnet

Account password Jxxxxx

C red it card num ber jl 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7

Credit card type ttV isa O BluebirdO MasterCard O Fisher

Credit card holder jFarig Xiao

Credit card expire date (tnmddyy) joi 0102 ~

Select shipping method t UPS 0 NormalO Express C Abnormal

| | ] Dorraquo raquo f j^ I o c a l intranet

47 Customer Information Processing

The customer information processing is handled by a servlet CustomerlnfoProces Its

source code is provided in the appendix

46

All information collected from the user should be written into the database therefore we

have to open a connection to a given database at first Example 461 is given for this

purpose

Example 471 A Part of Code of CustomerlnfoProcessjava

public void init() throws ServletException

try

ClassforName(sunjdbcodbcJdbcOdbcDriver)

m_con = riverManagergetConnection(jdbcodbcfxbookstore

null null)

catch (ClassNotFoundException e)

e printStackTrace()

catch (SQLException e)

e printStackTrace( )

There is a PO ST request in the check out page The servlet CustomerlnfoProcess will

handle the PO ST request by doPost function which is demonstrated in the following

example

47

Example 472 A Part of Source Code of CustomerlnfoProcessjava

public void doPost (HttpServletRequest req HttpServletResponse res)

throws ServletException IOException

ressetContentType(texthtml)

PrintWriter out = resgetWriter()

get information

String[] values = reqgetParameterValues(firstname)

if (values = null)

firstname = values[0]

values = reqgetParameterValues(middleinit)

if (values = null)

middleinit = values[0]

In the example the HttpServletRequest object res will get each data which was input by

the user by the getParameterValues() function

If the user is a returned user we donrsquot need open a new account again If the returned user

use the same credit card as previous we also donrsquot need to insert the credit card

48

information into the CREDITCARD table Otherwise we should insert all related

information into related table This is shown in the following example

Example 473 A Part of Source Code of CustomerlnfoProcessjava

Statement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where EmailAddress= +

email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext())

sql = insert into CUSTOMERACCOUNT (emailaddress password

firstname middleinit lastname) values ( + + email +

password + + firstname + + middleinit + lastname +

)

stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber= + creditcard

+

rs = stmtexecuteQuery (sql)

if (rsnext())

49

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype

HolderName ExpirationDate) values( + + creditcard + +

cardtype + + cardholder + 11 + expiredate + )

stmtexecute (sql)

All information related the books selected by the user can be obtained from the

shopping cart as shown in the following example

Example 474 A Part of Source Code of CustomerlnfoProcessjava

BookDetails book = null

ShoppingCartltern bookAndQuantity = null

Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getltems()

int aQuantity =0

String alSBN = null

while (itemshasMoreElements())

insert into Orderltems

bookAndQuantity = (ShoppingCartItem)itemsnextElement()

book = bookAndQuantitygetltem()

50

aQuantity = bookAndQuantitygetQuantity()

alSBN = book getISBN()

sql = insert into ORDERITEMS (shoppingCartID ISBN quantity)

values ( + + m_cartID + + aISBN + + aQuantity + )

stmtexecute (sql)

After all information inserted into related tables the servlet CustomerlnfoProcess will

produce invoice page The example page shows in Figure 471

51

Figure 471 An Invoice Page 3 Order List Microsoft Internet Explorer

is File Edit View Favorites Tools Help

J J J U r PS to p Refresh Hom e i -S earch Favorites History s Mai Print

Links Address iff 1 httpVlocalhostBOSOservletCustomerlnfoProcess 3

s5al Local intranet

Y ou r order reads as fo llow sE-MailAddress fiiiaomitecnet

ship to

Tel

Items

F ang Xiao12345 Western Plaza 23OmahaNE68154(402)123-4567

TitleCore Java 2Qtyl Price2579Subtotal2579

TitleJava Servlet PrograrnmingQtyl Price 1977 Sub total 1977 Total4556

i|51 D one

52

Chapter 5

Future Work

In this chapter we discuss two major problems for our future work They are the

Connection Pooling and Object-Oriented for better encapsulation

51 Connection Pooling

After we have used JDBC for a short time it will become evident that the major

performance bottleneck often comes right at the beginning when you are opening a

database connection This is because that opening a connection might involve a series of

low level communications between network protocols and database connection protocols

such as TCPIP ODBC etc

Servlet life cycle allows for extremely fast database access Servlet is loaded into Web

server only once Once it is loaded it can hold a connection to database all its life cycle

Every time it receives a request to read from or write data to database it can just use the

connection to do this

Here comes a problem however Suppose that a customer comes to the on-line store

During the period of selecting some items from the store he leaves his desktop and do

something else leaving this connection to database idling This will waste the precious

resource on the database From database port of view the connection to the database will

assign a space to hold corresponding status and to cache data For example Microsoft

SQL-Servertrade assigns about 36K bytes for each of its connection Resource on the

53

database is limited and idling connection causes such resource unable to be reused for

other users

To solve this problem we can use the technique called connection pooling Essentially a

connection pool is an object holding connections to backend database and managing the

number and status of connections For example if a connection in the pool idles over a

certain time of period the pool can terminate this connection if the requests are not the

same size of the connection pool the pool can dynamically shrink or expand the size of

itself A connection pool can run on a separate thread and is initialized when the server

starts or when a request to database is arrived

To implement a connection pool is pretty straight-forward Because of time constraint

however we did not do it in this paper and leave it as a possible future improvement

52 More Object-Oriented - Better Encapsulation

Another improvement might be done in the future is to create a HTML-related utility

class We have seen in this thesis that there are some duplicated code processing HTML

output such as ldquoout printIn ( lttbxtrgt lttrxtbgt)rdquo All these HTML-

related processes right now are used in a raw way That is they are not encapsulated A

better way to do this is to create a utility class or classes to deal with all HTML-related

processes and hide all HTML tags and format inside the class or classes For example

suppose that we create a Table class then we can use it in a way like

Table table = new Table()

54

table(somerow somecol contents)

table(somerow somecol some_image)

In this way we do not need to use HTML tags in our program and concentrate on the

programming logic The implementation is enriched with more object-oriented property

and therefore it is easy to maintain

55

Chapter 6

Conclusion

The increased awareness and popularity of the Internet make all kinds of electronic

commerce grow vigorously The most popular Web applications are the on-line stores

An on-line store system usually contains four components Web server business

procedure Database system application An on-line store system is different from web

publishing Currently there are three mainstream technologies which are widely used to

develop the on-line store systems CGI Microsoft ASP and Server-side Java application

Introducing the server-side Java application is one of the latest and most exciting trends

in Java programming We have discussed this technology in detail in this thesis The

server-side Java applications have many distinct advantages over CGI and other

technologies We present plenty of examples and figures to analysis the characteristics of

the server-side Java application

As a glance into the future electronic commerce will continue to grow driven by

purchases of home computers and other Web-enabled devices as well as new business

opportunities Electronic commerce is changing whole business procedures The future of

electronic commerce will be exciting and full of opportunities

56

APPENDIX A

Bibliography

57

[1] Karl Moss 1998 Java Servlets Mcgraw-Hill

[2] Jason Hunter William Crawford 1998 Java Servlet Programming O rsquoReilly

[3] Manoj Kumar Anand Rangachari Anant Jhingran Rakesh Mohan 1998 Sales Promitions on the Internet h ttpwwwibmcomiactech-paperhtml

[4] Manoj Kumar Stuart I Feldman 1998 Business Negotiations on the Internet httpwwwibmcomiactech-paperhtml

[5] Manoj Kumar Stuart I Feldman 1998 Internet Auction httpwwwibmcomiactech-paperhtml

[6] Shiwa Fu Jen-Yao Chung Walter Dietrich Vibby Gottemukkala Mitchell Cohen Shyhkwei Chen 1999 A Practical Approach to Web-Based Internet EDI httpwwwibmcomiacpapersicdcsws99indexhtml

[7] Zhong Tian Leo Y Liu Jing Li Jen-Yao Chung Vibby Guttemukkala 1999 Business-to-Business e-Commerce with Open Buying on the Internethttpw w w ibm comi acpapersobi -paperindex html

[8] Gerald J Tesauro Jeffrey O Kephart 1998 Foresight-Based Pricing Algorithms in an Economy os Software Agents http wwwi bm comi actech - paper html

[10] Jeffrey O Kephart James E Hanson Jakka Sairamesh 1998 Price and Niche Wars in a Free-Market Economy o f Software Agents httpwwwibmcomiactech-paperhtml

[11] Jeffrey O Kephart James E Hanson David W Levine Benjamin N Grosof Jakka Sairamesh Richard B Segal Steve R White 1998 Dynamics o f an Information-filtering Economy httpwwwibmcomiactech-paperhtml

[12] James E Hanson Jeffrey O Kephart 1998 Spontaneous Specialization in a Free-Market Economy os Agents httpwwwibmcomiactech-paperhtml

[13] Jakka Sairamesh Jeffrey O Kephart 1998 Price Dynamics o f Vertically differentiated Information Markets httpwwwibmcomiactech-paperhtml

[14] David Kosiur 1997 Understanding Electronic Commerce Microsoft Press

[15] Gunther Birznieks Selena Sol 1997 CGI fo r Commerce MampT Books - A Division of MIS Pres

58

[16] Ravi Kalakota Andrew B Whinston 1997 Electronic Commerce Addison Wesley

[17] Alex Fedorov Richard Harrison Dave Sussman Brian Francis Stephen Wood 1998 Profession Active Server Page 20 Wrox Press

[18] Calvin Austin Minica Pawlan 1999 Writing Advanced Application for the Java PlatformhttpVdeveloper iavasuncomdeveloperonlineTrainingProgrammin gJDCBooki ndexhtml

59

APPENDIX B

The Source Code of An On-Line Store System - Tiny Book Store

60

1 welcomeshtml

lthtmlgtltheadgtlttitlegtSearch Tinybookstorecomlttitlegtltheadgtltbodygt

lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=eeeeccgtlttrgtlttd rowspan=2 align=left valign=top width=15 cellspacing=0 cellpadding=0xIM G border=0 hspace=0 id=IMGl src=flowergif gtlttdgtlttd rowspan=2 align=left valign=centergtltstronggtlth2gtltigtTinyBookStorecomltigtlth2gtltstrongxtdgtlt trx tab legt

lttable border=0 width=100 cellspacing=0 cellpadding=0gtlttrgtlttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtltPgt

lttable width=100 cellspacing=0 cellpadding=5 border=0gtltTRgt ltTDgt ltTDgt ltTD colspan=2gt ltFONT FACE=verdanaarialhelvetica SIZE=-1 gtampnbsp ltFONTgt ltTDgt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD co lsp an = 2 x stro n g x fo n t face=verdanaarialhelvetica size=-lgtSearch B ooksltfontxstronggt ltTDgt ltTRgtltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt ltTD x f o n t face=verdanaarialhelvetica size=-l gt

lta href=w elcom eshtm lgtH om eltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt c T D x fo n t face=verdanaarialhelvetica size=-1 gt

lt A href= servletReqC ol 1 ec tc ategory gtC ate gory ltf o n tx A x T D gtltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollectauthorgtA uthorltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollecttitlengtTitleltorfo n tx A x T D gt ltTRgt

61

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectisbngtISBN ltA xfontxTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectpublisher_dategtPublisherD a telt A x fo n tx T D gtltTRgtlt tab lex p gtlttdgt

lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgtlttd valign=top align=leftgt

ltbr clear=allgtltPgtlt h 3 x s tro n g x fo n t color=ff6347gtWelcome to theltigt T in y B o o k S to rex o m lt ix fo n tx s tro n g x h 3 gt

ltbrgtlt s tro n g x b x h 3 x c e n te rgt F iv e Hot B o o k slt cen te rx h 3 x B x s tro n g gt

ltbrgtltservlet code=EchoServetTag myArgI=myValuel myArg2=myValue2gt ltparam name=myParm 1 value=Hellogtltparam name=myParml value=Worldgtltparam name=myParm2 value=myParmValue2gtltservletgt

lt td x trgt

lttablegt

ltTABLE width=100gtltTRgt ltTD width=50 valign=top align=Ieftgt ltTDgtltTD width=50 valign=top align=rightgtltfont size=-lgtltA href=topgtTop of P ag elt A x fo n tx T D gt ltTRgt

62

ltTABLEgt

ltcentergtltfont size=-lgtltA href=indexhtml gtTinybookstorecom HomeltAgt ampnbsplampnbsp ltA href=categoryhtml gtCategoryltAgt ampnbsplampnbspltA href= author html gtAuthorltAgt ampnbsplampnbspltA href= title html gtTitleltAgt ampnbsplampnbspltA href=7isbnhtml gtISBNltAgt ampnbsplampnbspltA href=publisherhtmrgtPublisher DateltAgtltpgtltfontgtltcentergt

ltPgtltcentergtlt b rx fo n t size=-lgtltA href=copyrighthtml gtCopyright and disclaimerltAgt copy 1999-2001 Fang Xiao ltfontgtltcentergt

ltbodygtlthtmlgt

63

2 AddToShoppingCartjava

ltpgt AddToShoppingCart is the servlet that process the action of adding item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javasql import javautil import javaxservlet import javaxservlethttp

public class AddToShoppingCart extends HttpServlet

protected Connection m_con = null protected ShoppingCart m_cart protected BookDetails book

public void initQ throws ServletException try

Class forName( sunj dbc odbc JdbcOdbcDriver)m_con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintstackTrace ()catch (SQLException e)

e prints tackT race ()

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

String[] params = reqgetParameterValues(isbn)

64

String isbn = get isbn from extra path infomationif (params = null)

isbn = params [0]

Get current session object create one if necessary HttpSession session = reqgetSession(true) m_cart = (ShoppingCart)sessiongetValue(cart)

if (m_cart == null) need new cart create a shopping cart m_cart = new ShoppingCart() add to current session sessionputValue(cart m_cart)

try Statement stmt = m_concreateStatement()ResultSet rs = stmtexecuteQuery(select from book where

ISBN=rsquo + isbn + rsquo)

if (rsnext()) book = new BookDetails(rsgetObject(ISBN)toString()

rsgetObject(TitIe)toStringOrsgetObject( Author) toStringO

rsgetDouble( Price) rs getObj ect( PublicationDate) toStringO)

catch (SQLException e)

eprintStackTrace()m_cartadd(bookgetISBN() book)

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lt h tm lxheadx titlegt T inyB ookS tore com S hopping

Cartlttitlexheadgt)outprintln(ltbody bgcolor=FFFFFF lmk=003399

alink=FF9933 vlink=996633 text=000000ngt)outprintln(lta nam e= topxmdashTop of Pagemdashx a gt )

65

outprin tln(ltpxa href=httplocalhost8080checkouthtmlximg src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=cccc99 gt)ou tp rin tln (lt tdxbrx tdgt )ou tp rin tln (lt tdxbrx tdgt )o u tp rin tln (lt tdxbrx tdgt )outprintln(lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=2xfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=left valign=topxfont

face=verdanaaria lhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=cccc99gt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lt td x b rx td gt ) outprintln(lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantityQ

outprintln(lttr bgcolor=FFFFFFgt) ou tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt )outprintln(ltbrgt + item getltem() get Author()) outprintln(ltbrgtQuantity + itemgetQuantityO) outprintln( ltbrgt) outprintln(lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=POST

action=7servletDeleteFromShoppingCartitemgetItem()getISBN()gt)

66

outprintln(ltpgt cinput type=hidden name=isbn value= + itemgetItem()getISBN())

outprintln(ltpgt ltinput type=submit name=ditemvalue=deletegt)

outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelve tica color=000000gt)

outprintln(ltNOBRgtltbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fon tx bx N O B R gt ltbrgt )

outprintln(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantity() + lt fo n tx b x N O B R x b rgt )

outprintln(ltfontgt) out println( lttdgt)

out printl n( lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)out println( lt fo n tx fo n tgt )outprintln(lttdxtrgt)outprintln(lttablegt)outprin tln(ltpxa href=httplocalhost8080checkouthtmlYximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)outprintln(ltbodygt lthtmlgt)

outflush()outclose()

67

3 AuthorProcessjava

bull ltpgt AuthorProcessbull This is the servlet that process the Author-search request and generatebull search resultbull Author Fang Xiao Purpose Thesis project Copyrightcopy Fang Xiao 1999-2001

import javaxservlet import jav ax servlet http import javaio import javasql

public class AuthorProcess extends HttpServlet protected final String EXACT = ldquoexactrdquo protected final String OTHERS = ldquolastrdquo

protected Connection con = null

public void init() throws ServletException try

ClassforName(ldquosunjdbcodbcJdbcOdbcDriverrdquo)con = DriverManagergetConnection(ldquojdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(ldquotexthtmlrdquo)PrintWriter out = resgetWriterQ

68

String[] valuesString name =

values = reqgetParameterValues(ldquoauthorrdquo) if (values = null)

name = values [0]

String mode = ldquordquovalues = reqgetParameterValues(ldquoauthor_moderdquo) if (values = null)

mode = values [0]

String sqlStmt = ldquordquo if (modeequalsIgnoreCase(EXACT))

sqlStmt = ldquoselect from BOOK where author=rsquordquo + name +else

sqlStmt = ldquoselect from BOOK where author like lsquordquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

ldquoYour Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ldquoltdlgtrdquo) 11 start Glossary List

while (rsnext()) count++outprintln(ldquolt d tx b gt rdquo + count + ldquo ldquo)String isbn = rsgetObject(ldquoISBNrdquo)toString()

69

outprintln(ldquolta href=servletDetailContentrdquo + isbn+

outprintln(rsgetObject(ldquoTitlerdquo)toString() +ldquolt a x b gt rdquo)

outprintln(ldquolt n o b rx fo n t color=990033gtUsually ships in 24 h o u rslt B R x fo n tx n o b rgt rdquo)

outprintln(ldquoltddgtrdquo +rsgetObject(ldquoAuthorrdquo)toString())

outprintln(ldquo ldquo +rsgetObject(ldquoPublisherrdquo)toString() + ldquo ldquo + rsgetObject(ldquoPublicationDaterdquo)toString())

outprintln(ldquoltbrgt Our Price ldquo +rsgetObject(ldquoPrice)toString())

outprintln(ldquolt b rx b rgt rdquo)

if (count == 0) outprintln(ldquoltdtgt No matched data foundrdquo)

outprintln(ldquoltdlgtrdquo) end Glossary List

catch (SQLException e) create footer here outprintln(ldquolttdgt lttrgtrdquo) outprintln(ldquolttablegtrdquo)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(ldquolthtmlgtrdquo) outprintln(ldquoltheadgtrdquo) outprintln(ldquolttitlegt TinyBookStorecom lttitlegtrdquo) outprintln(ldquoltheadgtrdquo)

outprintln(ldquoltbodygtrdquo)

70

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspacing=0 cellpadding=0 bgcolor=rdquoEEEECCYrsquogtrdquo)

outprintln(ldquolttrgtrdquo)outprintln(ldquolttd align=left valign=top width=90 gtrdquo) outprintln(ldquoltIMG border=0 hspace=0 id=IMGl

src=rdquodJavaWebServer20public_htmlflowergifrdquogtlttdgtrdquo) outprintln (ldquolttd width=30gtlttdgtrsquorsquo) outprintln(ldquolttd align=left valign=center width=300gtrdquo)

outprintln(ldquolt stro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x s tro n g x td gt rdquo) outprintln(ldquolttd align=right valign=centergtrdquo) outprintln(ldquolttdgtrdquo) outprintln(ldquolttd w id th= 20x tdgt rdquo) out pri ntln (ldquolttrgtrsquo rsquo) outprintln(ldquolttablegtrdquo)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ldquolttable width= 100gtrdquo)outprintln(ldquolttrgt lttd width=50 valign=top align=leftgt lttdgtrdquo) outprintln(ldquolttd width=50 valign=top align=rightgtrdquo) outprintln(ldquoltfont s iz e = - lx a href=rdquotoprdquogtTop of P agelt ax fon tgt rdquo) outprintln(ldquolttrgtrdquo) outprintln(ldquolttablegtrdquo)

outprintln(ldquoltcentergtrdquo) outprintln(ldquoltfont size=-lgtrdquo) outprintln(ldquolta

href=rdquohttplocalhost 8080welcomeshtmlrdquogtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080$ervletReqCollectcategoryrdquogtCategoryltagtampnbsplampnbsprdquo)

outprintln(ldquoltahref=Yhttplocalhost8080servletReqCollectauthorrdquogtAuthorltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_daterdquogtPublisheramp44Dateltagtrdquo)

outprintln(ldquoltpgtrdquo)

71

outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltpgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquolt b rx fo n t size=-lgtrdquo)outprintln(ldquoltA href=Y7copyrighthtmlrdquogtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiaordquo)outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltbodygtrdquo) outprintln(ldquolthtmlgtrdquo)

i

protected void CreateLeftMenu(PrintWriter out) System out println(ldquoLeftMenurdquo)

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspaeing=0 cellpadding=0gtrdquo)

outprintln(ldquolttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtrdquo)

outprintln(ldquoltpgtrdquo)

outprintln(ldquolttable width=rdquo 100rdquo cellspaeing=0 cellpadding=5border=0gtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquoltfont face=verdanaarialhelvetica SIZE=rdquo- l rdquogtampnbsp

ltfontgtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquolt strongxfon t face=verdanaarialhelvetica size=rdquo-

1 rdquogtSearch B ooksltfontxstronggtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd ldquo) outprintln(ldquoltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080welcomeshtmlYgt H o m elt fo n tx ax td gt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=rdquo-1rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080servletReqColIectcategoryrdquogt C ateg o ry lt fo n tx ax td gtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

72

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectauthorrdquogtAuthorltfontgtltagtlttdgtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width-2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l W rsquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltfontgtltagtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo-lYgtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_dateVrsquogtPublisher Dateltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolt tab lex p gt rdquo)

outprintln(lsquolsquolttdgtrdquo)outprintln(ldquolttd rowspan=4 width=5gtampnbspampnbspltbrgtlttdgtrdquo) outprintln(ldquolttd valign=top align=leftgtrdquo) outprintln(ldquoltbr clear=allgtrdquo)

73

4 BookTeatailsjava

ltpgt This is the class describing a book item in shopping cart

Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class BookDetails private String m_isbn = null private String m_title = null private String m_author = null private double m_price = 00 private String m_year = null

public BookDetails(String isbn String title String author double price String year)

thism_isbn = isbn thism_title = title thism_author = author thism_price = price thism_year = year

public String getISBN() return m_isbn

public String getTitle() return m_title

public String getAuthor() return m_author

public double getPrice() return m_price

ipublic String getYearQ

return m_year

75

5 CategoryProcessjava

ltpgt CategoryProcess This is the servlet that process the Category-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql import javautil

public class CategoryProcess extends FlttpServlet protected final String EXACT = exactprotected final String OTF1ERS = last

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

76

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentType( texthtml)Print Writer out = resgetWriterQ

String[] values String name = String sqlStmt =

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

else

path = pathsubstring(l) if (pathequalsIgnoreCase(cO 1))

sqlStmt = select from BOOK wherecategoryid=rsquo + cOl +

else if (pathequalsIgnoreCase(c02))sqlStmt = select from BOOK where

categoryid=rsquo + c02 +else if (pathequalsIgnoreCase(c03))

sqlStmt = select from BOOK wherecategoryid=rsquo + c03 +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftM enu(out)

Your Book Search Results try

77

if (con = null) Statement stmt = concreateStatement() rs = stmt executeQuery (sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn

+outprintln(rsgetObject(Title)toString() +

lt ax bgt )outprintln(ltnobrxfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltddgt +

rsgetObject( Author)toStringO)outprintln( +

rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)outprintln(ltbrgt Our Price +

rsgetObject( Price) toStringO) ltfont color=990000gtYou Save $1100

(20)ltfontgtoutprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

78

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)out println( lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20publicbdquohtmlflowergifgtlttdgt) outprintln(lttd width=3 0gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln( lt s tro n g x h 2 x igt T inyB ookS to re com lt ix h2x s tro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlngtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

79

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYrsquogtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln( ltfontgt)outprintln(ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rOwspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt)

outprintln(lttablewidth= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=Y2Ygt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y-1 Yrsquogtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2Yrsquogt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=Y-

lYrsquogtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=Y-lYgt)

80

outprintln(ltahref=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqColIectcategorygtCategoryltfontxagtlttdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(nltahref=httplocalhost8080servletReqCollectauthorVrsquogt A u th o rlt fo n tx ax td gtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httpIocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

6 CustomerlnfoProcessjava

ltpgt CustomerlnfoProcessThis servlet is responsible to process userrsquos information when heshe check out

Author Fang Xiao

Purpose Thesis projectCopyright (C) Fang Xiao 1999-2001

import javasql import javaio import j avau til import javaxservlet import javaxservlethttp

public class CustomerlnfoProcess extends HttpServlet protected Connection m_con = null protected HttpSession m_session = null protected static int m_cartID = 1 protected String firstname =protected String middleinit =protected String lastname =protected String email =protected String password =protected String creditcard =protected String cardtype =protected String cardholder =protected String expiredate =protected String shipping =protected String receiver =protected String address =protected String city =protected String state =protected String zipcode =protected String phone =

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)

82

m_con = DriverManagergetConnection(jdbcodbcfxbookstorenull null)

catch (ClassNotFoundException e)

eprintStackTrace()catch (SQLException e)

eprintStackTrace()i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

get informationString[] values = reqgetParameterValues(firstname) if (values = null)

firstname = values [0]

values = reqgetParameterValues(middleinit) if (values = null)

middleinit = values [0]

values = reqgetParameterValues(lastnameM) if (values = null)

lastname = values [0]

values = reqgetParameterValues(email) if (values = null)

email = values [0]

values = reqgetParameterValues(password) if (values = null)

password = values [0]

values = reqgetParameterValues(creditcard)

if (values = null) (creditcard = values [0]

values = reqgetParameterValues(cardtype) if (values = null)

cardtype = values [0]

values = reqgetParameterValues(cardholder) if (values = null) (

cardholder = values [0]

values = reqgetParameterValues(expiredate) if (values 1= null)

expiredate = values [0]

values = reqgetParameterValues(shippingrdquo) if (values = null)

shipping = values [0]

values = reqgetParameter Values (receiver) if (values = null)

receiver = values [0]

values = reqgetParameterValues(address) if (values = null)

address = values [0]

values = reqgetParameterValues(city) if (values = null) (

city = values [0])

values = reqgetParameterValues(state) if (values = null) (

state = values [0]

84

values = reqgetParameterValues(zipcode) if (values = null) (

zipcode = values [0]

values = reqgetParameterValues(phone) if (values = null)

phone = values[0]i

get session object m_session = reqgetSessionQ

try update databaseStatement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where Email Address=rsquo + email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext()) Systemoutprintln(insert customeraccount)

sql = insert into CUSTOMERACCOUNT (emailaddress password firstname middleinit lastname) values ( +

+ email + + password + + firstname +V + middleinit + + lastname + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber=rsquo +creditcard +

rs = stmtexecuteQuery (sql)

if (rsnext()) Systemoutprintln(insert creditcart)

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype HolderName ExpirationDate) values( +

+ creditcard + + cardtype + +cardholder + + expiredate + rdquo)

Systemoutprintln(sql)stmtexecute (sql)

i

85

sql = insert into SHOPPINGCART (ShoppingCartIDEmail Address CreditCardNumber ShippingType ReceiverName ReceiverAddress ReceiverCity ReceiverState ReceiverZipcode ReceiverPhone) values ( + m_cartID + V + email + Vrdquo +

creditcard + V + shipping + + receiver ++ address + V +

city + V + state + V + zipcode + V + phone +gt gt

Systemoutprintln(sql)stmtexecute (sql)

BookDetails book = nullShoppingCartltem bookAndQuantity = null Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

int aQuantity =0 String alSBN = null

while (itemshasMoreElementsO) insert into Orderltems bookAndQuantity =

(ShoppingCartItem)itemsnextElement()book = bookAndQuantitygetItem()

aQuantity = bookAndQuantitygetQuantity() alSBN - book getISBN()

Systemoutprintln(insert Orderltems)sql = insert into ORDERITEMS (shoppingCartED ISBN

quantity) values ( + m_cartID + +alSBN + + aQuantity + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

im_cartID++ must increase by one

86

catch (SQLException e) eprintS tackTrace()

printOrder(out)

public void printOrder(PrintWriter out) outprintln( lthtmlgt ltheadgt lttitlegt Order List lttitlegt ltheadgt) outprintln( ltbodygt)outprintln(lthlgt Your order reads as follows lthlgt)outprintln(lttablegt)outprintln( lttrgt)outprintln( lttdgtE-Mail Addres s lttdgt) outprintln(lttdgt+ em ail+lttdxtrgt) outprintln(lttrgt) outprintln(lttdgtship tolttdgt) outprintln(lttdgt+ receiver +ltbrgt) outprintln(address +ltbrgt) outprintln(city +ltbrgt) outprintln(state +ltbrgt) outprintln(zipcode + lt b rx td x trgt ) outprintln(lttrgt) outprintln( lttdgtTel lttdgt) outprintln(lttdgt+ phone +lttdxtrgt) outprintln(lttrgt) outprintln( lttdgtItems lttdgt)

BookDetails book = nullShoppingCartltem bookAndQuantity = nullEnumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

double total = 00

while (itemshasMoreElements()) bookAndQuantity = (ShoppingCartItem)itemsnextElement()

total += bookAndQuantitygetItem()getPrice() bookAndQuantitygetQuantityO

book = bookAndQuantitygetltem()

87

outprintln(lttdgtTitle+ bookgetTitle() + Qty + bookAndQuantitygetQuantity() + ltbrgt)

outprintln(Price + bookgetPrice() + Subtotal + bookAndQuantitygetQuantityO bookgetPrice() +ltbrgt)

outprintln(Total + total )outprintln(lttdxtrgt)outprintln(lttablegt)outflush()outclose()

7 DeleteFromShoppingCartjava

ltpgt DeleteFromShoppingCart is the servlet that process the action of deleting item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javautil import javaxservlet imp ort j avax servlet http

public class DeleteFromShoppingCart extends HttpServlet

protected ShoppingCart m_cart protected BookDetails book

public void doPost(HttpServletRequest req FIttpServletResponse res) throws ServletException IOException res setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String[] params = reqgetParameterValues(isbnrsquo) String isbn = get isbn hidden fieldif (params = null)

isbn = params [0]

Systemoutprintlnfisbn = + isbn)

Get current session objectHttpSession session = reqgetSession()m_cart = (ShoppingCart)sessiongetValue(carf)

m_cartremove(isbn)

89

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lthtm lgtltheadxtitlegtAm azoncom Shopping

C artlt titlexheadgt)out pri ntln ( ltb ody bgcolor=FFFFFF link=003399

alink=FF9933 vlink=Yrsquo996633Y text=rdquo000000rdquogtrdquo)outprintln(lta nam e= top xmdashTop of Pagemdashx a gt ) ou tp rin tln (lt pxa href=httplocalhost8080checkouthtmlximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=Yrsquocccc99Yrsquo gt)ou tp rin tln (lt tdxbrx tdgt )out pri ntln ( lt td x b r x td gt )outprintln( lt td x b r x td gt )out println (rsquo1 lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=Y2Yxfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=YleftY valign=YtopYxfont

face=verdanaarialhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=Ycccc99Yrsquogt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantity()

outprintln(lttr bgcolor=FFFFFFgt) o u tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt)outprintln(ltbrgt + itemgetItem()getAuthor())

90

outprintln(ltbrgtQuantity + itemgetQuantityO)outprintln(ltbrgt)outprintln( lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=VPOST

action=7servletDeleteFromShoppingCartVgt)outprintln(ltpgt ltinput type=hidden name=isbn value= +

itemgetItem()getISBN())outprintln(ltpgt cinput type=submit name=ditem

value=Y rsquo deletegt rsquo rsquo)outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelvetica color=000000gt)

outprintln(ltNOBRxbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fo n tx b x N O B R x b rgt )

outprintin(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantityO + lt fo n tx b x N O B R x b rgt )

outprintln( ltfontgt) outprintln( lttdgt)

i

outprintln(lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)outprintln(ltfontxfontgt)outprintln( lt td x trgt ) outprintln(lttablegt)ou tp rin tln (lt pxa href=Yhttplocalhost8080checkouthtmlYximg

src=YdYJavaWebServer20servletsimageproceed-to-checkoutgifYxagt)outprintln(ltbodygt lthtmlgt)

outflushOoutcloseQ

91

8 Detailcontentjava

ltpgt DetailContent is the servlet responsible for generating detailed information page for a book The book is identified by its ISBN Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaio import javasql import jav ax servlet import javaxservlethttp

public class DetailContent extends FIttpServlet protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String isbn = reqgetPathInfo()isbn = isbnsubstring(l) skip over rsquo rsquo

92

try String sql = select from book where ISBN=rsquo + isbn +

Statement stmt = concreateStatement()ResultSet rs = stmtexecuteQuery(sql)

create header here CreateHeader(out)

create left menu here CreateLeftMenu(out)

outprintlnfctd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintlnfctd valign=top align=leftgt)

cellpadding=0gt)

outprintln(ltbrgt)

create detailcontent here while (rsnext())

String strlSBN = rsgetObject(ISBN)toString() outprintln(lttable width=100 border=0 cellspacing=0

+ltbgtlttdxtrgt)

+ lt tdx trgt)

outprintln(lttrgt lttd colspan=3 align=leftxbgt) outprintln( rsgetObject(Title)toString()

outprin tln(lt trxtd colspan=3 align= leftxbgt by ltbgt) out println( rs getObj ec t( Author) toS tringQ

cellpadding=0gt)

outprin tln(lt trx td x i m g src=xtdgt) outprintln( lttd valign=topgt) outprintln( lttable border=0 cellspacing=0

outprintln( lt t r x td valign=topxbgtPrice )outprintln(

rsgetObject(Price)toString() + lt b x td x trgt ) outprintln(

lt trx td x b gt A v ailab ility lt b gt U su a lly lt td x trx b rgt )outprintln( lt t r x td vlign=topgtships within 24

hou rs lt td x trgt )outprintln( lt tab lextdgt)

93

outprintln( lttd align=rightgt) outprintln( lttable border=0 cellspacing=0

cellpadding=0gt)outprintln( lt trx td gt )outprintln( ltform

method=POST action=httplocalhost8080servletAddToShoppingCartgt)outprintln( ltinput

type=hidden name=isbn value= + strlSBN +outprintln( cinput

type=submit value=Add to cart )outprintln( lt tdx trgt )

outprintln( lt tab lex tdgt ) outprintln(rdquolttrgt)outprintln(lttrgt lttd clospan=3 align=leftgt ISBN ) outprintln( strlSBN +lttdxtrgt)outprintln(lttrgt lttd clospan=3 align=leftgt) outprintln( rsgetObject(Publisher)toString()

+rsgetObject(PublicationDate)toString() + lt tdx trgt )outprintln(lttablegt)outprintln(ltbrgt)outprintln(ltbrgt)

output reviewString review = rsgetObject(BookReview)toString() if (review = null)

review =DJavaWebServer20servletsreview + review

outprintln(ltbgtReviewsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(review))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprin tin (thisLine) ou t println( ltpgt)

)

icatch (IOException e)

need do something here eprintstackTrace ()

94

outprintln(ltbrgt)String comment =

rsgetObject(BookComment)toString()if (comment = null) comment = DJavaWebServer20servletscomment +

commentoutprintln(ltbgtReader Commentsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(comment))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprintln(thisLine) outprintln(ltpgt)

catch (IOException e)

need do something here eprintstackTrace ()

ou t pri ntln ( ltb rgt)

catch (SQLException e)

need to do something here

add table end tab outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt)

95

ou t pri ntln ( lthe adgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=YTOO cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d J avaW eb S erver 2 Opublic_htmlflo wer gif gtlttdgt) outprintln(lttd width=30gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyBookStorecomltigtlth2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln( lttd width=20gtlttdgt) out pri ntln ( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-1 gt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

96

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsptampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out prin tin ( ltcen tergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

eellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=Yhttplocalhost8080Avelcom eshtm lgtHom eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-1gt)

97

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=http7localhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref-httpIocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lVgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

98

9 EchoServlettagjava

import javaio import j avasql import javaxservlet import javaxservlethttp

public class EchoServletTag extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintStackTrace ()catch (SQLException e)

eprintStackTrace()

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

try Statement stmt = concreateStatementQResultSet rs = stmtexecuteQuery(select from book where title

like rsquoProgrammingrsquo)int count = 1outprintln(ltdlgt)while (rsnext() ampamp count lt 6)

outprintln(ltdtxbgt + count + )

99

String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn + outprintln(rsgetObject(Title)toString() + lt ax bgt ) outprintln(ltddxnobrgtltfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltbrgt + rs getObject( Author) toStringO) outprintln( + rsgetObject(Publisher)toStringO +

+ rsgetObject(PublicationDate)toStringO)outprintIn(ltbrgt Our Price +

rsgetObject(Price)-toStringO)

out println( lt b rx b rgt ) count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()outprintln(lttdgt lttrgt) outprintln(lttablegt) outflush() outcloseO

ii

100

10 ISBNProcessjava

ltpgt ISBNProcess This is the servlet that process the ISBN-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javax servlet import javaxservlethttp import javaio import j a vasql

public class ISBNProcess extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forN ame( sun j dbc odbc J dbcOdbcDri ver)con = DriverManagergetConnection(j dbc odbc fxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s s e tC on te n tTy pe ( tex th tm l)PrintWriter out = resgetWriter()

String[] values

String alSBN =

values = reqgetParameterValues(isbn) if (values = null)

alSBN = values [0]

String sqlStmt = select from BOOK where ISBN= + alSBN

ResultSet rs = null int count = 0

create header here bullCreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject( IS BN) toStringO

outprintln(lta href=servletDetailContent + isbn+ gt)

outprintln(rsgetObject(Title)toStringO +lt ax bgt )

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toStringO)

outprintln( +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

102

outprintln(ltbrgt Our Price +rsgetObject(rdquoPrice) toStringO)

outprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width= 100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d Uava WebS erver2 Opubhc_htmlflo wer gif gtlttdgt) outprintln(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS tore com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt)

103

out println( lttdgt) outprintln(lttd w id th= 20x tdgt ) out pri ntln( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)out pri ntln (lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) out pri ntln ( lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsp1ampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out println( ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

104

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 eellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Books lt fontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocaihost8080servletReqCollectcategorygtCategoryltfontxaxtdgt lttr gt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

105

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lttablegtltpgt)

o u t println( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

ii

106

11 PublisherDataProcessjava

ltpgt AuthorProcess This is the servlet that process the PublisherampDate-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql

public class PublisherDateProcess extends FIttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbc odbc JdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentT ype ( texthtml)PrintWriter out = resgetWriterQ

String[] valuesString namel =

107

values = reqgetParameterValues(publisher) if (values = null)

nam el = values [0]

String name2 =values = reqgetParameterValues(rdquopublication_date) if (values = null)

name2 = values [0]

String sqlStmt =sqlStmt = select from BOOK where publisher=rsquo + namel + rsquoand

publicationdate=rsquo +name2

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprin tln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toStringO outprintln(lta href=servletDetailContent + isbn

+ gt)outprintln(rsgetObject(Title)toString() + (

lt ax bgt )

108

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rs getObj ect( Author) toS tring())

outprintln(V +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

outprintln(ltbrgt Our Price +rsgetObject( Price) toStringO)

outprintln( lt b rx b rgt )

if (count == 0) (outprintln(ltdtgt No matched data found)

outprintln(rdquoltdlgt) end Glossary List

catch (SQLException e) ( create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 celipadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt)

109

outprintln(ltIMG border=0 hspace=0 id=IM Gl src=dJavaW ebServer20public_htmlflowergifxtdgt)

outprintln(lttd width=3 0 x td gt ) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS to re com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ctable w idths 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt) outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) ou t println( ltcentergt)

no

outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaim er^A gt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) out pri ntln ( lthtml gt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-1 gtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=V-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-1gt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

I l l

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitleYrsquogt T itle lt fo n tx a x td gt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(nltahref=Yhttplocalhost8080servletReqCollectisbnY gtISBNltaxfontxtdgt lttrgt)

outprindn(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdana arial helvetica size=Y -1 gt)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYgtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

1 12

12 ReqCollectjava

ltpgt This is a servlet responsible for generating search request collection page It read extra path information from URL and then according to the extra path information it generates corresponding page format Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001import javaxservlet import javaxservlethttp import javautil import javaio

public class ReqCollect extends HttpServlet

protected final String CATEGORY = categoryrdquo protected final String AUTHOR = author protected final String TITLE = titlerdquo protected final String ISBN = isbnprotected final String PUBLISHER_DATE = publisher_date

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentType( texthtml)PrintWriter out = resgetWriter()

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

)else

Create standard header CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

path = pathsubstring(l) if (pathequalsIgnoreCase(CATEGORY))

I I Create category request collect

outprintln(ltpgt)outprintln(lth3xstronggtProgrammingltstronggtlth3gt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc01gtAlgorithmsltagt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc02gtCampC++ltagt)outprintln( Delphi) outprintln(lta

href=httplocalhost8080servletCategoryProcessc03gtJavaltagt)outprintln( MFC Perl)

outprintln(software Design UML Visual Basic More)

outprintln(lth3xstronggtW eb Developm entltstrongxh3gt) outprintln(ASP Commercem Cyberculture HTML

JavaScript)

outprintln(Security Web Design XML more)

outprintln(lth3xstronggtGraphics amp Softwareltstrongxh3gt) outprintln(Asobe CAD Desktop Publishing Graphics)

outprintln(Microsoft More)

outprintln(lth3xstronggtNetW orking amp O Sltstrongxh3gt) outprintln(Linux Macs Oracle PCs SAp R3 SQL)

outprintln(TCPIP Unix WindowsampDOS W indowsNT)

out println( More)

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

1 14

outprintln(ltfont color-CC6600 face=verdana arial helvetic a size=+1 gtltbgtEnter Authorltbgtltfontgt)

outprintln(ltbrgt You can enter authorrsquos full name firstname or last nameltpgt)

outprintln(ltform method=POST action=httplocalhost 8080servletAuthorProcessY id=form 1 name=form 1 gt)

outprintln( lttable border=0gt) outprintln(lttrgt lttd valign=middle

ahgn= leftx ttx b gt A u th o rlt b gt lt ttx td gt )outprintln(lttd valign=middle align= leftx input

type=YtextY name=author size=40 value=YYxtdgt)outprintln(lttrgt)outprintln(lttrgt lttd colspan=2gt ltfont size=-lgt) outprintln(ltcentergt ltinput type=radio

name=Yauthor_modeY value=YexactY checkedgt Exact Name)outprintln(ltinput type=radio name=author_mode

value=lastgtLast First Name (or Initial))outprintln(ltcentergt) outprintln(ltfontgt) outprintln(lttdgt lttrgt)outprintln(lttrgt lttd colspan=2gt ltpgt ltbrgt lttdgt lttrgt)outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search NowY

id=submitl name=submitlgt)outprintln(cinput type=reset value=YClear Form

id=resetl nam e= rese tlxpgt )outprintln(ltcentergt ltformgt)

else if (pathequalsIgnoreCase(TITLE))

Create title request collect

outprintln(ltfont color=CC6600 face=verdanaarialhelvetica s ize= + lxbgt E n ter T itlelt bxfontgt)lsquo

outprintln(ltbrgtYou can enter the exact title or part oftitleltPgt)

outprintln(ltform method=YPOSTY action=Yhttplocalhost8080servletTitleProcessY id=form l name=formlgt)

outprintln(lttable border=0gt) outprintln(lt trxtd valign=middle

a lig n = le ftx ttx b gt T itle lt b x t tx td gt )

115

outprintln(lttd valign=middle align= leftx input type=text name=title size=40 value=xtdgt)

outprintln(lttrgt) outprintln(lttrgt) outprintln( lttd colspan=2gt) outprintln( ltfont size=-lgt) outprintln( ltcentergt)outprintln( ltinput type=radio name=title-mode

outprintln(value=exact checkedgt) outprintln( Exact Title)outprintln( ltinput type=radio name=title-mode

outprintln( value=titlewords gt ) outprintln( Title Words )outprintln(ltcentergt ltfontgt lttdgt lttrgt)outprin tln(lt trxtd c o ls p a n = 2 x p x b r x td x tr gt ) outprintln(lttablegt)

outprintln(ltcentergt)outprintln( ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln( ltinput type=reset value=Clear Form

id=resetl nam e= resetlxP gt )outprintln(ltcentergt) ou t println ( ltformgt)

outprintln(lthr noshade size=lgt)

outprintln(ltBgtExamplesltBgt)outprintln(ltULgt)outprintln(ltLIgtEntering ltbgtampquotJava Servlet

Programmingampquotltbgt in the title field )outprintln(and choosing ltemgtExact Titleltemgt finds the

book without also finding the many books)

outprintln(ltLIgtEntering ltbgtampquotJavaampquotltbgt in the Title field and choosing ltemgtTitle Wordsltemgt)

outprintln( finds all books whose title are related toltigtJavaltigt)

outprintln(ltULgt)

out printl n( lttdgtlttrgt) outprintln(lttablegt)

ielse if (pathequalsIgnoreCase(ISBN))

Create isbn request collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n ter ISBN ltbxfontgt)outprintln(ltbrgt) outprintln(ltform method=POSTY

action=httplocalhost8080servletISBNProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

a lig n = le ftx ttx b gt IS B N lt b x t tx td gt ) outprintln(lttd valign=middle a lign= leftx input

type=text name=isbn size=40 value=xtdgt)outprintln(lttrgt)

outprin tln(lt trxtd c o ls p a n = 2 x p x b rx td x trgt ) outprintln(lttablegt)

out println( ltcentergt)outprintln(ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln(ltinput type=reset value=Clear

FormV id=resetl nam e= resetlxP gt )outprintln(ltcentergt)outprintln(ltformgt)

outprintln(lthr noshade size=lgt)

outpiintln(ltULgtrdquo)outprintln(lttdxtrgt)outprintln(lttablegt)

else if (pathequalsIgnoreCase(PUBLISHER_DATE))

Create publisher date collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n te r Publisher and Publication D ate ltb gtltfontgt)

1 17

outprintln( ltbrgt) outprintln(ltform method=POST

action=httplocalhost8080servletPublisherDateProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

align=leftgtlt ttxbgt P ub lisher lt b x t t x t d gt )outprintln(lttd valign=middle align= leftx input

type=text name=publisher size=40 value=xtdgt)outprintln(lttrgt) outprintln(lttrgt lttd valign=middle

a lign= leftx ttxbgt P ub lica tion D a te lt b x ttx td gt )outprintln(lttd valign=middle align= leftx input

type=text name=publication_date size=40 value=xtdgt)outprintln(lttrgt)outprintln( c t r x td c o l s p a n = 2 x p x b r x td x t r gt )outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search Now

id=submitl name=submitlgt)outprintln(ltinput type=reset value=VClear FormYrsquo

id=resetl nam e= resetlxpgt )outprintln(ltcentergt) outprintln(ltformgt) outprintln(lthr noshade size=lgt)

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush()outclose()

)

protected void CreateHeader(PrintWriter out) outprintln(lthtmigt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding bgcolor=EEEECCgt)

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20pubiic_htmlflowergifgtlttdgt) outprindn(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(lt s tro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x stro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt)outprintln(lttd w idth=20xtdgt) ou t println ( rsquo lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

out pri ntln ( ltfon tgt) outpri ntln( ltcentergt ) out pri ntln ( ltpgt) outprintln(ltcentergt) outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)out pri ntln ( ltf on tgt) outprintln(irltcentergt) out println ( ltbodygt) out pri ntln( lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

cellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=YT00 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE= -lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

1 gtS earch B ookslt fontx stronggt)outprintln(lttdgt lttrgt)out pri ntln (lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=l-lgt)

outpri ntln(ltahref=httplocalhost8080servletReqCoilectauthorgtA uthorltfontxaxtdgtlttrgt)

120

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprindn(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=V-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln(lttablexpgt)outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

121

13 ShoppingCartjava

ltpgt This is the definition for ShoppingCart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import Javautil

public class ShoppingCart Hashtable items = null int numberOfltems = 0

public ShoppingCart() items = new Hashtable()

add BookDetails to cart param bookID isbn param book book need to be added to cart copyreturn void

public void add(String bookld BookDetails book) if(itemscontainsKey(bookId))

ShoppingCartltem scitem = (ShoppingCartltem)itemsget(bookld) scitemincrementQuantity ()

else ShoppingCartltem newltem = new ShoppingCartltem(book) itemsput(bookId newltem)

numberOftems++

param bookld isbn

public void remove(String bookld) if(itemscontainsKey(bookd))

items remove (bookld) numberOfltems - -

public Enumeration getltems() return itemselements()

protected void finalize() throws Throwable items clear()

public int getNumberOfItems() return numberOfltems

public void clear() items clear() numberOfltems = 0

123

14 ShoppingCartltemjava

ltpgt This is the definition for the shoppingcart item Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class ShoppingCartltem BookDetails item int quantity

public ShoppingCartItem(BookDetails anltem) this item = anltem this quantity = 1

public void decrementQuantity() if (quantity gt 0)

quantitymdash

public void incrementQuantity() thisquantity++

i

public BookDetails getltem() return thisitem

public int getQuantity() ( return thisquantity

i

124

15 StandardFooterjava

package servlets

import j avax servlet

ltpgt This is a server side include servlet that will format the TinyBookStore HTML footer

public class StandardFooter extends GenericServlet

ltpgtPerform the servlet service

param req The request from the client param res The response from the servlet public void service (ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the response javaioPrintW riter out = new

javaioPrintWriter(resgetOutputStream())

Format the standard footeroutprintln(ctable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(rdquoltfont s iz e = - lx a href=topgtTop of

P agelt ax fon tgt )outprintln(lttrgt) out println( lttablegt) outprintln(ltcentergt) outprintln(rsquoltfont size=-lgt)outprintln(lta href=7welcomeshtmlYgtTinybookstorecom

Homeltagt ampnbsplampnbsp)outprintln(lta href=categoryhtmlgtCategoryltagt

ampnbsplampnbsp)outprintln(lta href-authorhtmlgtAuthorltagt

ampnbsplampnbsp)outprintln(lta href=titlehtmlrdquogtTitleltagt ampnbsplampnbsp)

125

outprintln(lta href=isbnhtmlgtISBNltagt ampnbsplampnbsp) outprintln(lta href=7publisherhtmlgtPublisheramp44

Dateltagt)outprintln(ltpgt)outprintln(ltfontgt)ou t println ( ltcen tergt)outprintln(ltpgt)out println (ltcentergt )outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and

disclaim er^A gt ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln( ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

outflush()outclose()

126

16 StandardHeaderjava

package servlets

import javaxservlet

ltpgt This is a server side include servlet that will format the standard TinyBookStore HTML header The Title of the page will be set to the value of the title property

public class StandardHeader extends Generic Servlet

ltpgt Performs the servlet service param req The request from the client param res The response from the servlet

public void service(ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the responsejavaioPrintWriter out = new javaioPrintWriter(resgetOutputStream())

Get the title of the page Set to empty string if no title parameter was givenString titles[] = reqgetParameterValues(title)String title = if (titles = null)

if (titleslength gt 0) title = titles [0]

outprintln(lthtmlgt) outprintln(ltheadgt) outprintln(lttitlegt + title + lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=T00 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)

127

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src=dJavaWebS erver2 Opublic_htmlflower gi A gtlttdgt) out println(lttd width=3 O x td gt ) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyB ookStorecom ltigtlth2xstrongxtdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) out printl n ( lttd width=20gtlttdgt) out printl n( lttrgt) outprintln(lttablegt)

outflush()outclose()

128

17 TitleProcessjava

ltpgt TltleProcess This is the servlet that process the Tltle-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import j avax servlet import javaxservlethttp import javaio import j avasql

public class TitleProcess extends HttpServlet protected final String EXACT = exact protected final String OTFIERS = titleWords

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

129

String[] valuesString name =

values = reqgetParameterValues(title) if (values = null)

name = values [0]

String mode =values = reqgetParameterValues(title_mode) if (values = null)

mode = values [0]

String sqlStmt =if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where title=rdquo + name +else

sqlStmt = select from BOOK where title like rsquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString()

130

outprintln(lta href=servletDetailContent + isbn+

outprintln(rsgetObject(Title)toString() +ltagtltbgt)

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toString())

outprintln( +rsgetObject(Publisher)toString() + + rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +rsgetObject(Price)toString())

outprintln(ltbrxbrgt)i

if (count == 0) outprintln(ltdtgt No matched data found)

ioutprintln(ltdlgt) II end Glossary List

catch (SQLException e) i create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

131

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=EEEECCgt)

outprintln(rdquolttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaW ebServer20public_htmlflowergifxtdgt) outprintln(lttd w idth=30xtdgt) outprintln(rdquolttd align=left valign=center width=300gt)

outprintln(ltstronggtlth2gtltigtTinyBookStorecomltixh2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(rdquolttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln( lttrgt)outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(rdquolta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(rdquoltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

132

out println( ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) outprintln( ltcentergt) outprin tln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disciaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) S y s te m out println( LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt )

outprintln(lttable width= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y- lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost 8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

133

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lt tab lex pgt )

ou t pri ntl n ( lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

134

18 checkouthtml

lthtmlgtltheadgt lttitlegtCustomer Informationlttitlegt ltheadgtltbodygt

lt hlgt ltcentergt ltbgt Customer Information ltbgt ltcentergt lt hlgt

ltform method=POST action=httplocalhost8080servletCustomerInfoProcessgt lttable border=0gt

lttrgtlttd align=rightgtFirst namelttdgtlttd colspan=2 align= leftx input type=text name=firstname size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtMiddle initiallttdgtlttd colspan=2 align= leftx input type-text name=middleinit s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtLast namelttdgtlttd colspan=2 align= leftx input type-text name=lastname size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtEmail addresslttdgtlttd colspan=2 align= leftx input type=text name=email s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgt Account pass word lttdgtlttd colspan=2 align= leftx input type=text name=password s ize= 40x tdgt

lttrgtlttrgt

lthrgtlttrgt

lttablegtltbrgt

ctable border=0gtlttrgt

lttd align=rightgtCredit card numberlttdgtlttd colspan=2 align= leftx input type=text name=creditcard s ize= 40x tdgt

lttrgtlttr valign=topgt

135

lttd align=rightgtCredit card typelttdgtlttd align=leftgtltinput type=radio name=cardtype value=visagtVisaltbrgtltinput type=radio name=cardtype value= mastercard gtMasterCardltbrgt lttdgtlttd align=leftgtltinput type=radio name=cardtype value=bluebirdgtBluebirdltbrgtltinput type=radio name=cardtype value=fishergtFisherltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtCredit card holderlttdgtlttd colspan=2 a lign= leftx input type=text name=cardholder s ize= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCredit card expire date (mmddyy)lttdgtlttd colspan=2 align= leftx inpu t type=text name=expiredate size= 40x tdgt

lttrgtlt trx trgtlt trx trgtlttr valign=topgt

lttd align=rightgtSelect shipping methodlttdgtlttd align=leftgtltinput type=radio name=shipping value=upsgtUPSltbrgtltinput type=radio name=shipping value=expressgtExpressltbrgtlttdgtlttd align=leftgtcinput type=radio name=shipping value=normalgtNormalltbrgtltinput type=radio name=shipping value=abnormalgtAbnormalltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtReceiver Namelttdgtlttd col span=2 a lign= leftx inpu t type=text name=receiver size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtAddresslttdgtlttd colspan=2 align= leftx input type=text name=address size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCitylttdgtlttd colspan=2 align= leftx inpu t type=text name=city size= 4 0 x td gt

lttrgtlttrgt

136

lttd align=rightgtStatelttdgtlttd colspan=2 align= leftx inpu t type=text name=state s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtZipcodelttdgtlttd colspan=2 align= leftx inpu t type=text name=zipcode size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtPhonelttdgtlttd colspan=2 align= leftx input type=text name=phone size= 40x tdgt

lttrgtlttablegtlt b rx b rgtcinput type=submit value=Process name=actiongt

ltformgt

ltbodygtlthtmlgt

137

APPENDIX C

Screen Display of the Test

138

mmm File Edit View Favorites T o d s Help

^ Jit j j ^ LJ U 3) ~ pound=J _Am Back - S top Refresh Home j Search Favorites History Mait Print Edit

Links gtgt Address |4S ] httDVIocalhost808QAvdcorne shtml

TinyBookStore com

Welcome to the TJnyBoakStoro com

F i v e H o t B o o k s

1 T h e C + + Programming LanguageU s u a l l y s h i p s i n 24 h o u r s

B j a r n e S t r o u s t r u p A d d i s o n - W e s l e y Pub Co 1997 Our P r i c e 31 47

2 - P r o g r a m m i n g V i s u a l C + +U s u a l l y s h i p s i n 24 h ou r I I

Local intranet

Search BooksHorne

Category

Author

Title

ISBNPublisherDate

3 iigt60

3 1 S earch T inybooksloiecom - Microsoft Internet Explorer

139

T inyB ookStorecom - Microsoft Internet Explorer

j File Edit View Favorites lo o k Help

q a a H 3 1 d B ack S top R efresh Home S earch Favorite History j M aJ Print

Links gtgt A ddress httpV localhost 308QoryleV PetailCorterV 020i8SC l4

MM

Edit

Search Books

Home

Category

Author

Title

ISBN

PublisherDate

TinyBookStore com

The C++ Programming Languageby B j a r n e S t r o u s t r u p

0

ISBN 0 2 0 1 8 8 9 5 4 4 A d d i s o n - W e s 1e y P ub Co 199 7

Reviews

P r i c e 31 47A v a i 1ab i 1i t y U s u a l 1 ys h i p s w i t h i n 24h o u r s

Aic t o c a r t

ijgJ Local intranet

140

^ | I myBook5torecom Shopping Cart - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

[v] I ^ -J JB ack - Stop R efresh Home S earch Favorites History lsquo Mail Print

Links A ddress 0 1 h ttp localhost8080servetA ddT oShoppingCart ~3 ltGdeg

Shopping Cart Item s Price

The C++ Programmi ng LanguageB j a r n e S t r o u s t r u p Q u a n t i 1 7 1

Price $ 3 1 4 7 Subtotal $ 3 1 4 7

d e l e t e

Total 31 47

Customer Information Microsoft Internet Explorer

File Edit View Favorites lo o ls Help bull _

bullgt 3i 4 n j j d a 31Back ~-j Stop- R efresh Home S earch Favorites History j Mail Print Edit

Link gtgt j Address ] j j h ttplocalhost SOSOcheekoot html

EMH1

~3

Customer Information

First name jFang

Middle initial |a

Last name Xiao

Email address fxiaomitecnet

Account password pooooc

0 1 Done

Credit card number 1234567891234567

Credit card type VisaC MasterCard

C Bluebir d C Fisher

Credit card holder jr ong Xiao

ard expire date (mmddyy) J010102

Select shipping method UPSO Express

O Normal C Abnormal

J |sect Local intranet

141

lt2] Order List - Microsoft Internet ExplorerFile |d i t View Fayotites lo o t Help

^ 3 ^ S i l S - j S tep R efresh Home Search Favorite History Mail Print h-

HFte-LLinks A ddress I g ] httplocalhost8030servletCustemeilrifoProcess 3 ^Go

Your order reads as followsE - M a i l A d d r e s s f x i a o

F a n g X i a o

ship to

T e l

11 e m s

pound] Pc

10821 W e s t e r n P l a z aOmahaME6 8 1 5 4

( 4 0 2 ) 4 9 6 - 7 5 7 0T i t l e T h e C++ P r o g r a m m i n g L a n g u a g e Q t y 1 P r i c e 31 47 S u b t o t a l 31 47

| a [ Local intianet rsquo

l i

T inyB ookSloiecom - Microsoft Internet Explorer

T 7 ~ J iii 4 a i t Vi 1+ a Si

5 E

P r i te i+ A d d ie r I ig l httplocalhot8080ervletReqCollectauthor

S e a r c h B o o k s

Horne

Ca t e g o r y

A u th o r

Title

ISBN

P ublishe r Date

jS 1 D one

TinyBookStore com

fc t i t e r l i t n o rYou can enter authors full name first name or last name

A u t h o r |sCOtt

O ExactName amp Last F irst Name (or Initial)

T itiv b o o k s to re c o m H o a e | C a te g o ry | A u th o r | T itle | ISBN | P u b lish e r D ate

C opyright and disclaim ercopy 1999-2001 F an g Xiao

T op o f P f

|sect g j Local intranet

142

linyBookStore^com- MiciosoFUnteinet ExplorerFite Edit View Favorites Tools Ftelp

IIl4 rsquojO IjjlI - 3 -Upraquo 8 a c k ltbullltbullbullltlaquo Stop R efresh Home S earch Favorites History Mail Print 1

| Links 1 Address j raquo 3 http7localhost8CI80servletAuthorProcess

l - i f l |x |

S e a r c h B o o k s

Home

C a t e g o r y

Ti t le

ISBN

P ublishe r D a te

D o n e-

TinyB o okStore com

1- Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

I G aleampory I A utho t | I jt te | ISBN | PubH shei^D atg

i t and disclaim erreg 1999-2001 F ang Xiao

Top of

l i Local intranet

j T iny8ookStorecom - M icrosoft Internet Explorer

Fite Edit View Favorites Tools Help

4- 5 ni M m ~ltpound C r =gt 2f|L i p | | | | | iAdiiill|^Thttp7localhost8080seivletD etailContent0201924889

U 3

S e a r c h B o o k s

H ome

C a t e g o r y

A u th o r

Title

ISBN

P u b lish e r P a te

TinyB o okStore com

Effective C++b y Scott Meyers

ISBN 0201924889 Addison-Wesley Pub Co 1995

R eviews

This is the review of Effective C++

R eader Comments

Price 3795 Availability U sually ships within 24 hours

Add to iosil

IIH LdcSiiihttahdt

143

l inyBookStorecom Shopping Cart - Microsoft Internet Explorer

4- -- _ t lS M JJ ltpound I 7 r mdash2--I or- Stop R efiesh Home S ea rch Favorites History Wait PrintBach

Links Y 1^ddtessj-^1 httDvVlocalliostiBOBOyservletMddToShoppinqCart 73 ^

0

Shopping Cart Item s

Effective C + +Scott Meyers Quantity 1

0 1 Done

delete

Price

Price $ 3 7 9 5 Su b to ta l $ 3 7 9 5

Total 3 7 9 5

IB~ht Locai intranet

bull 3 TinyBooKGIoFooom M icrosoft Internet Cxplorcr

Fite Edit View Favorites Tools Help

4- -4gt Lfl 4 r amp J J lt$ i icirsquo s J ~lAB ack Ti(^poundprV aTdV iS^Stop-T SfSjefre^ptr I i - M t s s j r y rvlih- i JPopSnr -JE

i i i l l l P I I I ^ I i l l ] httplocalhost8080servletR eqC ollectauthor

G3SJ

7 ^ Go

S e a r c h B o o k s

H om e

C a t e g o ry

A u th o r

Title

ISBN

Eytoiisiier Date

101 D one

T i n y B o o k S t o r e c o m

E n te r AuthorYou can enter authors full name first narne or last name

A u t h o r jCraig Larmen

E Exact N ante O Last F irst N ame (or Initial)

Search Now 1 Clear Form

I C ategory | A u th o r | j j t l s | ISBN |

C opyright and ctiiclali[er copy 1999-2001 F an g Xiao

T o p o fP ag e

^tDpcafihttangfe-

144

gj TinyBbokSlorecom - Microsoft Internet ExplorerFile Edit View F a v o n te s - Pools

4-1 4 gt_poundj Q Jl3S top R efresh Home S ea rch Favorites History Mail PrintCacl-

lsquo Unko A ddress j ig ] httplocalhostSOSCiservletAuthorProces 71

S e a r c h B o o k s

Home

C a t e o o r v

A u th o r

Tit le

ISBN

P ub l i she r D a t e

Titty Bo okStore com

1 Applying UM L and Pattern Usually ships in 24 hours Craig Larmen Prentice Hall 1997 Our Price 450

T im booksto re com Home | C ateg o ry | A u th o r | Title | I3BM | Publisher P a ts

C opyrigh t and disclaimer copy 1999-2001 F an g X iao IIg ] http7localhost 8080eopyright html Local intranet

7 j T inyBookStorecom - Microsoft Internet Explorer

^ 03 4 31 0 i -_r _j _T B ack ~j~ S top R efresh Hom e Search Favorites History Mail Print Edit

I Links Addiess AocalhcistiiiOciOserv-letCctailConfent0137488S07

u m m

S e a r c h B o o k s

HorneC a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r Date

Tiny Bo okStore com

Applying LOVIL and Patternby Craig Larmen

0 Price 450 Availability TJ sually ships within 24 hours

ISBN 013748880 Prentice Halil 997

R ev iew s

Tins is the review o f Applying UML and Pattern

R ea d er Com ments

Add to cart

01ll iPdSSIihirSdety

145

3 TinyBookStorecom Shopping Cart bull Microsoft internet ExplorerFile Edit View Favorites Tools Help

vJBeck

JStop Refresh

4Home

H Si - iS- -=dSearch Favorites History Mail Pnnt

Links rdquo Address jlti] httpVlocalhostBOSOservletAddToShoppingCart 3 ^ Gc

r o 1

Shopping Cirt J toms Price

A pplying UML and PatternCraig Larmen Quantity 1 Effective C++Scott Meyers Quantity 1

l i l le t e

delete

Price $ 4 5 0 Subtotal $45 0

Price $ 3 7 9 5 Subtotal $ 3 7 9 5

Total 82 95

d f g a j Local intranet

146

lt3 TinyBookStoiecom - Microsoft Internet ExplorerFile Edit View Favorites Io o ls Help

gt j i 4 a - a i [j JB ack Forward Stop Refresh Home S earch Favorites Histeiy Mail Print Edit

Links Address ] pound ] hiipVonahost803CeerveirsquoReqColectlsquoauthor

0 1 i

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r D a te

Tiny Bo okStore com

You can enter authors full name first name or last name

A u t h o r jJeff

O Exact N ame Last First N ame (or Initial)

Search Now i Clear Form

T inybookstorecotti H oinf | Category | A trthor | Title j ISBN | Publisher Date

Copyright and disclaimer copy 1999-2001 Fang Xiao

Top of Page

M Local intraZl

m TinyBook Stote com - Microsoft Internet Explorer

Fife Edit View Favorites Joo ls Help

ISregBack Stop Refresh Home S earch Favorites History Marl Print c

Lirrks Address samp] httplocalhost8080servletAuthorProcess ~z ^ Gc

S e a r c h B o o k s

H ome

CategoryA u th o r

Title

ISBN

P u b lishe r D a te

i M

TinyBookStore com

1 Progi aimning Windows bullwith M FC Usually slaps in 24 hours JeffProsise Microsoft P ress 1999 Our Price 4799

jnybo-okstorscom Homo | Category | A u th or | Title | ISBN | Publisher P a h

C opyright and disclaijRief copy 1999-liOO1 FangX iao

Loccii intranet

147

148

m I myUookSlorecom - Microsoft Internet ExplorerFile- pound d it View Favorite T ools Help

^ J ] 4 U J j j =jgt Stop R efresh Home S e a rc h Favorites History i Mail Print EditBack

Links AddressilaquojigThttplocalhost5 i380ser4eM D etailContent157231 pound350

rfgKxi

ldquo3 gt6deg

S e a r c h B o o k s

HorneC a teg o ry

A u th o r

Ti tle

ISBN

P ub l i she r D a t e

TinyBookStorecom

Programming Windows with M FCby JeffProsise

0

ISB N 1572316950 Micro s oft Pre s s 19 9 9

Price 4799 Availability Usually ships within 24 hours

R e N ew s

This is the review of Programming Windows with MFC

R eader Comments

A dd to cart

D one i jh j Local intranet

lt 3 TjryBook S tore com Shop p in g Cart - M icrosoft Internet Exolorer

File Edit View f a nute T ools Help

r 1B ack

J 3 Q 0J amp poundlr - Jlilip isS h lA ld rS s httpy |ocalhost8U 80AervletA ddToShoppingCait TSIIlli

Shopping Cart Item s

Program m ing W indow s w ith M F CJeffProsise Quantity 1A pplying UML a n d PatternCraig Larmen Quantity 1 E ffective C++Scott Meyers Quantity 1

d e le te

d elete

d elete

Price

Price $ 4 7 9 9 S u b to ta l $ 4 7 9 9

P rice $ 4 5 0 S u b to ta l $ 4 5 0

Price $ 3 7 9 5 S u b to ta l $ 3 7 9 5

Total 1 3 0 9 4

^ h W h e iM

S s i Local intranet

149

File Edit View Favorites lo o ls Help n4- -0 iS - M L U

Back Stop Refresh Home Search FavoritesJ

History I3 H H H B H H H BMail Pm Edit

Links rdquo Addrecs |s] hHplocalhogt5t8080servletReqCollectcategorii ^_____ bulllt bullbull llilltllll

Search Books

Home

Category

Author

Title

ISBNPublisherDate

TinyBookStore com

P r o g r a m m in g

AI g o r i t Lins CampC++ D e l p h i J a v a MFC P e r l s o f t w a r e D e s i g n UML V i s u a l B a s i c M o r e

Done

Web D e v e lo p m e n t

ASP Commercem C y b e r c u l t u r e HTML J a v a S c r i p t S e c u r i t y Web D e s ig n XML more

G r a p h i c s amp S o f t w a r e

Asobe CAD D es k t op P u b l i s h i n g G r a p h i c s M i c r o s o f t More

I J J ig Local intranet

150

finvBookStorecom - Microsoil Internet Explorer - j g j x

j Fite Edit Jfiew Favorites lo o ts Help

bull j 5 a i B ack lsquolti S top Refresh Home S e a tc h Favorites History Mail Print Edit

Links 1 Address |ltg] hitpVocalhostl-i030seryletCateciofyPreceigtVc03 ^ | g

S e a r c h B o o k s

Home CategoQ

A u th o r

Title

ISBN

Publishe r D a te

TinyBookStore com

1 Core Ja v a 2 Usually ships in 24 hoursCay S Horstmaun Prentice Hall 1999 Our Price 2579

2 Ja v a S erv let Programm itig Usually ships in 24 hoursJason Hunter i O Reilly 1993 Our Price 1977

3 Ju st J a v a 2 Usually ships in 24 hoursPerter van der Linden Prentice Hall 1999 Our Price 3149

Tinybookstorecom Home | C ategory | A u th o r | T itle | IbBN | Publisher D ateloRoIEage

n g Local intranet

ta

151

41 Tinytfookbtorecom - Microsoft Internet ExplorerFile gdit y iew Favorites JLools Help

1 ^ hgt a a a amp a j ri i - 3 bull a Back Forward Stop Refresh Home S earch Favorites History Mart Print Edit

lisLinteslsii Address ji^]h ttp localhost8D 8o7serv letD etailC ontent0130319336

M i

3 f^Gc

S e a r c h B o o k s

Homec a t e g o r y

Tiny Bo okStore com

Core Java 2by Cay S Horstmaun

El

ISBN 0130819336 Prentice H alil999

Reviews

This is the review of Core Java

R eader Comments

Price 2579 Availability U sually ships within 24 hours

I Add to car

S ] Done S i Local intranet

TinyBookStorecom Shopping Cart - Microsoft Internet Explorerfel11 File Eefit View Favorite l o o k H e lp

tljH|V| 4 a 3 j 09 c T J

Stop Refresh Home S e a rc h Favorites History j Mail Print

jiiLihkIi87js ^ B ie s S ij^ ] http Z localhost8080servletiddT oShoppirigC art

B I B

3= i

Shopping Cart Item s

Core Java 2Cay S Horstmaun Quantity 1

Icopy

t i l

delete

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Total 2 5 7 9

sal Local intranet

152

a TinvBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites J o o lr Fjelp

NBack

amp Id b iStop Refresh Home

ISearch Favorifes History - Mail Print Edit

Links gty I Address [ jg l httplocalhost8080servletD etailContent156592391 x d

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

T i t le

IS B N

Publisher Date

ampJ Lrl e

Tiny Bo okStore com

J a v a S erv le t Piograitmmigby Jason Hunter

a Price 1977 Availability XT sually ships within 24 hours

ISBN 15659239 lx O Refflvl998

R e N ew s

In this brand-new third edition of Java Servlet Programming author Bjame Stroustrup the creator of Java presents the full specification for the Java language and standard library a spec that will soon become the joint ISOANSI Java standard

j ~2J Local intranetm

dH T iny8ook5torecom Shopping Cart - Microsoft Internet Explorer

File pound d t y iew Favorites Io o ls HelpB H

a $ a i a a -Stop Refresh Home S ea rch Favorites Hi lory Mjl

3- lsquonr I

| j | i | H | g i | i | i d ^ | | | | l Q httplocalhost80S0servletAddToShoppirigCart J P

m

Shopping Cart Item s

Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d e le te

d e le te

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Price $ 1 9 7 7 S y b to ta l $ 1 9 7 7

Total 4 5 5 6

I O I

aiil

153

Lustomer Information - Microsoft Internet Explorerpoundite pounddit View Favorites Xoo|s Help

v- _) _ l 4 J I VB ack - Stop R efresh Home Search Favorites History Mail

Links gty] A ddress ] j i l h ttD localhost8080checkouthtm l

F -iVj ~f

l l i l i i

C u sto m er In fo rm a tio n

First name jFang

Middle initial lA

Last name fXiao

Email address jfxiao m itecnet

Account password jxxxxx

Credit card number ]1234567B91234567

Credit card type C VisaC M asterCard

C Bluebird O Fisher

Credit card holder jFang Xiao

Credit card expire date (mmddyy) jo 10102

Select shipping method c u p sC Express

NormalAbnormal

0 ] D one Local intranet

poundpound Order List - Microsoft Internet Explorer

s

Back

Li il raquo

Yiew Favorites l o o h Help

bullV Y lJ j X I T- lty S to p Refresh H o m e

amp 1 3 J - jrS earch Favorite History lt Mail Print

fcesssaampl httplocalhost8080servletCustom erlnfoProcess

Y o u r ord er reads as fo llow sE-Mail Address 6daomitecnet

Fang Xiao

ship to

Tel

Items

12345 Western PlazaOmahaNE68154(402) 123-4567

Title C ore Java 2 Qty 1 Price2579 Subtotal 2579

Tide Java Servlet ProjammingQty 1 Pnce 1977Subtotal 1977 Total4556

ffl|b ] Done kl Local intranet

154

mammmm 1

File Edit View Favorites lo o ts tieip

E=cl i u F t l H -n e -i i rdquo F j-oiilsquoiBillHistory lsquo gt1 ll Print Edit

iiiiiiiiiiiiiiiiiirsquo Links Address j-copy] http localhust 8080servletReqCollectisbn J

TinyBookStore com

Search Books

Home ISBN

Author

Title

IS B N

S e a r c h Hew C le a r Form

PubnsheuDate

Top o f PageITnjrbooksj^ore^ com Horne I C a te g o rv | ^ i t h o r | T i t Ie I ISBN | Publisher Date

- g ] http locdlho-st SOSOwelcome shtrnl

TinvBookStorecom - Microsoft Internet Exploier

poundaj Local intranetId

| File Edit View Favorites Tools Help

i -e -e u u r5_ _ _ a u ^ 4 - a a j Back Forward S top Refresh Home S earch Favorites History Hail Print Edit

Links A d d re ss ^ hitp rsquoIdcanc-stEtnSOservlltlsquoF-aqZoll-~ntispn z raquo h

TinyB o okStore com

S e a r c h B o o k s

Horne

A utho r

T itle

ISBN

P u b lish e r P a t e

fcntar ISBN

I SB H 1565922840

|sectplli||pbw||l| IliM M pifiillj

T rgU onL cirrti -nr Kini- | Cgtgpound-gg | Agithor | Title | ISBN f uhhe-rt Pete

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top o f Pag e

aipoundbull] O o n e Local intranet

155

File Edit View Favorites Tools Help

HUTinyBookStorecom - MicrosoH InternetExplorer

B ad-J J A J d -2r =3

Stop R efresh Home S e a rc h Favorites History Mail Print

Links ygt A ddress j ^ ] httpVlocalhost8080servletrsquoISBM Process

S e a r c h B o o k s

Horne

C a t e g o r y

A u th o r

T itle

IS B N

Pub l i she r D a t e

TinyB o okStore com

1 Learning Perl Usually ships m 24 hours Randal L Schwartz O Reilly 1997 Our Price 1997

T in vh ooksto re c o m H orne | C at ego tv | A u th o r | Title | ISBM | Publisher D ate

C opy rig h t a n d d isclaim ercopy 1999-2001 F a n g X iao

0 ] Done

yen

ighj Local i

TinyB ookStoiecom - Microsoft Internet Explorer

Erie Edrt View Favorites- lo o ls Help

-s pound] 4 pound1 jLl icArdquo =pound 2 S top Refresh Home S earch Favorites History Marl Print Edit

iilHI

NpBack

httpyiocalhostSOBOservleMDetailContentAI 565922840 ~T] Cm

Tiny Bo okStore com

S e a r c h B o o k s

H o m e i

C a teg o ry

A u th o r

T itle

ISBN

Publishe r D a te

Learning Perlby Randal L Schwartz

I ^

ISBN 1565922840 O Reillvl997

Price 1997 Availability U sually ships within 24 hours

Reviews

This is the review of learning Perl

Reader Comments M0 ] Done lsquofR | Local intranet

156

IHHHHHI _ I f f i x |

File E d t yiew Favorites J o e ls H elp 11v- -__ l

Back ~ rc Stop R efresh Home S earch Favorites HistoryJ rMail

HH1111Pgtnt

Links A ddress | ] http7docalhost8030servleM AddToShoppingCart 3 tgt G o

O S III

Shopping Cart Item s

Learning PeriRandal L Schwartz Quantity 1

delete

Price

Price $ 1 9 9 7 Subtota l $ 1 9 9 7

Total 1 9 9 7

s

Done Local intranet

Eg W illi 1 lttMM41 i H H p n B n 1 0 1 x i

Fite Edit View Favorites Toots Help E H

1$3 L plusmn J8ack Forward Stop Refresh Home Search Favoutes

4History i

- i V -=JMail Print

-Edit

71 Address http7localhost8080lsquoservletFleqCollecVisbn I l f i l l l

TinyBookStore com

Search Books

Home

C ateao rv

Author

Title

ISBN

Publisher D a te

Enter ISSN

i s bit [l 565921496

Search Now I Clear Form

Tinybookstore o n Home | Category | A uthor | Titb | ISBN | Publisher Dte

Copyright arid disclaimer copy 1999-2001 Fang Xiao zl amp j Done Js J Local intranet I

157

H H H r f e i x i File Edit View Favorites Lools Help

- J j j j ] JBack Stop Fiefresh Home Search

J JFavorites-

-J i C rHistory Mail Print

111111811i n

r Links wj i Address |reg] http docalhost 8080servletIS8N Process

S ea rch B ooks

Home

Category-

rdquo A u th o r

T i t l e

IS B fi

P u b l i s h e r D a ta

Tiny Bo okStore com

1 Programtning Perl Usually ships in 24 hours Larry Wall O Reilly 1997 Our Price 2397

T o o k s t o r e c o m H P in e | C a t e g o r y | A u t h o r | Till | IS B N | P -ubtu-hai D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g X ia

T o p o f P a g e

zlamp2 Done Local intranet

158

lt3 l mytfookSlorecom - Microsoft Internet ExplorerF3e Edit View FavoMes lo o ts Help

Back3 U Si S rsquo IStop Refresh Home lt Search Favorites History Mail Print Edit

httplocalhost8080servletDetailContent15S5321496 j3

Search Books

Horns

Category

Author

Title

ISBN

Publisher Date

Done

TinyB o okStore com

Programming Perlby Larry Wall

0 Price 2397 Av ail ability U sually ships within 24 hours

ISBN 1565921496 O Reillyl997

Reviews

This is the review of Programming Perl

Reader Comments

Add to cart

l or=lM

159

Tm vBookSlorecom Shopping Cart - M icrosoft Internet Explorer

i Fite Edit View Favorites lo o k Help

^ Beck R efresh Home

ampS earch Favorites History j Mail Print

E Links I Address ] pound http localhost 8080servletA ddT oShoppingCart rsquo ] O rai

i O

Shopping Cart Jlems

Learning Peri Randal L Schwartz Quantity 1 Program m ing PeriLarry W all Quantity 1

delete

d e le te

Price

Price $ 1 9 9 7 S u b to ta l $ 1 9 9 7

Price $ 2 3 9 7 S u b to ta l $ 2 3 9 7

Total 4 3 9 4

3SJ Done j | s [ Local intranet

160

m m mmmHi mmmHHHHHi1 File Edit View Favorites Tools Help

^ - J J -ih Ji - j| B a d Forward Stop Refresh Home S earch FavoritesHIH ctuv Mjl Print

IHIlllliEd

B l

MbfeifcssfjP Address httplocalhost8080servletFleqCollectpLiblisher_date_ ___ ________ ___________ _ bull bull bull bull_________________ Zi T gt 6 o

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

Title

ISBN

Publishe r P a t e

S ] Done

TinyBo okStore com

T rsquov -

Publisher

sind IPpiIs1iclaquoifciori OsifiC

jAd cl i so n-VVe oI e y Fuo C o ~

P u b l i c a t i o n D a t e 1U97

Search Now Clear Form

T inybookstore com Home | C ategory j A u tho r j I itle | ISBN | Publisher Ds

C opyright and disclaimer copy 1999-2001 F an g Xiao

T op o f Page

g a l Local intranet

161

lt|j TinyBookStoiecom - Microsoft Internet Explorerlsquo Erie Edit View Favorites lo o ls Help

v-1 Q rij - 3 rsquo- a u -=pound Ci Back s lsquoi i 1 Stop Refresh Home S earch Favorites History Mail Print i

jL inks i A ddress 0 1 http7localhost8Q80servletPublisherDateProcess

EMM

3

S e a r c h B o o k s

Home

C a t e g o r y

Author Title

ISBN

Publisher D a te

TinyBookStore com

1- Algorithm s in C Usually ships in 24 hoursRobert Sedgewick Addison-Wesley Pub Co 1997 Our Price 4495

2 The C++ P rogr amming L anguage Usually ships in 24 hourBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

3 Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

4- U M L D istilled Usually ships in 24 horn sMartin Fowler Addison-Wesley Pub Co 1997 Our Price 2995

Done | s j L ocalm

TinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorites l o o k Help

Backamp 3 $ -Q 3 3 AJStop Refresh Home S earch Favorites History Mail Print Edit

Lipikkigt7i Ajddr$esjhttpv7localhost8080-servletDetailCoriterit0201314525

m

3 rgtGc

S earch B ooks

Horne

A uthor

Title

ISBN

Publisher D a te

Tiny BookStore com

Algorithms in Cby Robert Sedgewick

S

ISBN 0201314525 Addison-Wesley Pub Co 1995

Reviews

This is the review of Algorithms in C

Reader Comments

Price 4495 Availability U sually ships within 24 hours

Add to cart

0I reg S a i t^ s a l intranet

162

File Edit View Favorites lo o ls Help

2 ^ iVi ^ ^ t j j B ack gt Stop Refresh Home S ea rch Favorites History ||

- i -Mail Print

WB0BUBSSSI B ifl

Links ygt Addrese |isect ] httpvVlocalhostSOSChservletAddToShoppingCart

Shopping Cart Item s

A lgontfim s in CRobert Sedgewick Quantity 1

0 1 D one

delete-

Price

Price $ 4 4 9 5 Subtota l $ 4 4 9 5

Total 4 4 9 5

Local intranet

163

^ l inyBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

ls31

3 bullrsquo -I- _J _jj - j i_ 3 - j rdquo -= $ ABack Forward Stop Refresh Home Search Favorites History Mail Print Edit

Links rdquo Address 6 J http Vlocalhost SOSOAervletR eqCollectpublisher_date j ^G

Search B o o k s

Home

categoryAutho r

Title

IS B N

Publi sher D a te

TinyBookStore com

liter Publisher and Publication Date

P u b l i s h e r Wrox Press Inc

P u b l i c a t i o n D a t e ]1

Search Now j Clear Form

T invbookstor ecotnHomg | Category | A uthor | Title | ISBN | Pu b lish e rP a t

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top of Page

zD one Local infra

m TinyB ookStoiecom - Microsoft Internet Explorer

R e Edit View Favorites Tools Help

- -i 13 4 St 2J amp t r - JHB-1

fff ij if P S | Address |sjpound~| httpVlocalhost8030servletPublisherDateProcess

S e a r c h B o o k s

Home

C a t e g o r y

A utho r

T itle

ISBN

Publisher D a te

0 ] Done

TinyBookStore com

1 Beginning Visual Basic 6 Database Programming Usually ships in 24 hour John Connell W rox Press Inc 1998 Our Price 3199

2 Befmiung Visual Basic 6 Usually ships in 24 hours Peter Wright Wrox Press Inc 1998 Our Price 3199

T inybookstore com H orae | C ategory | A u thor | Title | ISBN | Publisher Date

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top o f Fas

Local intranet

64

| File Edit Yiew Favorites T ook Help

i A - + - - a S 3 rsquo reg - pound J -3 Back ldquo d Stop Refresh Home Search Favorites History

- vMail Print

i

Edit

IllplBlllll________ g - M

isisfcinbsijp Addre s | g ) httplocalhost8080servletDetailCoritent1861001061 3 Gdeg

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

T itle

ISBN

Publishe r D a te

TinyBookStore com

Beginning Visual Basic 6 Database Programmingby John Connell

a Price 3199 Availability U sually ships within 24 hours

ISBN 1861001061 Wrox Press Inc 1998

Reviews

This is the review of beginning Visual Basic 6 Database Programming

Reader Comments

A d d to c a n

S] pone Local intranet

m u i

lillllEHl ^ bdquo A 3 2tl 4 t M liJ i

Back Forward Stop Refresh Home Search Favorites3

History 4 _ r

M j 1J

Print EditiSillilillllS

httplocalhost8080servletReqCollecttitle

S e a r c h B o o k s

Home

C a t e g o r y

Author

Title

ISBN

Publisher Date

TinyB o okStore com

Enter TicleYou can enter the exact title or part of title

T i t l e C++

O Exact Title Title Words

Search Now Clear Form

Example

bull Entering Java Servlet Programming in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title are related to Java _li

165

lt5 TinyBookStorecom - Microsoft Internet ExplorerFite Edit View Favorites lo o ts Help

Back Stop Refresh Home S earch Favorites History Mail Print

Links gty Addiess http-localhost8080servlet7TitleProcess

i|p1

I

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

Publi sher IS a t e

TinyBookStore com

1 The C++ Programming L anguage Usually ships in 24 hoursBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

2 Effective C+-F Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

3 Programttung Visual C-H- Usually ships in 24 hours David J Kmglinski Microsoft Press 1998 Our Price 3999

T m y h o o k s to e co m H o m e | C a te g o ry | A u th o r | T itle | ISBH | P u b lish er D ate

http iocalhost SOSOservletFleqCollectcategary

T op of P age

~hj Local intranet

bull a TlnjpBflOkStOfecom - Microsoft Internet Explorer

File Edit View Favorite Pools Help

0 3 4 S l i 3 O - J J i t of Stop Refresh Home S earch Favorites History - Mart Print Edit

HBack

i i i i lS i lB i I i f f id i l f f lH Q http Vlocalhost 8080AervletD etailContent1572318570

EEEI

J

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b lis h e r D a f t

TinyBookStore com

Programming Visual C++by David J KrngHnski

[Hj

ISBN 1572318570Microsoft Press 1998

Price 3999 Availability Usually ships within 24 hours

R e v ie w s

This is the review o f Programming Visual1

Reader Comments

Add to cart

if Local intranet

166

mm| File pounddtt View Favorites Jo o ls Help

c J J j j mdash JB ack - J Stop Refresh Home S earch Favorites History

- _ i -M u

J tPrint

t e t a f e w P A ddress | ^ ] httplocalhost8080servletAddToShoppingCart zl -lt1gtSo

Shopping Cart Item s

Programmeng Visual C + +David J Kmgbnski Quantity 1

delete-

Price

Price $ 3 0 9 0 Sub to ta l $ 3 9 9 9

Total 3 0 9 9

D one ^aj Local intranet

TinyBookStorecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

vHBack-

-J a 4 -a si fi- 3 aStop R efresh Home S earch Favorites History j Mail Print- Edit

Links gty A d d re s sL ^ ] hrtpWlocalhostSOSOservleVFIeqCollectAitle

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

ISBN

Pub l i she r Date

TinyBookStore com

Enter TitleYou can enter the exact title or part of title

Title Distil I nrfExact T itle V T itle W o rd s

Search Now | Cle ar Fo rm

Examples

rpound] Done

bull Entering Java Servlet Programming11 in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title arei date 11 j Java JZJ

167

a TlnyBA5kSioiecom - Microsoft Internet Explorergt 0e Edit ifiew Favorites Jock Jd lp

a a amp -a tii j k i Back s - Stop Refresh Home Search Favorites History Mail Print

liilP raquo httpiVlocalhostSOSOservletTitleProcess

E M 3

ldquo3 rgt-

S ea rch B ook s

Horne

C a t e d o r v

A utho r

TiUgt~ ISSN

Publi sher D a te

Tiny BookStore com

1- TJML D istilled Usually ships in 24 nowsMartin Fowler Addis on-Wesley Pub Co 1997 Our Price 2995

| C s rg g o ty | A u th o r | T itle | IStBH I P u b lis h e r D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g Xiao

-jg Local intranetS3

m n ^ i l a i i x l

File Edd View Favorites Joels- Help M Mi r J lt 3 L h f 4 - 0 lt 3

Back i t Stop Refresh Home S earch Favorites History Mail9

PrintM

Edit

Links raquo A ddress j | i ] http do ca lh o d 1030N m letDetailContenr0201325632 Mimas

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

Title

IS B N

Publisher Date

Tiny BookStore com

TJML Distilledby Martin Fowler

0

ISBN 0201325632 Addison-Weslev Pub Co 1997

Reviews

Tins is the review of The UML Distilled

Reader Comments

Price 2995 Avail abilityTJs u ally ships within 24 hours

Add to c a r t

0 3S i] Done |g^iLnealiihfrregei

TinyBookStorecom Shopping Cart Microsoft Internet ExplorerFile Edit View Favorites Jo o ls HetP

IBiiiBlll l l lHBlSglSlllllilMH MlllBliriilllgllSlIlBack - f - i - S top Refresh Home

a J i l ^ j 3 Search Favorites History 1 Mail Print liiii

3 Links ( A ddress j ig j hrtplocalhost803DservletAddToShoppingCart

Shopping Cart Herns Price

UML D istilledMartin Fowler Quantity 1Program m ing Visual C + +David J Kraglinski Quantity 1

Price $ 2 9 9 5 Subtota l $ 2 9 9 5

delete

Price $ 3 9 9 9 Subtota l $ 3 9 9 9d elete

Total 6 9 9 4

  • Electronic Commerce on Business Application
    • Recommended Citation
      • tmp1499779448pdf2JOpQ

List of Figure

Figure 261 The Structure of An Online Store 10

Figure 321 Handle Requests Flow Chart 13

Figure 331 HttpService of The Java Web Server Using Servlets 15

Figure 411 The Home Page of Tiny Book Store 22

Figure 412 One of The Searching by Author Pages26

Figure 441 One of The Outputs of Servlet AuthorProces 34

Figure 451 A Page Show All Information About A Book 39

Figure 452 A Page Show Items In The Shopping Cart After A User

Added Books To The Shopping Cart 40

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A

Book From The Shopping Cart42

Figure 461 A Check Out Page 43

Figure 471 An Invoice Page48

1

Chapter 1

Introduction

As we step in the year 2000 we can no longer look to the past as the guide for the

future A combination of business social and technical possibilities drives the rapid

progress in electronic commerce

Electronic commerce can offer a company both short-term and long-term benefits

Not only can it open new markets enabling a business firm to reach new customers

but it can also make it easier and faster for the firm to do business with their existing

customer base Moving business practices such as ordering invoicing and customer

support to network-based systems can also reduce the paperwork involved in

business-to-business transactions When more of the information is digitized it

allows that business firm to focus on meeting their customerrsquos needs Tracking

customer feedbacks and presenting customer solutions for their clientele are just

some of the opportunities that can stem from electronic commerce

2

Chapter 2

Electronic- Commerce

21 What Is Electronic Commerce

For some time now large business enterprises have used electronic commerce to conduct

their business-to-business transactions In early 1960 private networks were dedicated

for the use of electronic data interchange (EDI) and electronic funds transfer (EFT) in the

banking industry Recently however with the increased awareness and popularity of the

Internet electronic commerce has come to encompass individual consumers as well as

businesses of all size

To many electronic commerce is defined as the buying and selling of products and

service over the Internet But there are many other aspects Depending on whom you ask

electronic commerce has different definitions

From a communications perspective electronic commerce is the delivery of information

productsservices or payments via telephone lines computer networks or any other

means From a business process perspective electronic commerce is the application of

technology toward the automation of business transactions and workflow From a service

perspective electronic commerce is a tool that addresses the desire of firms consumers

and management to cut service costs while improving the quality of goods and increasing

3

the speed of service delivery From an online perspective electronic commerce provides

the capability of buying and selling products and information on the Internet and other

online services [16]

These definitions are valid with their perspectives It is a matter of which lens is used to

view the electronic commerce landscape Broadly speaking electronic commerce

emphasizes the generation and exploitation of new business opportunities by ldquogenerating

business valuerdquo or ldquodoing more with lessrdquo

22 The Importance of Electronic Commerce

As we approach the year 2000 we can no longer look to the past as guide to the future In

the face of strong market forces created by electronic commerce and mounting

competition corporations can no longer plod along historical tracks or seek the

preservation of the status quo Companies are discovering that old solutions do not work

with new problems The business parameters have changed and so have the risks and

payoffs

23 Types of Electronic Commerce

From a broad view there are three distinct general classes of electronic commerce

applications Inter-organizational (business-to-business) intra-organizational (within

business) and customer-to-business application [16]

4

231 Inter-Organizational Electronic Commerce

Inter-organizational electronic commerce makes business more convenient on the

following aspects

Firstly e-commerce can improve supplier management since electronic applications can

reduce the processing costs and cycle times for each purchase order and it can reduce the

number of people who work on purchase orders

Secondly e-commerce can improve inventory management since electronic applications

make the business partners can fast exchange information and easy track their documents

to ensure that they were received This not only can eliminate out-of-stock occurrences

but also can reduce inventory and improve inventory turn

Thirdly e-commerce can improve distribution management since electronic applications

can make the business partners receive the shipping documents as soon as possible and

enable better resource management by ensuring that the documents contain more accurate

data

Fourthly e-commerce can improve channel management since electronic application can

let the business partner post the information to electronic bulletin boards This can

eliminate repeated telephone calls and countless labor hours

Fifthly e-commerce can improve payment management since the business partner are

linked by network so the payments can be sent and received electronically Electronic

payment is more accurate and fast than traditional payment

232 Intra-Organizational Electronic Commerce

5

Intra-organizational electronic commerce facilities the following business applications

Workgroup communications Electronic applications enable manager to

communicate with employees using electronic mail videoconferencing and

bulletin boards

Electronic publishing Electronic applications enable companies to publish

information by using tools such as the World Wide Web On-line publishing can

show information immediately and clearly and reduce costs for printing and

distributing documentation

Sales promotion Electronic application improve the flow of information between

the production and sales forces and between the firms and customers This can

make companies have greater access to market and competitor information

Today Intranets are primarily set up to publish and access vital corporate information

Some of the most common types of information are Human Resources information

employee communications product development and project management data internal

catalogs sales support data equipment and shipment tracking and accessing corporate

database

233 Consumer-To-Business Electronic Commerce

In consumer-to-business transactions customers learn about products through electronic

publishing buy products with electronic cash and other secure payment systems and

even have information goods delivered over the network

6

From the consumerrsquos perspective there are three transactions

1 Electronic applications enable consumers to communicate with each other through

electronic mail videoconferencing and news groups

2 Electronic applications enable consumers to manage investments and personal finances

using online banking tools

3 Electronic application enable consumers to find online information about existing and

new products services

Consumers consistently demand greater convenience and lower prices Electronic

commerce provides consumers with convenient shopping methods from online catalog

ordering to phone banking both of which eliminate the costs of expensive retail

branches Electronic commerce facilitates factory orders by eliminating many

intermediary steps thereby reducing manufacturersrsquo inventory and distribution costs and

indirectly providing consumers with lower prices

24 Why Most Internet Based Electronic Commerce Is In The Business-To-

Consumer World

For the Business-to-Business e-commerce the lack of well-accepted standards is

hindering the success in promoting Business-to-Business electronic commerce

solutions[5] VAN (Value-Added Networks) EDI (Electronic Data Interchange) based

solutions are only accessible to large organizations due to the cost factor Corporate

buyers and suppliers large and small are looking for Internet based solutions to

streamline the procurement procedures and to reduce the cost of establishing trading

relationship and the trading transactions Such demands put forward some fundamental

challenge on issue like trust infrastructure on the Internet standards and inter-operability

etc

25 Current State of Business-To-Consumer E-Commerce

Business activity on the Internet is currently limited to publicizing the business

opportunity and to catalog based sales but it will rapidly expand to include the

negotiations conducted to settle the price of the goods or commodities being traded

These negotiations are currently conducted by human intermediaries through various

forms of auctions bidding systems for awarding contracts and brokerages The role of

the intermediaries can now be performed by Internet trading applications at a fraction of

the cost[4] Trading on the Internet allows a business to reach a large number of potential

customers and suppliers in a shorter time and a lower cost than possible by other modes

of communication and to settle business transaction with lower cost overhead in a shorter

time

Auctioned or brokered sales are the norm in business world for negotiating trades of large

monetary value But consumer sales and small-scale purchases have used the fixed price

mode perhaps because of the high overhead cost of using the auction or brokerage

method The new economics of the Internet will make auctions popular in consumer and

small business transactions also

Auctions are just one form of business negotiations Other examples are competitive bids

for procurement brokeragesexchangescartels and two party negotiations

Nowadays the free-market economy of software agents is in the embryonic stage But in

the near future the software agents will populate the Internet and provide trade and use

a rich variety of information goods and services in an open free-market economy In a

free-market economy of software agents information is produced traded and consumed

by vast numbers of autonomous self-motivated agents An essential task in such an

economy is the retailing or brokering of information gathering it from the right

producers and distributing it to the right consumers[10] The overall research goal is to

characterize and understand the dynamic behavior of information economies very large

open economies of automated information agents that are likely to come into existence in

the Internet

26 The Structure of The On-Line Store

9

Nowadays there are thousands of on-line stores running on the Internet A few well-

known ones are amazoncom and bookpoolcom Most of such applications involve

common functions which are as following

Searching for product information

Ordering products

Paying for goods and services

Providing online customer service

So they have a similar structure as shown in Figure 261 The system contains the

following components

1 A web server running continuously accepts userrsquos connection gets user requests and

forward requests to business procedure retrieves data (answers to user requests) from

business procedure and send it back to user

2 Business procedure usually consists of a user identification procedure like credit card

check user request analysis procedure analyzing requests calculating discomposing (if

necessary) and dispatching request to different data source component Also in some

case business procedure is responsible to compose data obtained from different data

sources into user-readable format

3 Database is the place to hold relevant data These data not only serve as a data source

describing commercial goods and prices but can be used for data mining to improve

store service quality as well Database is updated and maintained by both customersrsquo

input and system applications A customerrsquos input usually includes order information

10

Figure 261 The Structure of An Online Store

(through browser)

Databas

(through browser)client

client

serverWeb

Systemapplication

Busines

procedu

4 System applications can include a search engine running all the time and searching

relevant information from the internet data mining application deals with mining and

analyzing customer and sale data for management use database maintaining application

handles update data when product information changes Varying from system size to

system size not every system has cleardistinct boundaries between these components

The system can be 3-tired or n-tired but these systems all operate in similar ways

11

Chapter 3

Technologies For On-Line Store System

An on-line store system is different from traditional web publishing It needs customerrsquos

interactive communications and frequent data update The traditional HTML page is

insufficient because all it does is provide static content publishing Other technologies

are required in order to implement the on-line store

Currently there are three mainstream technologies which are widely used Common

Gateway Interface (CGI) Microsoft Active Server Page (ASP) and Server-side Java

application We briefly explore these technologies here

31 Traditional Web Application - Common Gateway Interface (CGI)

The common Gateway Interface normally referred to as CGI is one of the first practical

techniques for creating dynamic content With CGI a web server passes certain requests

to an external program The output of this program is then sent to the client in place of a

static file The advent of CGI makes it possible to implement all sorts of new

functionality in web pages and CGI quickly become a defacto standard implemented on

dozens of web servers Even though a CGI program can be written in almost any

language the Perl programming language is the predominant choice However CGI have

some distinct disadvantages

Firstly CGI program is transient A request is made each time to a CGI program It must

be loaded and executed by the Web server When the CGI program is complete it is

removed from memory and the results are returned to the client All program

initialization (such as connecting to a database) must be repeated each time a CGI

program is used

Secondly when a server receives a request that accesses a CGI program it must create a

new process to run the CGI program and then pass to it via environment variables and

standard input Every bit of information might be necessary to generate a response

Creating a process for every such request requires time and significant server resources

which limits the number of requests a server can handle concurrently

Thirdly a CGI program cannot interact with the web server or take the advantage of the

serverrsquos abilities once it begins execution because it is running in a separate process

32 Active Server Page

As shown in figure 321 the following list walks you step-by-step through what

happens if the client requests the page xyzasp

The client requests the page xyzasp from the server The Web server checks the file

extension to see whether a special program (such as the Active server Pages engine)

13

must be invoked to process the request If therersquos a asp extension the Web server

determines that it should invoke ASP to process this page

Figure 321 Handle Requests Flow Chart

Request

Response

WEB SERVERComponents

Databas

ns

ASP File

CLIENT

Active X Data

VBScript

If this page has never been requested before or has been changed since the last

request it must be parsed and the syntax checked and then be compiled by the Web

server Otherwise the page might be read from a cache of recently processed pages

which aids in performance During the parsing process the HTML and scripting code

14

are separated IIS (Internet Information Server) determines which scripting engine is

responsible for which part of the script and delegates the work of syntax checking and

compiling to the proper scripting engine (such as VB Script)

Now the code is executed by the scripting engine using resources from IIS which is

hosting the scripting engines All objects that the language engine cannot handle are

requested by the IIS which is also responsible for handling inputs and outputs for the

external ActiveX objects that are created and used inside the script If it is not able to

supply the object an error is generated

Script output and static HTML code in the ASP file are merged

The final HTML is sent back to the user in an HTTP response

The important point about ASP is that the Script runs entirely in a server to protect the

intellectual property by shielding it from browser which are different from the account

for when writing client-side code The entire server-side code is processed and only plain

HTML - or whatever kind of content you chose to generate - is sent to the client

33 Server-Side Java Application

The rise of server-side Java applications is one of the latest and most exciting trends in

Java programming A Servlet can be thought of as a server-side applet Servlets are

loaded and executed by a Web server in the same manner that applets are loaded and

executed by a Web browser

15

As shown in Figure 331 a servlet accepts requests from a client (via the Web server)

performs some task and returns the results

The client (mostly likely a Web browser) makes a request via HTTP The Web server

receives the request and forwards it to the servlet If the servlet has not yet been loaded

the Web server will load it into the Java virtual machine and execute it The servlet will

receive the HTTP request perform some type of process and return a response back to

the Web server The Web server will forward the response to the client

Figure 331 HttpService of The Java Web Server Using Servlets

RequestResponseRequestResponse

RequestResponse

Java Web Server

Administrative SERVLET

SERVLETHTTP

SERVLETWeb Proxy

Servlets have distinct advantages over CGI program

Servlets are persistent Servlets are loaded only once by the Web server and can

maintain services (such as a database connection) between requests

Servlets are fast since servlets only need to be loaded once

16

Servlets are platform independent Servlets are written in Java and conform to a well-

defined and widely accepted API They are highly portable across operating systems

and across server implementations A servlet can be developed on a Windows NT

machine running the Java Web Server and later can be deployed effortlessly on a

high-end Unix server running Apache

Servlet portability is not the stumbling block it so often is with applets There are two

reasons Firstly servlet portability is not mandatory Unlike applets which have to be

tested on all possible client platforms servlets have to work only in the server

machines that you are using for development and deployment Unless you are in the

business of selling your servlets you donrsquot have to worry about complete portability

Secondly servlets avoid the most error-prone and inconsistently implemented portion

of the Java language the Abstract Windowing toolkit (AWT) that forms the basis of

Java graphical user interfaces

Servlets are extendable Servlets that are written in Java brings all of the other

benefits of Java to servlet Java is a robust object-oriented programming language

which can be extended easily to suit our needs

Servlets are secure The only way to invoke a servlet from the outside world is

through a Web server This brings a high level of security especially if the Web

server is protected behind a firewall

Servlets can be used with a variety of clients

Servlets are tightly integrated with the server This integration allows a servlet to

cooperate with the server For example a servlet can use the server to translate file

paths to perform logging and to check authorization

Servlets are quite flexible An HTTP servlet can be used to generate a complete web

page it can be added to a static page using a ltSERVLETgt tag in whatrsquos know as a

server-side include and it can be used in cooperation with any number of other

servlets to filter content in something called a servlet chain

18

Chapter 4

Design of On-line Bookstore Using Java Servlets A Practical

Verification

Server-side Java application is one of the latest technologies used to implement an onshy

line store system Servlet is a set of classes that come up from Java language It is

designed to be used for server-side Java applications There are many techniques people

can use when they utilize servlet such as Server-Side Include (SSI) Servlet Chaining

Applet and Servlet communication etc We tried to use as many such techniques as

necessary in our implementation to demonstrate the advantages of servlets

The demonstration system module is same as the one we mentioned above Figure 331

We use this module to show how such system works

The system called Tiny Book Store emulates an on-line bookstore selling computer

books It has the full functionality of other on-line stores The only difference between

this system and the other on-line systems is the database size We donrsquot want to spend

much developing time for database maintaining part because this part is similar to

ordinary database maintaining and it is an independent subsystem The Tiny Book Store

mainly consists of three modules user interface business procedure and data access

19

41 The Design of Home Page of Tiny Book Store

The home page - welcome page - is designed using the Server-Side Include technique

That is embedding a servlet inside HTML file with a specific HTML tag ltSERVLETgt

In our case this servlet when invoked can run a query on database via data access

objects to retrieve most recent top 5 best-seller books and then returns the retrieved data

to the place within the page where the ltSERVLETgt tag was As long as the data in

database update timely it is guaranteed that customer will get the most recent data

The embedded servlet is invoked by Java Web Server before the page is sent back to

client Java Web Server processes any HTML file having shtml extension and invokes

the embedded servlet marked by ltSERVLETgt tags

Server-Side Includes are useful when a page is primarily static but contains a few distinct

dynamic portions One of the servlets produces the ldquo Five Hot Books ldquo which is shown in

the following example

Example 411 A Part of Code of welcomeshtml

lt P gt

lth3xstrongxf ont color= f f 6347 gtWelcome to theltigt

TinyBookStorecomltigtltfontgtltstronggtlth3 gt

20

ltstrongxbxh3gtltcentergtFive Hot

Booksltc e n t e r x h3gtltbgtltstronggt

ltbrgt

ltservlet code=EchoServletTaggt

ltservletgt

The servlet EchoServletTag searches database according to some business rule and gets

data from data access objects to produce the Five Hot Books The following example is

the sample code

Example 412 A Part of Code of The EchoServletTagjava

public void service(HttpServletRequest req

HttpServletResponse res)

throws ServletException IOException

res setContentType ( text Jhtml)

PrintWriter out = resgetWriter()

try

Statement stmt = concreateStatement()

21

ResultSet rs = stmtexecuteQuery(select from

book where

title like Programming)

int count = 1

outprintln(ltdlgt)

while (rsnext() ampamp count lt 6)

out print In ( ltdtxbgt + count + )

String isbn =

rsgetObj ect(ISBN) toString()

outprintln(lta

href=servletDetailContent + isbn +

outprintln(rsgetObj ect(Title) toString()

+ lt a x bgt )

out println ( ltddxnobrxfont color=990033gtUsuallY

ships in 24 hoursltBRxfontxnobrgt )

outprintIn(ltbrgt +

rsgetObject(Author) toString() )

outprintIn( +

r s getObject(Publisher)toString() + +

r s getObj ect(PublicationDate) toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

out println ltbrxbrgt )

22

count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()

The servelt EchoServletTag by the business mle that searching a specific table sends a

request query through data access object stmt and gets search result through another

data access object rs It then passes data to the page The content between ltservletgt and

ltservletgt tags in the HTML of home page is replaced by the search result at run time

The center part of the sample result page in Figure 411 is an example

23

Figure 411 The Home Page of Tiny Book Store

gj Search TinybookstGiecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

^ bullgt o a 4 i a a j ugt- a a Back lt7gtn Stop Refresh Home j Search Favorites History Mail Print Etfe

-Six

sfekinlfeSsI 3 Address |iS1 httpiVlocalhosLSOSCVwelcomeshtrnl Cj

f S M B l TinyBookStorecom

Search B o o k sW e l c o m e tc f l i e

HomeFive H ot Books 1 1

Category i-si

IA uthor

Title1 The C + + Programming L a n g u a g e B

Usually ships in 114 hoursISBN

k

IPublisher D a teBjame Stroustrup Addis on-Wesley Pub Co 1997Our Price 3147

m2 Programming Visual C+ +

Usually ships in 24 hours y

David J Krn^dinski Dlicrosoft Press 1998 c damp Local intranet

From this practice we know Server-Side Include not only can produce dynamic portion

of the page but also prevent from other people spy into your code Since Java servlet runs

entirely on a server thus protecting your intellectual property and shielding you from the

browser This means what the client sees can be totally different from what the server

does From the client side it is difficult to figure out how the server works

The left-hand menu items are implemented by using a characteristic of servlet - extra

path information or virtual path The extra path information can be used as a kind of

parameter passed to a servlet In general this extra path information is used to indicate a

24

file on the server that should use for something We use this feature here in an abnormal

way to manage customer requests and process these requests in a single place

Consider a traditional method When a menu item is selected by a customer it redirects

the customer to another page where it hyperlinks to If we have several ten items we

need to pre-create several ten pages This is the disadvantage of static HTML pages

However with servlet which can dynamically generate page content we can direct all the

customer requests to a central servlet and process the requests there according to some

condition (parameters) and then generate the page which customer need to see In this

way we only need one place to hold the code to save serverrsquos space And this place is

easy to maintain

The following is how it was doing for the Tiny Book Store

The Author item uses the following hyperlink

ltA

href = servlet ReqCo 11 ect author gtAuthorlt fontx AxTDgt

ltTRgt

The ReqCollect is the name of a servlet We pass the ldquoauthorrdquo in the hyperlink as a

parameter to ReqCollect When the Author item is selected ReqCollect is invoked by

lava Web Server ReqCollect generates a html page to let a user input author search

condition The ReqCollect code is listed below

25

Example 413 A part of Source Code of ReqCollectjava

public class ReqCollect extends HttpServlet

protected final String AUTHOR = author

public void service(HttpServletRequest req

HttpServletResponse res) throws ServletException

IOException

PrintWriter out = resgetWriter()

String path = reqgetPathlnfo ()

if (path == null)

error handling

else

Create standard header

CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

26

path = pathsubstring(1)

if (pathequalsIgnoreCase(CATEGORY))

Create category request collect

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

outprintln(ltfont color=CC66 0 0

face-verdana arial helvetica size = + lxbgtEnter

Authorltbgtltfontgt )

outprintln(ltbrgt You can enter

authors full name first name or last nameltpgt)

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess

id=forml name=formlgt)

outprintln(lttable border=0gt)

outprintln(lttrgt lttd valign=middle

align = lef txttgtltbgtAuthor ltbxttxtdgt )

outprintln(lttd valign=middle

align = lef txinput type = text name= author size = 40

value=x tdgt )

outprintln(lttrgt)

27

outprintln(lttrgt lttd colspan=2gt ltfont

size=-lgt)

outprintln(ltcentergt ltinput

type=radio name=author_mode value=exact

checkedgt Exact Name)

outprintln(ltinput type=radio

name=author_mode value=lastgtLast First Name (or

Initial) )

outprintln(ltcentergt)

outprintln(ltfontgt)

outprintln(lttdgt lttrgt)

outprintln(lttrgt lttd colspan=2gt ltpgt

ltbrgt lttdgt lttrgt)

outprintln(lttablegt)

outprintln(ltcentergt)

outprintln(ltinput type=submit

value=Search Now id=submitl name=submitlgt)

outprintln(cinput type=reset

value=Clear Form id=resetl name=resetlxpgt )

outprintln(ltcentergt ltformgt)

Create standard footer

28

CreateFooter(out)

outflush()

outclose()

The generated page looks like this

Figure 412 One of The Searching by Author PagesTinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorite l o o k H e lp

^ 3 4 s j ] S o zdStop Refresh Home Search Favorites History Mail Print EditBack bull

I t i h f e l f f httplocalhost8080servletReqCollectauthor

S ea rch Books

Home

C a t e g o r y

Author

Title

ISBN Publisher Date

poundj

TinyBookStore com

You can enter authors foil name first name or last name

A u t h o r jbjarne

C Exact N ame amp Last First N atne (or Initial)

Search Now | Clear Form

Taw boekstofeeoraH om e | Category | A uthor | Title | IS3M | Publisher Date

jpyright and disclaimer copy 1999-2001 F ang Xiao

ihtterteti

42 Design of Search by Different Requests

29

According to different requests the different pages should be produced There are many

common parts in the produced pages So we donrsquot need to code the common parts for

each page We can design the common parts into standard utility classes or static

functions You can simply call the standard classes or functions when you needed them

An example looks like this

CreateHeader(out)

CreateLeftMenu(out)

CreateFooter(out)

The three lines above invoke the standard functions CreateHeader() CreateFooter() and

CreateLeftMenu() which are developed in this thesis writing The CreateHeader()

function produces the top part of the pages The CreateLeftMenu() function produces the

left part of the pages The Createfooter() function produces the bottom part of the pages

You can find the source code in several servlets in Appendix

43 Servlet Chaining To Process Requests In Different Levels

A request can be handled by a sequence of servlets This system is designed to use the

first level servlets to handle the search requests If needed the first level servlets can

cooperates with the second level servlets by passing their processing result to the second

level servlets and let them to proceed the request until the final result is obtained The

final result is returned by the last servlet This is called servlet chaining The request

30

from the client browser is sent to the first servlet in the chain The response from the last

servlet in the chain is returned to the browser In between the output from each servlet is

passed as an input to the next servlet Each servlet in the chain has the option to change

or extend the content W e can see the example in the ReqCollect code

Example 431 A Part of Code of The ReqCollectjava

if (pathequalsIgnoreCase(AUTHOR))

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess id=forml

name=formlgt)

The ReqCollect servlet uses the getPathInfo() method to get the extra path information

This method returns the extra path information associated with request According to the

different extra path information the first level servlet invokes the different servlet of the

second level In this case ReqCollect invokes AuthorProcess servlet The final output

has been listed in Figure 412

31

44 Database Connectivity and Search from Database

The biggest advantage for servlets with regard to database connectivity is that the servlet

life cycle allows servlets to maintain open database connections An existing connection

can trim several seconds from a response time compared to a CGI program that has to

reestablish its connection for every invocation

Another advantage of the servlets over CGI and many other technologies is that JDBC is

database-independent JDBC is a SQL-level API - one that allows you to execute SQL

statements and retrieve the results if any The API itself is a set of interfaces and classes

designed to perform action against any database

An individual database system is accessed via a specific JDBC driver that implements the

javasqlDrivers interface Drivers exist for nearly all-popular RDBMS systems The

database connection used for Tiny Book Store uses a JDBC-ODBC bridge driver coming

along with the JDK 12 to allow access to standard ODBC data source such as the

Microsoft Access database

The first step in using a JDBC driver to get a database connection involves loading the

specific driver class into the applicationrsquos Java Virtual Machine This makes the driver

available later when we need it for opening the connection An easy way to load the

driver class is to use the ClassforNameQ method

32

ClassforName(sunj dbcodbcJdbcOdbcDriver)

When the driver is loaded into memory it registers itself with the javasqlDriverManager

class as an available database driver

The next step is to ask the DriverManager class to open a connection to a given database

where the database is specified by a specified formatted URL The method used to open

the connection is DriverManagergetConnection() It returns a class that implements the

javasqlConnection interface

Connection con =

DriverManagergetConnection(j dbcodbcsomedb

user passwd)

A JDBC URL identifies an individual database in a driver-specific manner Different

drivers may need different information in the URL to specify the host database

During the call to getConnection() the DriverManager object asks each registered driver

if it recognizes the URL If a driver says yes the driver manager uses that driver to create

the Connection object Here is an example

Example 441 A Part of Code of AuthorProcessjava

public void init() throws ServletException

try

ClassforNamesunj dbcodbcJdbcOdbcDriver)

con =

DriverManagergetConnection(j dbcodbcfxbookstore null

null)

catch (ClassNotFoundException e)

catch (SQLException e)

After we got the database connection we need to have some way to execute queries The

simplest way to execute a query is to use the javasqlStatement class Statement objects

are never instantiated directly instead a program calls the createStatement() method of

Connection to obtain a new Statement object

Statement stmt = concreateStatement()

34

A query that returns data can be executed using the executeQuery() method of Statement

This method executes the statement and returns a javasqlResultSet that encapsulates the

retrieved data

Example 442 A Part of Code of AuthorProcessjava

String sqlStmt =

if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where author= + name +II i n

else

sqlStmt = select from BOOK where author like +

name +

ResultSet rs = null

Statement stmt = concreateStatement()

rs = stmtexecuteQuery(sqlStmt)

35

A ResultSet object can be thought as a representation of the query result returned one row

at a time The next() method of ResultSet is used to move from row to row The

ResultSet interface also boasts a multitude of methods designed for retrieving data from

the current row The getStringO and getObject() methods can be used for retrieving

column values

Example 443 A Part of Code of AuthorProcessjava

while (rsnextO )

count++

outprintln(ltdtgtltbgt + count + )

String isbn = rsgetObject(ISBN)toString()

outprintln(lta href=servletDetailContent + isbn +

gt )

outprintln(rsgetObj ect(Title) toString() +

ltagtltbgt)

outprintln (ltnobrxfont color=990033gtUsually ships

in 24 hoursltBRgtltfontxnobrgt)

outprintln(ltddgt +

rsgetObj ect(Author) toString() )

36

outprintln( +

rs getOb j ect ( Publisher) toString () + +

rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

outprintln(ltbrgtltbrgt)

One of the outputs of servlet AuthorProcess is show in Figure 421 and Figure 441

Figure 441 One of The Outputs of Servlet AuthorProcess

37

File Edit View Favorites lo o k - Help M i

T 1 bdquo - 0 L Q 4 pound $ L L lBack r s Stop Refresh Home S earch Favorites History

A - Mail Print

Links rdquo Address | jyen j http7ocalhost808O$ervletAuthorProcess 3

Search B ooks

Home

CategoryA uthor

Title

ISBN

P u b l i sh e r D a te

Tiny Bookstore com

1 The C++ Prograitmuitg Language Usually ships in 24 hour Bjame Stroustrup Addison-Wesley Pub Co i 1997 Our Price 3147

T in yb o oks to re c om H ora e | Category | A uthor | Till | ISBN | Publisher P a t

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top of Page

gk j Local intranet

45 Session Tracking

Session Tracking is one of the most important techniques for any on-line store systems

This is because that HTTP protocol is a stateless protocol A HTTP server sees only a

series of requests and it by itself has no way to know exactly who is making the request

This means that when a customer puts a book in his shopping cart and then goes to other

pages to find more books next time when he puts another book in his shopping cart there

is no guarantee that he puts the book in the same cart It is very possible that he uses

another customerrsquos shopping cart at this time

38

To solve this problem session-tracking is introduced Traditional techniques used by

CGI include hidden form fields URL rewriting user authorization and persistent cookies

For server-side Java applications a built-in class supplied servlet can be used easily to

handle such tasks

When a user first accesses the site web server assigns a new HttpSession object and a

unique session ID to the user The session ID identifies the user and is used to match the

user with the HttpSession object in subsequent requests Usually the session ID is saved

on the client in a cookie or sent as part of a rewritten URL The Tiny Book Store uses this

technique

The Tiny Book Store is a classic shopping cart application A client can put items in his

virtual cart accumulating them until he checks out several page requests later How to

make sure a userrsquos shopping items will be put in his shopping cart or delete from his

shopping cart The Java Servlet API provide built in session tracking to handle this

problem Every user of a site is associated with a javaxservlethttpHttpSession object

that servlets can use to store or retrieve information about that user We can save any set

of arbitrary Java objects in a session object For example a userrsquos session object provides

a convenient location for a servlet to store the userrsquos shopping cart contents An example

shows below

Example 451 A Part of Code of AddToShoppingCartjava

39

1 Get current session object create one if necessary

2 HttpSession session = reqgetSession(true)

3 m_cart = (ShoppingCart)sessiongetValue(cart)

4 if (ra_cart == null) need new cart

5 create a shopping cart

6 m_cart = new ShoppingCart()

7 add to current session

8 sessionputValue(cart m_cart)

9

10

11 try

12 Statement stmt = m_concreateStatement()

13 ResultSet rs = stmtexecuteQuery(select from

book where ISBN= + isbn +)

14 if (rsnext())

15 book - new

BookDetails(rsgetObj ect(ISBN) toString()

16 rsgetObject(Title)toString()

rsgetObj ect(Authorrdquo) toString()

17 rsgetDouble(Price)

rsgetObj ect(PublicationDate) toString() )

18

40

1 9

2 0 catch (SQLException e)

21 e printStackTrace()

22

23 m_cartadd(bookgetlSBN() book)

The servlet uses its request objectrsquos getSession() method to retrieve the current

httpSession object

public HttpSession HttpServeltRequestgetSession (boolean create)

This method returns the current session associated with the user making the request If

the user has no current valid session this method creates one if create is true or return

null if create is false To ensure the session is properly maintained this method must be

called at least once before any output is written to the response Please look at the line 2

in the example 451

If you want to add data to an HttpSession object you can use the putValueQ method

public void HttpSessionputValue(String name Object value)

41

This method binds the specified object value under the specified name Any existing

binding with the same name is replaced This specifies at line 8 of the example 451

If you want to retrieve an object from a session you can use getValue() method

public Object HttpSessiongetValue(String name)

This method specified at line 3 of example 451 returns the object bound under the

specified name or null if there is no binding

From line 4 to line 9 the servlet checks whether the user already has a shopping cart If

the user didnrsquot have a shopping cart the servlet assigns a shopping cart to this user and

add the shopping cart to the current session to keep tracking The ShoppingCartjava class

is developed in this thesis writing code is provided in the appendix

From line 10 to line 21 the servlet knows the user already has a shopping cart m_con is

a data member of AddtoShoppingCart class Lines 12-13 have been discussed in the

previous section Lines 16-20 get some information of the book which the user selected

The information will be the data members of the ldquobookrdquo object that is an instance object

of BookDetailsjava class BookDetailsjava class is developed in this thesis writing the

source code is provided in the Appendix

Line 25 puts the book which is selected by the user into the shopping cart

42

Please see a set of pages are shown below

Figure 451 A Page Show All Information About A Book

TinjiRnfikStnre com - M inrnsnfl Interned Explnrpr

File Edit View Favorites Tools Help-

^ O 4 4 1 f i tStop Refresh Home I Search Favorites History Mail Print Edit

I Link gtgt Address [gl hgtplocalhos9l]IBrit-rvetDetailConetit-Ll20183l)544

S e a r c h B o o k s

Home-

C a t e g o r y

Author

Title

ISSNPublisher Pate

TinyBookStore com

The C++ Programming Languageby Bjarne Stroustrup

aISBN 0201889544 Addison-Wesley Pub Co 1997

Price 3147 Availability U sually ships within 24 hours

Add to cart

Done

R ev iew s

In tins brand-new third edition of The C + + Programming Language author Bjame Stroustrup the creator of C++ presents the full specification for the C++ language and standard library a spec that will soon become the joint ISOANSI C++ standard

g ig L o ca l in tranet

43

Figure 452 A Page Show Items In The Shopping Cart after A User Added Books To The Shopping Cart

H H I H I - I I

j File Edit View Favorites l o o k Help I f

| S ack Stop Refresh Home Search FavoritesJ V

History Wail Print

j Links Address |S1 http7localhost8O80servletAddToShoppingCart i i i i a i i i

( O ldquo ii

Shopping Cart Item s Price

An Introduction to fen e tic Algorithm sMelanie MteheU Quantity 1 Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

drle trgt

delete

delete

Price $ 2 2 0 Subtotal $ 2 2 0

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 6 7 5 6

|euro

rfuj Local intranet

44

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A Book From The Shopping Cart

^ A m a z o n c o m Shopping Cart - Microsoft Internet Explorer

- J A l 4Stop Refresh Home

gtH bdquo ] Back bdquo

httplocalhost8080servletDeleteFromShoppingCartitemgetltem()getlSBN()

Ji _J 3Search Favorites History

j - JMarl Print

~U ccdeg

Shopping Cart Item s

Core Java 2Cay S Horstrnaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d elete

delete

Price

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 4 5 5 6

rsquo0 1 Done gSsfLocat intranet

46 Check Out

This part is designed only using the HTML It collects all information from a user The

information will be written into the database

An important line in this HTML file is shown below

45

ltform method=POST

action=httplocalhost808 0servletCustomerlnfoProcessgt

This line will invoke the servlet CustomerlnfoProcess that will process all data collected

from the user This servlet will discuss in the next section The check out page shows in

Figure 461

Figure 461 A Check Out Page

M M iH M M M i M MmmrnfrnM File Edit View Favorites too ls Help

^ gt a 3 A hi -ltamp f V j HISllll mmB ack S lop R efresh H em e S earch 1 i l lie History M 1 Print Edit

^Links A ddrecs j ig ] h ltp localhostSO SO checkouth tm l i i i l a s

Custom er Information

First name (Fang

Middle initial |a

Last name [Xiao

Email address |fgtdaomitecnet

Account password Jxxxxx

C red it card num ber jl 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7

Credit card type ttV isa O BluebirdO MasterCard O Fisher

Credit card holder jFarig Xiao

Credit card expire date (tnmddyy) joi 0102 ~

Select shipping method t UPS 0 NormalO Express C Abnormal

| | ] Dorraquo raquo f j^ I o c a l intranet

47 Customer Information Processing

The customer information processing is handled by a servlet CustomerlnfoProces Its

source code is provided in the appendix

46

All information collected from the user should be written into the database therefore we

have to open a connection to a given database at first Example 461 is given for this

purpose

Example 471 A Part of Code of CustomerlnfoProcessjava

public void init() throws ServletException

try

ClassforName(sunjdbcodbcJdbcOdbcDriver)

m_con = riverManagergetConnection(jdbcodbcfxbookstore

null null)

catch (ClassNotFoundException e)

e printStackTrace()

catch (SQLException e)

e printStackTrace( )

There is a PO ST request in the check out page The servlet CustomerlnfoProcess will

handle the PO ST request by doPost function which is demonstrated in the following

example

47

Example 472 A Part of Source Code of CustomerlnfoProcessjava

public void doPost (HttpServletRequest req HttpServletResponse res)

throws ServletException IOException

ressetContentType(texthtml)

PrintWriter out = resgetWriter()

get information

String[] values = reqgetParameterValues(firstname)

if (values = null)

firstname = values[0]

values = reqgetParameterValues(middleinit)

if (values = null)

middleinit = values[0]

In the example the HttpServletRequest object res will get each data which was input by

the user by the getParameterValues() function

If the user is a returned user we donrsquot need open a new account again If the returned user

use the same credit card as previous we also donrsquot need to insert the credit card

48

information into the CREDITCARD table Otherwise we should insert all related

information into related table This is shown in the following example

Example 473 A Part of Source Code of CustomerlnfoProcessjava

Statement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where EmailAddress= +

email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext())

sql = insert into CUSTOMERACCOUNT (emailaddress password

firstname middleinit lastname) values ( + + email +

password + + firstname + + middleinit + lastname +

)

stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber= + creditcard

+

rs = stmtexecuteQuery (sql)

if (rsnext())

49

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype

HolderName ExpirationDate) values( + + creditcard + +

cardtype + + cardholder + 11 + expiredate + )

stmtexecute (sql)

All information related the books selected by the user can be obtained from the

shopping cart as shown in the following example

Example 474 A Part of Source Code of CustomerlnfoProcessjava

BookDetails book = null

ShoppingCartltern bookAndQuantity = null

Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getltems()

int aQuantity =0

String alSBN = null

while (itemshasMoreElements())

insert into Orderltems

bookAndQuantity = (ShoppingCartItem)itemsnextElement()

book = bookAndQuantitygetltem()

50

aQuantity = bookAndQuantitygetQuantity()

alSBN = book getISBN()

sql = insert into ORDERITEMS (shoppingCartID ISBN quantity)

values ( + + m_cartID + + aISBN + + aQuantity + )

stmtexecute (sql)

After all information inserted into related tables the servlet CustomerlnfoProcess will

produce invoice page The example page shows in Figure 471

51

Figure 471 An Invoice Page 3 Order List Microsoft Internet Explorer

is File Edit View Favorites Tools Help

J J J U r PS to p Refresh Hom e i -S earch Favorites History s Mai Print

Links Address iff 1 httpVlocalhostBOSOservletCustomerlnfoProcess 3

s5al Local intranet

Y ou r order reads as fo llow sE-MailAddress fiiiaomitecnet

ship to

Tel

Items

F ang Xiao12345 Western Plaza 23OmahaNE68154(402)123-4567

TitleCore Java 2Qtyl Price2579Subtotal2579

TitleJava Servlet PrograrnmingQtyl Price 1977 Sub total 1977 Total4556

i|51 D one

52

Chapter 5

Future Work

In this chapter we discuss two major problems for our future work They are the

Connection Pooling and Object-Oriented for better encapsulation

51 Connection Pooling

After we have used JDBC for a short time it will become evident that the major

performance bottleneck often comes right at the beginning when you are opening a

database connection This is because that opening a connection might involve a series of

low level communications between network protocols and database connection protocols

such as TCPIP ODBC etc

Servlet life cycle allows for extremely fast database access Servlet is loaded into Web

server only once Once it is loaded it can hold a connection to database all its life cycle

Every time it receives a request to read from or write data to database it can just use the

connection to do this

Here comes a problem however Suppose that a customer comes to the on-line store

During the period of selecting some items from the store he leaves his desktop and do

something else leaving this connection to database idling This will waste the precious

resource on the database From database port of view the connection to the database will

assign a space to hold corresponding status and to cache data For example Microsoft

SQL-Servertrade assigns about 36K bytes for each of its connection Resource on the

53

database is limited and idling connection causes such resource unable to be reused for

other users

To solve this problem we can use the technique called connection pooling Essentially a

connection pool is an object holding connections to backend database and managing the

number and status of connections For example if a connection in the pool idles over a

certain time of period the pool can terminate this connection if the requests are not the

same size of the connection pool the pool can dynamically shrink or expand the size of

itself A connection pool can run on a separate thread and is initialized when the server

starts or when a request to database is arrived

To implement a connection pool is pretty straight-forward Because of time constraint

however we did not do it in this paper and leave it as a possible future improvement

52 More Object-Oriented - Better Encapsulation

Another improvement might be done in the future is to create a HTML-related utility

class We have seen in this thesis that there are some duplicated code processing HTML

output such as ldquoout printIn ( lttbxtrgt lttrxtbgt)rdquo All these HTML-

related processes right now are used in a raw way That is they are not encapsulated A

better way to do this is to create a utility class or classes to deal with all HTML-related

processes and hide all HTML tags and format inside the class or classes For example

suppose that we create a Table class then we can use it in a way like

Table table = new Table()

54

table(somerow somecol contents)

table(somerow somecol some_image)

In this way we do not need to use HTML tags in our program and concentrate on the

programming logic The implementation is enriched with more object-oriented property

and therefore it is easy to maintain

55

Chapter 6

Conclusion

The increased awareness and popularity of the Internet make all kinds of electronic

commerce grow vigorously The most popular Web applications are the on-line stores

An on-line store system usually contains four components Web server business

procedure Database system application An on-line store system is different from web

publishing Currently there are three mainstream technologies which are widely used to

develop the on-line store systems CGI Microsoft ASP and Server-side Java application

Introducing the server-side Java application is one of the latest and most exciting trends

in Java programming We have discussed this technology in detail in this thesis The

server-side Java applications have many distinct advantages over CGI and other

technologies We present plenty of examples and figures to analysis the characteristics of

the server-side Java application

As a glance into the future electronic commerce will continue to grow driven by

purchases of home computers and other Web-enabled devices as well as new business

opportunities Electronic commerce is changing whole business procedures The future of

electronic commerce will be exciting and full of opportunities

56

APPENDIX A

Bibliography

57

[1] Karl Moss 1998 Java Servlets Mcgraw-Hill

[2] Jason Hunter William Crawford 1998 Java Servlet Programming O rsquoReilly

[3] Manoj Kumar Anand Rangachari Anant Jhingran Rakesh Mohan 1998 Sales Promitions on the Internet h ttpwwwibmcomiactech-paperhtml

[4] Manoj Kumar Stuart I Feldman 1998 Business Negotiations on the Internet httpwwwibmcomiactech-paperhtml

[5] Manoj Kumar Stuart I Feldman 1998 Internet Auction httpwwwibmcomiactech-paperhtml

[6] Shiwa Fu Jen-Yao Chung Walter Dietrich Vibby Gottemukkala Mitchell Cohen Shyhkwei Chen 1999 A Practical Approach to Web-Based Internet EDI httpwwwibmcomiacpapersicdcsws99indexhtml

[7] Zhong Tian Leo Y Liu Jing Li Jen-Yao Chung Vibby Guttemukkala 1999 Business-to-Business e-Commerce with Open Buying on the Internethttpw w w ibm comi acpapersobi -paperindex html

[8] Gerald J Tesauro Jeffrey O Kephart 1998 Foresight-Based Pricing Algorithms in an Economy os Software Agents http wwwi bm comi actech - paper html

[10] Jeffrey O Kephart James E Hanson Jakka Sairamesh 1998 Price and Niche Wars in a Free-Market Economy o f Software Agents httpwwwibmcomiactech-paperhtml

[11] Jeffrey O Kephart James E Hanson David W Levine Benjamin N Grosof Jakka Sairamesh Richard B Segal Steve R White 1998 Dynamics o f an Information-filtering Economy httpwwwibmcomiactech-paperhtml

[12] James E Hanson Jeffrey O Kephart 1998 Spontaneous Specialization in a Free-Market Economy os Agents httpwwwibmcomiactech-paperhtml

[13] Jakka Sairamesh Jeffrey O Kephart 1998 Price Dynamics o f Vertically differentiated Information Markets httpwwwibmcomiactech-paperhtml

[14] David Kosiur 1997 Understanding Electronic Commerce Microsoft Press

[15] Gunther Birznieks Selena Sol 1997 CGI fo r Commerce MampT Books - A Division of MIS Pres

58

[16] Ravi Kalakota Andrew B Whinston 1997 Electronic Commerce Addison Wesley

[17] Alex Fedorov Richard Harrison Dave Sussman Brian Francis Stephen Wood 1998 Profession Active Server Page 20 Wrox Press

[18] Calvin Austin Minica Pawlan 1999 Writing Advanced Application for the Java PlatformhttpVdeveloper iavasuncomdeveloperonlineTrainingProgrammin gJDCBooki ndexhtml

59

APPENDIX B

The Source Code of An On-Line Store System - Tiny Book Store

60

1 welcomeshtml

lthtmlgtltheadgtlttitlegtSearch Tinybookstorecomlttitlegtltheadgtltbodygt

lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=eeeeccgtlttrgtlttd rowspan=2 align=left valign=top width=15 cellspacing=0 cellpadding=0xIM G border=0 hspace=0 id=IMGl src=flowergif gtlttdgtlttd rowspan=2 align=left valign=centergtltstronggtlth2gtltigtTinyBookStorecomltigtlth2gtltstrongxtdgtlt trx tab legt

lttable border=0 width=100 cellspacing=0 cellpadding=0gtlttrgtlttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtltPgt

lttable width=100 cellspacing=0 cellpadding=5 border=0gtltTRgt ltTDgt ltTDgt ltTD colspan=2gt ltFONT FACE=verdanaarialhelvetica SIZE=-1 gtampnbsp ltFONTgt ltTDgt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD co lsp an = 2 x stro n g x fo n t face=verdanaarialhelvetica size=-lgtSearch B ooksltfontxstronggt ltTDgt ltTRgtltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt ltTD x f o n t face=verdanaarialhelvetica size=-l gt

lta href=w elcom eshtm lgtH om eltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt c T D x fo n t face=verdanaarialhelvetica size=-1 gt

lt A href= servletReqC ol 1 ec tc ategory gtC ate gory ltf o n tx A x T D gtltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollectauthorgtA uthorltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollecttitlengtTitleltorfo n tx A x T D gt ltTRgt

61

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectisbngtISBN ltA xfontxTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectpublisher_dategtPublisherD a telt A x fo n tx T D gtltTRgtlt tab lex p gtlttdgt

lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgtlttd valign=top align=leftgt

ltbr clear=allgtltPgtlt h 3 x s tro n g x fo n t color=ff6347gtWelcome to theltigt T in y B o o k S to rex o m lt ix fo n tx s tro n g x h 3 gt

ltbrgtlt s tro n g x b x h 3 x c e n te rgt F iv e Hot B o o k slt cen te rx h 3 x B x s tro n g gt

ltbrgtltservlet code=EchoServetTag myArgI=myValuel myArg2=myValue2gt ltparam name=myParm 1 value=Hellogtltparam name=myParml value=Worldgtltparam name=myParm2 value=myParmValue2gtltservletgt

lt td x trgt

lttablegt

ltTABLE width=100gtltTRgt ltTD width=50 valign=top align=Ieftgt ltTDgtltTD width=50 valign=top align=rightgtltfont size=-lgtltA href=topgtTop of P ag elt A x fo n tx T D gt ltTRgt

62

ltTABLEgt

ltcentergtltfont size=-lgtltA href=indexhtml gtTinybookstorecom HomeltAgt ampnbsplampnbsp ltA href=categoryhtml gtCategoryltAgt ampnbsplampnbspltA href= author html gtAuthorltAgt ampnbsplampnbspltA href= title html gtTitleltAgt ampnbsplampnbspltA href=7isbnhtml gtISBNltAgt ampnbsplampnbspltA href=publisherhtmrgtPublisher DateltAgtltpgtltfontgtltcentergt

ltPgtltcentergtlt b rx fo n t size=-lgtltA href=copyrighthtml gtCopyright and disclaimerltAgt copy 1999-2001 Fang Xiao ltfontgtltcentergt

ltbodygtlthtmlgt

63

2 AddToShoppingCartjava

ltpgt AddToShoppingCart is the servlet that process the action of adding item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javasql import javautil import javaxservlet import javaxservlethttp

public class AddToShoppingCart extends HttpServlet

protected Connection m_con = null protected ShoppingCart m_cart protected BookDetails book

public void initQ throws ServletException try

Class forName( sunj dbc odbc JdbcOdbcDriver)m_con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintstackTrace ()catch (SQLException e)

e prints tackT race ()

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

String[] params = reqgetParameterValues(isbn)

64

String isbn = get isbn from extra path infomationif (params = null)

isbn = params [0]

Get current session object create one if necessary HttpSession session = reqgetSession(true) m_cart = (ShoppingCart)sessiongetValue(cart)

if (m_cart == null) need new cart create a shopping cart m_cart = new ShoppingCart() add to current session sessionputValue(cart m_cart)

try Statement stmt = m_concreateStatement()ResultSet rs = stmtexecuteQuery(select from book where

ISBN=rsquo + isbn + rsquo)

if (rsnext()) book = new BookDetails(rsgetObject(ISBN)toString()

rsgetObject(TitIe)toStringOrsgetObject( Author) toStringO

rsgetDouble( Price) rs getObj ect( PublicationDate) toStringO)

catch (SQLException e)

eprintStackTrace()m_cartadd(bookgetISBN() book)

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lt h tm lxheadx titlegt T inyB ookS tore com S hopping

Cartlttitlexheadgt)outprintln(ltbody bgcolor=FFFFFF lmk=003399

alink=FF9933 vlink=996633 text=000000ngt)outprintln(lta nam e= topxmdashTop of Pagemdashx a gt )

65

outprin tln(ltpxa href=httplocalhost8080checkouthtmlximg src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=cccc99 gt)ou tp rin tln (lt tdxbrx tdgt )ou tp rin tln (lt tdxbrx tdgt )o u tp rin tln (lt tdxbrx tdgt )outprintln(lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=2xfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=left valign=topxfont

face=verdanaaria lhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=cccc99gt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lt td x b rx td gt ) outprintln(lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantityQ

outprintln(lttr bgcolor=FFFFFFgt) ou tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt )outprintln(ltbrgt + item getltem() get Author()) outprintln(ltbrgtQuantity + itemgetQuantityO) outprintln( ltbrgt) outprintln(lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=POST

action=7servletDeleteFromShoppingCartitemgetItem()getISBN()gt)

66

outprintln(ltpgt cinput type=hidden name=isbn value= + itemgetItem()getISBN())

outprintln(ltpgt ltinput type=submit name=ditemvalue=deletegt)

outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelve tica color=000000gt)

outprintln(ltNOBRgtltbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fon tx bx N O B R gt ltbrgt )

outprintln(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantity() + lt fo n tx b x N O B R x b rgt )

outprintln(ltfontgt) out println( lttdgt)

out printl n( lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)out println( lt fo n tx fo n tgt )outprintln(lttdxtrgt)outprintln(lttablegt)outprin tln(ltpxa href=httplocalhost8080checkouthtmlYximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)outprintln(ltbodygt lthtmlgt)

outflush()outclose()

67

3 AuthorProcessjava

bull ltpgt AuthorProcessbull This is the servlet that process the Author-search request and generatebull search resultbull Author Fang Xiao Purpose Thesis project Copyrightcopy Fang Xiao 1999-2001

import javaxservlet import jav ax servlet http import javaio import javasql

public class AuthorProcess extends HttpServlet protected final String EXACT = ldquoexactrdquo protected final String OTHERS = ldquolastrdquo

protected Connection con = null

public void init() throws ServletException try

ClassforName(ldquosunjdbcodbcJdbcOdbcDriverrdquo)con = DriverManagergetConnection(ldquojdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(ldquotexthtmlrdquo)PrintWriter out = resgetWriterQ

68

String[] valuesString name =

values = reqgetParameterValues(ldquoauthorrdquo) if (values = null)

name = values [0]

String mode = ldquordquovalues = reqgetParameterValues(ldquoauthor_moderdquo) if (values = null)

mode = values [0]

String sqlStmt = ldquordquo if (modeequalsIgnoreCase(EXACT))

sqlStmt = ldquoselect from BOOK where author=rsquordquo + name +else

sqlStmt = ldquoselect from BOOK where author like lsquordquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

ldquoYour Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ldquoltdlgtrdquo) 11 start Glossary List

while (rsnext()) count++outprintln(ldquolt d tx b gt rdquo + count + ldquo ldquo)String isbn = rsgetObject(ldquoISBNrdquo)toString()

69

outprintln(ldquolta href=servletDetailContentrdquo + isbn+

outprintln(rsgetObject(ldquoTitlerdquo)toString() +ldquolt a x b gt rdquo)

outprintln(ldquolt n o b rx fo n t color=990033gtUsually ships in 24 h o u rslt B R x fo n tx n o b rgt rdquo)

outprintln(ldquoltddgtrdquo +rsgetObject(ldquoAuthorrdquo)toString())

outprintln(ldquo ldquo +rsgetObject(ldquoPublisherrdquo)toString() + ldquo ldquo + rsgetObject(ldquoPublicationDaterdquo)toString())

outprintln(ldquoltbrgt Our Price ldquo +rsgetObject(ldquoPrice)toString())

outprintln(ldquolt b rx b rgt rdquo)

if (count == 0) outprintln(ldquoltdtgt No matched data foundrdquo)

outprintln(ldquoltdlgtrdquo) end Glossary List

catch (SQLException e) create footer here outprintln(ldquolttdgt lttrgtrdquo) outprintln(ldquolttablegtrdquo)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(ldquolthtmlgtrdquo) outprintln(ldquoltheadgtrdquo) outprintln(ldquolttitlegt TinyBookStorecom lttitlegtrdquo) outprintln(ldquoltheadgtrdquo)

outprintln(ldquoltbodygtrdquo)

70

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspacing=0 cellpadding=0 bgcolor=rdquoEEEECCYrsquogtrdquo)

outprintln(ldquolttrgtrdquo)outprintln(ldquolttd align=left valign=top width=90 gtrdquo) outprintln(ldquoltIMG border=0 hspace=0 id=IMGl

src=rdquodJavaWebServer20public_htmlflowergifrdquogtlttdgtrdquo) outprintln (ldquolttd width=30gtlttdgtrsquorsquo) outprintln(ldquolttd align=left valign=center width=300gtrdquo)

outprintln(ldquolt stro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x s tro n g x td gt rdquo) outprintln(ldquolttd align=right valign=centergtrdquo) outprintln(ldquolttdgtrdquo) outprintln(ldquolttd w id th= 20x tdgt rdquo) out pri ntln (ldquolttrgtrsquo rsquo) outprintln(ldquolttablegtrdquo)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ldquolttable width= 100gtrdquo)outprintln(ldquolttrgt lttd width=50 valign=top align=leftgt lttdgtrdquo) outprintln(ldquolttd width=50 valign=top align=rightgtrdquo) outprintln(ldquoltfont s iz e = - lx a href=rdquotoprdquogtTop of P agelt ax fon tgt rdquo) outprintln(ldquolttrgtrdquo) outprintln(ldquolttablegtrdquo)

outprintln(ldquoltcentergtrdquo) outprintln(ldquoltfont size=-lgtrdquo) outprintln(ldquolta

href=rdquohttplocalhost 8080welcomeshtmlrdquogtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080$ervletReqCollectcategoryrdquogtCategoryltagtampnbsplampnbsprdquo)

outprintln(ldquoltahref=Yhttplocalhost8080servletReqCollectauthorrdquogtAuthorltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_daterdquogtPublisheramp44Dateltagtrdquo)

outprintln(ldquoltpgtrdquo)

71

outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltpgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquolt b rx fo n t size=-lgtrdquo)outprintln(ldquoltA href=Y7copyrighthtmlrdquogtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiaordquo)outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltbodygtrdquo) outprintln(ldquolthtmlgtrdquo)

i

protected void CreateLeftMenu(PrintWriter out) System out println(ldquoLeftMenurdquo)

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspaeing=0 cellpadding=0gtrdquo)

outprintln(ldquolttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtrdquo)

outprintln(ldquoltpgtrdquo)

outprintln(ldquolttable width=rdquo 100rdquo cellspaeing=0 cellpadding=5border=0gtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquoltfont face=verdanaarialhelvetica SIZE=rdquo- l rdquogtampnbsp

ltfontgtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquolt strongxfon t face=verdanaarialhelvetica size=rdquo-

1 rdquogtSearch B ooksltfontxstronggtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd ldquo) outprintln(ldquoltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080welcomeshtmlYgt H o m elt fo n tx ax td gt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=rdquo-1rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080servletReqColIectcategoryrdquogt C ateg o ry lt fo n tx ax td gtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

72

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectauthorrdquogtAuthorltfontgtltagtlttdgtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width-2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l W rsquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltfontgtltagtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo-lYgtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_dateVrsquogtPublisher Dateltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolt tab lex p gt rdquo)

outprintln(lsquolsquolttdgtrdquo)outprintln(ldquolttd rowspan=4 width=5gtampnbspampnbspltbrgtlttdgtrdquo) outprintln(ldquolttd valign=top align=leftgtrdquo) outprintln(ldquoltbr clear=allgtrdquo)

73

4 BookTeatailsjava

ltpgt This is the class describing a book item in shopping cart

Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class BookDetails private String m_isbn = null private String m_title = null private String m_author = null private double m_price = 00 private String m_year = null

public BookDetails(String isbn String title String author double price String year)

thism_isbn = isbn thism_title = title thism_author = author thism_price = price thism_year = year

public String getISBN() return m_isbn

public String getTitle() return m_title

public String getAuthor() return m_author

public double getPrice() return m_price

ipublic String getYearQ

return m_year

75

5 CategoryProcessjava

ltpgt CategoryProcess This is the servlet that process the Category-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql import javautil

public class CategoryProcess extends FlttpServlet protected final String EXACT = exactprotected final String OTF1ERS = last

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

76

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentType( texthtml)Print Writer out = resgetWriterQ

String[] values String name = String sqlStmt =

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

else

path = pathsubstring(l) if (pathequalsIgnoreCase(cO 1))

sqlStmt = select from BOOK wherecategoryid=rsquo + cOl +

else if (pathequalsIgnoreCase(c02))sqlStmt = select from BOOK where

categoryid=rsquo + c02 +else if (pathequalsIgnoreCase(c03))

sqlStmt = select from BOOK wherecategoryid=rsquo + c03 +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftM enu(out)

Your Book Search Results try

77

if (con = null) Statement stmt = concreateStatement() rs = stmt executeQuery (sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn

+outprintln(rsgetObject(Title)toString() +

lt ax bgt )outprintln(ltnobrxfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltddgt +

rsgetObject( Author)toStringO)outprintln( +

rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)outprintln(ltbrgt Our Price +

rsgetObject( Price) toStringO) ltfont color=990000gtYou Save $1100

(20)ltfontgtoutprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

78

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)out println( lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20publicbdquohtmlflowergifgtlttdgt) outprintln(lttd width=3 0gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln( lt s tro n g x h 2 x igt T inyB ookS to re com lt ix h2x s tro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlngtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

79

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYrsquogtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln( ltfontgt)outprintln(ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rOwspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt)

outprintln(lttablewidth= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=Y2Ygt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y-1 Yrsquogtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2Yrsquogt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=Y-

lYrsquogtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=Y-lYgt)

80

outprintln(ltahref=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqColIectcategorygtCategoryltfontxagtlttdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(nltahref=httplocalhost8080servletReqCollectauthorVrsquogt A u th o rlt fo n tx ax td gtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httpIocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

6 CustomerlnfoProcessjava

ltpgt CustomerlnfoProcessThis servlet is responsible to process userrsquos information when heshe check out

Author Fang Xiao

Purpose Thesis projectCopyright (C) Fang Xiao 1999-2001

import javasql import javaio import j avau til import javaxservlet import javaxservlethttp

public class CustomerlnfoProcess extends HttpServlet protected Connection m_con = null protected HttpSession m_session = null protected static int m_cartID = 1 protected String firstname =protected String middleinit =protected String lastname =protected String email =protected String password =protected String creditcard =protected String cardtype =protected String cardholder =protected String expiredate =protected String shipping =protected String receiver =protected String address =protected String city =protected String state =protected String zipcode =protected String phone =

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)

82

m_con = DriverManagergetConnection(jdbcodbcfxbookstorenull null)

catch (ClassNotFoundException e)

eprintStackTrace()catch (SQLException e)

eprintStackTrace()i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

get informationString[] values = reqgetParameterValues(firstname) if (values = null)

firstname = values [0]

values = reqgetParameterValues(middleinit) if (values = null)

middleinit = values [0]

values = reqgetParameterValues(lastnameM) if (values = null)

lastname = values [0]

values = reqgetParameterValues(email) if (values = null)

email = values [0]

values = reqgetParameterValues(password) if (values = null)

password = values [0]

values = reqgetParameterValues(creditcard)

if (values = null) (creditcard = values [0]

values = reqgetParameterValues(cardtype) if (values = null)

cardtype = values [0]

values = reqgetParameterValues(cardholder) if (values = null) (

cardholder = values [0]

values = reqgetParameterValues(expiredate) if (values 1= null)

expiredate = values [0]

values = reqgetParameterValues(shippingrdquo) if (values = null)

shipping = values [0]

values = reqgetParameter Values (receiver) if (values = null)

receiver = values [0]

values = reqgetParameterValues(address) if (values = null)

address = values [0]

values = reqgetParameterValues(city) if (values = null) (

city = values [0])

values = reqgetParameterValues(state) if (values = null) (

state = values [0]

84

values = reqgetParameterValues(zipcode) if (values = null) (

zipcode = values [0]

values = reqgetParameterValues(phone) if (values = null)

phone = values[0]i

get session object m_session = reqgetSessionQ

try update databaseStatement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where Email Address=rsquo + email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext()) Systemoutprintln(insert customeraccount)

sql = insert into CUSTOMERACCOUNT (emailaddress password firstname middleinit lastname) values ( +

+ email + + password + + firstname +V + middleinit + + lastname + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber=rsquo +creditcard +

rs = stmtexecuteQuery (sql)

if (rsnext()) Systemoutprintln(insert creditcart)

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype HolderName ExpirationDate) values( +

+ creditcard + + cardtype + +cardholder + + expiredate + rdquo)

Systemoutprintln(sql)stmtexecute (sql)

i

85

sql = insert into SHOPPINGCART (ShoppingCartIDEmail Address CreditCardNumber ShippingType ReceiverName ReceiverAddress ReceiverCity ReceiverState ReceiverZipcode ReceiverPhone) values ( + m_cartID + V + email + Vrdquo +

creditcard + V + shipping + + receiver ++ address + V +

city + V + state + V + zipcode + V + phone +gt gt

Systemoutprintln(sql)stmtexecute (sql)

BookDetails book = nullShoppingCartltem bookAndQuantity = null Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

int aQuantity =0 String alSBN = null

while (itemshasMoreElementsO) insert into Orderltems bookAndQuantity =

(ShoppingCartItem)itemsnextElement()book = bookAndQuantitygetItem()

aQuantity = bookAndQuantitygetQuantity() alSBN - book getISBN()

Systemoutprintln(insert Orderltems)sql = insert into ORDERITEMS (shoppingCartED ISBN

quantity) values ( + m_cartID + +alSBN + + aQuantity + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

im_cartID++ must increase by one

86

catch (SQLException e) eprintS tackTrace()

printOrder(out)

public void printOrder(PrintWriter out) outprintln( lthtmlgt ltheadgt lttitlegt Order List lttitlegt ltheadgt) outprintln( ltbodygt)outprintln(lthlgt Your order reads as follows lthlgt)outprintln(lttablegt)outprintln( lttrgt)outprintln( lttdgtE-Mail Addres s lttdgt) outprintln(lttdgt+ em ail+lttdxtrgt) outprintln(lttrgt) outprintln(lttdgtship tolttdgt) outprintln(lttdgt+ receiver +ltbrgt) outprintln(address +ltbrgt) outprintln(city +ltbrgt) outprintln(state +ltbrgt) outprintln(zipcode + lt b rx td x trgt ) outprintln(lttrgt) outprintln( lttdgtTel lttdgt) outprintln(lttdgt+ phone +lttdxtrgt) outprintln(lttrgt) outprintln( lttdgtItems lttdgt)

BookDetails book = nullShoppingCartltem bookAndQuantity = nullEnumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

double total = 00

while (itemshasMoreElements()) bookAndQuantity = (ShoppingCartItem)itemsnextElement()

total += bookAndQuantitygetItem()getPrice() bookAndQuantitygetQuantityO

book = bookAndQuantitygetltem()

87

outprintln(lttdgtTitle+ bookgetTitle() + Qty + bookAndQuantitygetQuantity() + ltbrgt)

outprintln(Price + bookgetPrice() + Subtotal + bookAndQuantitygetQuantityO bookgetPrice() +ltbrgt)

outprintln(Total + total )outprintln(lttdxtrgt)outprintln(lttablegt)outflush()outclose()

7 DeleteFromShoppingCartjava

ltpgt DeleteFromShoppingCart is the servlet that process the action of deleting item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javautil import javaxservlet imp ort j avax servlet http

public class DeleteFromShoppingCart extends HttpServlet

protected ShoppingCart m_cart protected BookDetails book

public void doPost(HttpServletRequest req FIttpServletResponse res) throws ServletException IOException res setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String[] params = reqgetParameterValues(isbnrsquo) String isbn = get isbn hidden fieldif (params = null)

isbn = params [0]

Systemoutprintlnfisbn = + isbn)

Get current session objectHttpSession session = reqgetSession()m_cart = (ShoppingCart)sessiongetValue(carf)

m_cartremove(isbn)

89

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lthtm lgtltheadxtitlegtAm azoncom Shopping

C artlt titlexheadgt)out pri ntln ( ltb ody bgcolor=FFFFFF link=003399

alink=FF9933 vlink=Yrsquo996633Y text=rdquo000000rdquogtrdquo)outprintln(lta nam e= top xmdashTop of Pagemdashx a gt ) ou tp rin tln (lt pxa href=httplocalhost8080checkouthtmlximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=Yrsquocccc99Yrsquo gt)ou tp rin tln (lt tdxbrx tdgt )out pri ntln ( lt td x b r x td gt )outprintln( lt td x b r x td gt )out println (rsquo1 lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=Y2Yxfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=YleftY valign=YtopYxfont

face=verdanaarialhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=Ycccc99Yrsquogt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantity()

outprintln(lttr bgcolor=FFFFFFgt) o u tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt)outprintln(ltbrgt + itemgetItem()getAuthor())

90

outprintln(ltbrgtQuantity + itemgetQuantityO)outprintln(ltbrgt)outprintln( lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=VPOST

action=7servletDeleteFromShoppingCartVgt)outprintln(ltpgt ltinput type=hidden name=isbn value= +

itemgetItem()getISBN())outprintln(ltpgt cinput type=submit name=ditem

value=Y rsquo deletegt rsquo rsquo)outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelvetica color=000000gt)

outprintln(ltNOBRxbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fo n tx b x N O B R x b rgt )

outprintin(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantityO + lt fo n tx b x N O B R x b rgt )

outprintln( ltfontgt) outprintln( lttdgt)

i

outprintln(lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)outprintln(ltfontxfontgt)outprintln( lt td x trgt ) outprintln(lttablegt)ou tp rin tln (lt pxa href=Yhttplocalhost8080checkouthtmlYximg

src=YdYJavaWebServer20servletsimageproceed-to-checkoutgifYxagt)outprintln(ltbodygt lthtmlgt)

outflushOoutcloseQ

91

8 Detailcontentjava

ltpgt DetailContent is the servlet responsible for generating detailed information page for a book The book is identified by its ISBN Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaio import javasql import jav ax servlet import javaxservlethttp

public class DetailContent extends FIttpServlet protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String isbn = reqgetPathInfo()isbn = isbnsubstring(l) skip over rsquo rsquo

92

try String sql = select from book where ISBN=rsquo + isbn +

Statement stmt = concreateStatement()ResultSet rs = stmtexecuteQuery(sql)

create header here CreateHeader(out)

create left menu here CreateLeftMenu(out)

outprintlnfctd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintlnfctd valign=top align=leftgt)

cellpadding=0gt)

outprintln(ltbrgt)

create detailcontent here while (rsnext())

String strlSBN = rsgetObject(ISBN)toString() outprintln(lttable width=100 border=0 cellspacing=0

+ltbgtlttdxtrgt)

+ lt tdx trgt)

outprintln(lttrgt lttd colspan=3 align=leftxbgt) outprintln( rsgetObject(Title)toString()

outprin tln(lt trxtd colspan=3 align= leftxbgt by ltbgt) out println( rs getObj ec t( Author) toS tringQ

cellpadding=0gt)

outprin tln(lt trx td x i m g src=xtdgt) outprintln( lttd valign=topgt) outprintln( lttable border=0 cellspacing=0

outprintln( lt t r x td valign=topxbgtPrice )outprintln(

rsgetObject(Price)toString() + lt b x td x trgt ) outprintln(

lt trx td x b gt A v ailab ility lt b gt U su a lly lt td x trx b rgt )outprintln( lt t r x td vlign=topgtships within 24

hou rs lt td x trgt )outprintln( lt tab lextdgt)

93

outprintln( lttd align=rightgt) outprintln( lttable border=0 cellspacing=0

cellpadding=0gt)outprintln( lt trx td gt )outprintln( ltform

method=POST action=httplocalhost8080servletAddToShoppingCartgt)outprintln( ltinput

type=hidden name=isbn value= + strlSBN +outprintln( cinput

type=submit value=Add to cart )outprintln( lt tdx trgt )

outprintln( lt tab lex tdgt ) outprintln(rdquolttrgt)outprintln(lttrgt lttd clospan=3 align=leftgt ISBN ) outprintln( strlSBN +lttdxtrgt)outprintln(lttrgt lttd clospan=3 align=leftgt) outprintln( rsgetObject(Publisher)toString()

+rsgetObject(PublicationDate)toString() + lt tdx trgt )outprintln(lttablegt)outprintln(ltbrgt)outprintln(ltbrgt)

output reviewString review = rsgetObject(BookReview)toString() if (review = null)

review =DJavaWebServer20servletsreview + review

outprintln(ltbgtReviewsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(review))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprin tin (thisLine) ou t println( ltpgt)

)

icatch (IOException e)

need do something here eprintstackTrace ()

94

outprintln(ltbrgt)String comment =

rsgetObject(BookComment)toString()if (comment = null) comment = DJavaWebServer20servletscomment +

commentoutprintln(ltbgtReader Commentsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(comment))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprintln(thisLine) outprintln(ltpgt)

catch (IOException e)

need do something here eprintstackTrace ()

ou t pri ntln ( ltb rgt)

catch (SQLException e)

need to do something here

add table end tab outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt)

95

ou t pri ntln ( lthe adgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=YTOO cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d J avaW eb S erver 2 Opublic_htmlflo wer gif gtlttdgt) outprintln(lttd width=30gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyBookStorecomltigtlth2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln( lttd width=20gtlttdgt) out pri ntln ( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-1 gt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

96

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsptampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out prin tin ( ltcen tergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

eellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=Yhttplocalhost8080Avelcom eshtm lgtHom eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-1gt)

97

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=http7localhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref-httpIocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lVgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

98

9 EchoServlettagjava

import javaio import j avasql import javaxservlet import javaxservlethttp

public class EchoServletTag extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintStackTrace ()catch (SQLException e)

eprintStackTrace()

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

try Statement stmt = concreateStatementQResultSet rs = stmtexecuteQuery(select from book where title

like rsquoProgrammingrsquo)int count = 1outprintln(ltdlgt)while (rsnext() ampamp count lt 6)

outprintln(ltdtxbgt + count + )

99

String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn + outprintln(rsgetObject(Title)toString() + lt ax bgt ) outprintln(ltddxnobrgtltfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltbrgt + rs getObject( Author) toStringO) outprintln( + rsgetObject(Publisher)toStringO +

+ rsgetObject(PublicationDate)toStringO)outprintIn(ltbrgt Our Price +

rsgetObject(Price)-toStringO)

out println( lt b rx b rgt ) count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()outprintln(lttdgt lttrgt) outprintln(lttablegt) outflush() outcloseO

ii

100

10 ISBNProcessjava

ltpgt ISBNProcess This is the servlet that process the ISBN-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javax servlet import javaxservlethttp import javaio import j a vasql

public class ISBNProcess extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forN ame( sun j dbc odbc J dbcOdbcDri ver)con = DriverManagergetConnection(j dbc odbc fxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s s e tC on te n tTy pe ( tex th tm l)PrintWriter out = resgetWriter()

String[] values

String alSBN =

values = reqgetParameterValues(isbn) if (values = null)

alSBN = values [0]

String sqlStmt = select from BOOK where ISBN= + alSBN

ResultSet rs = null int count = 0

create header here bullCreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject( IS BN) toStringO

outprintln(lta href=servletDetailContent + isbn+ gt)

outprintln(rsgetObject(Title)toStringO +lt ax bgt )

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toStringO)

outprintln( +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

102

outprintln(ltbrgt Our Price +rsgetObject(rdquoPrice) toStringO)

outprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width= 100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d Uava WebS erver2 Opubhc_htmlflo wer gif gtlttdgt) outprintln(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS tore com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt)

103

out println( lttdgt) outprintln(lttd w id th= 20x tdgt ) out pri ntln( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)out pri ntln (lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) out pri ntln ( lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsp1ampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out println( ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

104

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 eellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Books lt fontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocaihost8080servletReqCollectcategorygtCategoryltfontxaxtdgt lttr gt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

105

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lttablegtltpgt)

o u t println( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

ii

106

11 PublisherDataProcessjava

ltpgt AuthorProcess This is the servlet that process the PublisherampDate-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql

public class PublisherDateProcess extends FIttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbc odbc JdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentT ype ( texthtml)PrintWriter out = resgetWriterQ

String[] valuesString namel =

107

values = reqgetParameterValues(publisher) if (values = null)

nam el = values [0]

String name2 =values = reqgetParameterValues(rdquopublication_date) if (values = null)

name2 = values [0]

String sqlStmt =sqlStmt = select from BOOK where publisher=rsquo + namel + rsquoand

publicationdate=rsquo +name2

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprin tln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toStringO outprintln(lta href=servletDetailContent + isbn

+ gt)outprintln(rsgetObject(Title)toString() + (

lt ax bgt )

108

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rs getObj ect( Author) toS tring())

outprintln(V +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

outprintln(ltbrgt Our Price +rsgetObject( Price) toStringO)

outprintln( lt b rx b rgt )

if (count == 0) (outprintln(ltdtgt No matched data found)

outprintln(rdquoltdlgt) end Glossary List

catch (SQLException e) ( create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 celipadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt)

109

outprintln(ltIMG border=0 hspace=0 id=IM Gl src=dJavaW ebServer20public_htmlflowergifxtdgt)

outprintln(lttd width=3 0 x td gt ) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS to re com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ctable w idths 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt) outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) ou t println( ltcentergt)

no

outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaim er^A gt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) out pri ntln ( lthtml gt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-1 gtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=V-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-1gt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

I l l

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitleYrsquogt T itle lt fo n tx a x td gt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(nltahref=Yhttplocalhost8080servletReqCollectisbnY gtISBNltaxfontxtdgt lttrgt)

outprindn(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdana arial helvetica size=Y -1 gt)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYgtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

1 12

12 ReqCollectjava

ltpgt This is a servlet responsible for generating search request collection page It read extra path information from URL and then according to the extra path information it generates corresponding page format Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001import javaxservlet import javaxservlethttp import javautil import javaio

public class ReqCollect extends HttpServlet

protected final String CATEGORY = categoryrdquo protected final String AUTHOR = author protected final String TITLE = titlerdquo protected final String ISBN = isbnprotected final String PUBLISHER_DATE = publisher_date

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentType( texthtml)PrintWriter out = resgetWriter()

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

)else

Create standard header CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

path = pathsubstring(l) if (pathequalsIgnoreCase(CATEGORY))

I I Create category request collect

outprintln(ltpgt)outprintln(lth3xstronggtProgrammingltstronggtlth3gt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc01gtAlgorithmsltagt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc02gtCampC++ltagt)outprintln( Delphi) outprintln(lta

href=httplocalhost8080servletCategoryProcessc03gtJavaltagt)outprintln( MFC Perl)

outprintln(software Design UML Visual Basic More)

outprintln(lth3xstronggtW eb Developm entltstrongxh3gt) outprintln(ASP Commercem Cyberculture HTML

JavaScript)

outprintln(Security Web Design XML more)

outprintln(lth3xstronggtGraphics amp Softwareltstrongxh3gt) outprintln(Asobe CAD Desktop Publishing Graphics)

outprintln(Microsoft More)

outprintln(lth3xstronggtNetW orking amp O Sltstrongxh3gt) outprintln(Linux Macs Oracle PCs SAp R3 SQL)

outprintln(TCPIP Unix WindowsampDOS W indowsNT)

out println( More)

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

1 14

outprintln(ltfont color-CC6600 face=verdana arial helvetic a size=+1 gtltbgtEnter Authorltbgtltfontgt)

outprintln(ltbrgt You can enter authorrsquos full name firstname or last nameltpgt)

outprintln(ltform method=POST action=httplocalhost 8080servletAuthorProcessY id=form 1 name=form 1 gt)

outprintln( lttable border=0gt) outprintln(lttrgt lttd valign=middle

ahgn= leftx ttx b gt A u th o rlt b gt lt ttx td gt )outprintln(lttd valign=middle align= leftx input

type=YtextY name=author size=40 value=YYxtdgt)outprintln(lttrgt)outprintln(lttrgt lttd colspan=2gt ltfont size=-lgt) outprintln(ltcentergt ltinput type=radio

name=Yauthor_modeY value=YexactY checkedgt Exact Name)outprintln(ltinput type=radio name=author_mode

value=lastgtLast First Name (or Initial))outprintln(ltcentergt) outprintln(ltfontgt) outprintln(lttdgt lttrgt)outprintln(lttrgt lttd colspan=2gt ltpgt ltbrgt lttdgt lttrgt)outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search NowY

id=submitl name=submitlgt)outprintln(cinput type=reset value=YClear Form

id=resetl nam e= rese tlxpgt )outprintln(ltcentergt ltformgt)

else if (pathequalsIgnoreCase(TITLE))

Create title request collect

outprintln(ltfont color=CC6600 face=verdanaarialhelvetica s ize= + lxbgt E n ter T itlelt bxfontgt)lsquo

outprintln(ltbrgtYou can enter the exact title or part oftitleltPgt)

outprintln(ltform method=YPOSTY action=Yhttplocalhost8080servletTitleProcessY id=form l name=formlgt)

outprintln(lttable border=0gt) outprintln(lt trxtd valign=middle

a lig n = le ftx ttx b gt T itle lt b x t tx td gt )

115

outprintln(lttd valign=middle align= leftx input type=text name=title size=40 value=xtdgt)

outprintln(lttrgt) outprintln(lttrgt) outprintln( lttd colspan=2gt) outprintln( ltfont size=-lgt) outprintln( ltcentergt)outprintln( ltinput type=radio name=title-mode

outprintln(value=exact checkedgt) outprintln( Exact Title)outprintln( ltinput type=radio name=title-mode

outprintln( value=titlewords gt ) outprintln( Title Words )outprintln(ltcentergt ltfontgt lttdgt lttrgt)outprin tln(lt trxtd c o ls p a n = 2 x p x b r x td x tr gt ) outprintln(lttablegt)

outprintln(ltcentergt)outprintln( ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln( ltinput type=reset value=Clear Form

id=resetl nam e= resetlxP gt )outprintln(ltcentergt) ou t println ( ltformgt)

outprintln(lthr noshade size=lgt)

outprintln(ltBgtExamplesltBgt)outprintln(ltULgt)outprintln(ltLIgtEntering ltbgtampquotJava Servlet

Programmingampquotltbgt in the title field )outprintln(and choosing ltemgtExact Titleltemgt finds the

book without also finding the many books)

outprintln(ltLIgtEntering ltbgtampquotJavaampquotltbgt in the Title field and choosing ltemgtTitle Wordsltemgt)

outprintln( finds all books whose title are related toltigtJavaltigt)

outprintln(ltULgt)

out printl n( lttdgtlttrgt) outprintln(lttablegt)

ielse if (pathequalsIgnoreCase(ISBN))

Create isbn request collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n ter ISBN ltbxfontgt)outprintln(ltbrgt) outprintln(ltform method=POSTY

action=httplocalhost8080servletISBNProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

a lig n = le ftx ttx b gt IS B N lt b x t tx td gt ) outprintln(lttd valign=middle a lign= leftx input

type=text name=isbn size=40 value=xtdgt)outprintln(lttrgt)

outprin tln(lt trxtd c o ls p a n = 2 x p x b rx td x trgt ) outprintln(lttablegt)

out println( ltcentergt)outprintln(ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln(ltinput type=reset value=Clear

FormV id=resetl nam e= resetlxP gt )outprintln(ltcentergt)outprintln(ltformgt)

outprintln(lthr noshade size=lgt)

outpiintln(ltULgtrdquo)outprintln(lttdxtrgt)outprintln(lttablegt)

else if (pathequalsIgnoreCase(PUBLISHER_DATE))

Create publisher date collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n te r Publisher and Publication D ate ltb gtltfontgt)

1 17

outprintln( ltbrgt) outprintln(ltform method=POST

action=httplocalhost8080servletPublisherDateProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

align=leftgtlt ttxbgt P ub lisher lt b x t t x t d gt )outprintln(lttd valign=middle align= leftx input

type=text name=publisher size=40 value=xtdgt)outprintln(lttrgt) outprintln(lttrgt lttd valign=middle

a lign= leftx ttxbgt P ub lica tion D a te lt b x ttx td gt )outprintln(lttd valign=middle align= leftx input

type=text name=publication_date size=40 value=xtdgt)outprintln(lttrgt)outprintln( c t r x td c o l s p a n = 2 x p x b r x td x t r gt )outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search Now

id=submitl name=submitlgt)outprintln(ltinput type=reset value=VClear FormYrsquo

id=resetl nam e= resetlxpgt )outprintln(ltcentergt) outprintln(ltformgt) outprintln(lthr noshade size=lgt)

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush()outclose()

)

protected void CreateHeader(PrintWriter out) outprintln(lthtmigt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding bgcolor=EEEECCgt)

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20pubiic_htmlflowergifgtlttdgt) outprindn(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(lt s tro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x stro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt)outprintln(lttd w idth=20xtdgt) ou t println ( rsquo lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

out pri ntln ( ltfon tgt) outpri ntln( ltcentergt ) out pri ntln ( ltpgt) outprintln(ltcentergt) outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)out pri ntln ( ltf on tgt) outprintln(irltcentergt) out println ( ltbodygt) out pri ntln( lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

cellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=YT00 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE= -lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

1 gtS earch B ookslt fontx stronggt)outprintln(lttdgt lttrgt)out pri ntln (lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=l-lgt)

outpri ntln(ltahref=httplocalhost8080servletReqCoilectauthorgtA uthorltfontxaxtdgtlttrgt)

120

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprindn(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=V-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln(lttablexpgt)outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

121

13 ShoppingCartjava

ltpgt This is the definition for ShoppingCart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import Javautil

public class ShoppingCart Hashtable items = null int numberOfltems = 0

public ShoppingCart() items = new Hashtable()

add BookDetails to cart param bookID isbn param book book need to be added to cart copyreturn void

public void add(String bookld BookDetails book) if(itemscontainsKey(bookId))

ShoppingCartltem scitem = (ShoppingCartltem)itemsget(bookld) scitemincrementQuantity ()

else ShoppingCartltem newltem = new ShoppingCartltem(book) itemsput(bookId newltem)

numberOftems++

param bookld isbn

public void remove(String bookld) if(itemscontainsKey(bookd))

items remove (bookld) numberOfltems - -

public Enumeration getltems() return itemselements()

protected void finalize() throws Throwable items clear()

public int getNumberOfItems() return numberOfltems

public void clear() items clear() numberOfltems = 0

123

14 ShoppingCartltemjava

ltpgt This is the definition for the shoppingcart item Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class ShoppingCartltem BookDetails item int quantity

public ShoppingCartItem(BookDetails anltem) this item = anltem this quantity = 1

public void decrementQuantity() if (quantity gt 0)

quantitymdash

public void incrementQuantity() thisquantity++

i

public BookDetails getltem() return thisitem

public int getQuantity() ( return thisquantity

i

124

15 StandardFooterjava

package servlets

import j avax servlet

ltpgt This is a server side include servlet that will format the TinyBookStore HTML footer

public class StandardFooter extends GenericServlet

ltpgtPerform the servlet service

param req The request from the client param res The response from the servlet public void service (ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the response javaioPrintW riter out = new

javaioPrintWriter(resgetOutputStream())

Format the standard footeroutprintln(ctable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(rdquoltfont s iz e = - lx a href=topgtTop of

P agelt ax fon tgt )outprintln(lttrgt) out println( lttablegt) outprintln(ltcentergt) outprintln(rsquoltfont size=-lgt)outprintln(lta href=7welcomeshtmlYgtTinybookstorecom

Homeltagt ampnbsplampnbsp)outprintln(lta href=categoryhtmlgtCategoryltagt

ampnbsplampnbsp)outprintln(lta href-authorhtmlgtAuthorltagt

ampnbsplampnbsp)outprintln(lta href=titlehtmlrdquogtTitleltagt ampnbsplampnbsp)

125

outprintln(lta href=isbnhtmlgtISBNltagt ampnbsplampnbsp) outprintln(lta href=7publisherhtmlgtPublisheramp44

Dateltagt)outprintln(ltpgt)outprintln(ltfontgt)ou t println ( ltcen tergt)outprintln(ltpgt)out println (ltcentergt )outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and

disclaim er^A gt ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln( ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

outflush()outclose()

126

16 StandardHeaderjava

package servlets

import javaxservlet

ltpgt This is a server side include servlet that will format the standard TinyBookStore HTML header The Title of the page will be set to the value of the title property

public class StandardHeader extends Generic Servlet

ltpgt Performs the servlet service param req The request from the client param res The response from the servlet

public void service(ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the responsejavaioPrintWriter out = new javaioPrintWriter(resgetOutputStream())

Get the title of the page Set to empty string if no title parameter was givenString titles[] = reqgetParameterValues(title)String title = if (titles = null)

if (titleslength gt 0) title = titles [0]

outprintln(lthtmlgt) outprintln(ltheadgt) outprintln(lttitlegt + title + lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=T00 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)

127

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src=dJavaWebS erver2 Opublic_htmlflower gi A gtlttdgt) out println(lttd width=3 O x td gt ) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyB ookStorecom ltigtlth2xstrongxtdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) out printl n ( lttd width=20gtlttdgt) out printl n( lttrgt) outprintln(lttablegt)

outflush()outclose()

128

17 TitleProcessjava

ltpgt TltleProcess This is the servlet that process the Tltle-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import j avax servlet import javaxservlethttp import javaio import j avasql

public class TitleProcess extends HttpServlet protected final String EXACT = exact protected final String OTFIERS = titleWords

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

129

String[] valuesString name =

values = reqgetParameterValues(title) if (values = null)

name = values [0]

String mode =values = reqgetParameterValues(title_mode) if (values = null)

mode = values [0]

String sqlStmt =if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where title=rdquo + name +else

sqlStmt = select from BOOK where title like rsquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString()

130

outprintln(lta href=servletDetailContent + isbn+

outprintln(rsgetObject(Title)toString() +ltagtltbgt)

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toString())

outprintln( +rsgetObject(Publisher)toString() + + rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +rsgetObject(Price)toString())

outprintln(ltbrxbrgt)i

if (count == 0) outprintln(ltdtgt No matched data found)

ioutprintln(ltdlgt) II end Glossary List

catch (SQLException e) i create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

131

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=EEEECCgt)

outprintln(rdquolttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaW ebServer20public_htmlflowergifxtdgt) outprintln(lttd w idth=30xtdgt) outprintln(rdquolttd align=left valign=center width=300gt)

outprintln(ltstronggtlth2gtltigtTinyBookStorecomltixh2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(rdquolttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln( lttrgt)outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(rdquolta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(rdquoltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

132

out println( ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) outprintln( ltcentergt) outprin tln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disciaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) S y s te m out println( LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt )

outprintln(lttable width= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y- lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost 8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

133

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lt tab lex pgt )

ou t pri ntl n ( lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

134

18 checkouthtml

lthtmlgtltheadgt lttitlegtCustomer Informationlttitlegt ltheadgtltbodygt

lt hlgt ltcentergt ltbgt Customer Information ltbgt ltcentergt lt hlgt

ltform method=POST action=httplocalhost8080servletCustomerInfoProcessgt lttable border=0gt

lttrgtlttd align=rightgtFirst namelttdgtlttd colspan=2 align= leftx input type=text name=firstname size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtMiddle initiallttdgtlttd colspan=2 align= leftx input type-text name=middleinit s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtLast namelttdgtlttd colspan=2 align= leftx input type-text name=lastname size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtEmail addresslttdgtlttd colspan=2 align= leftx input type=text name=email s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgt Account pass word lttdgtlttd colspan=2 align= leftx input type=text name=password s ize= 40x tdgt

lttrgtlttrgt

lthrgtlttrgt

lttablegtltbrgt

ctable border=0gtlttrgt

lttd align=rightgtCredit card numberlttdgtlttd colspan=2 align= leftx input type=text name=creditcard s ize= 40x tdgt

lttrgtlttr valign=topgt

135

lttd align=rightgtCredit card typelttdgtlttd align=leftgtltinput type=radio name=cardtype value=visagtVisaltbrgtltinput type=radio name=cardtype value= mastercard gtMasterCardltbrgt lttdgtlttd align=leftgtltinput type=radio name=cardtype value=bluebirdgtBluebirdltbrgtltinput type=radio name=cardtype value=fishergtFisherltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtCredit card holderlttdgtlttd colspan=2 a lign= leftx input type=text name=cardholder s ize= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCredit card expire date (mmddyy)lttdgtlttd colspan=2 align= leftx inpu t type=text name=expiredate size= 40x tdgt

lttrgtlt trx trgtlt trx trgtlttr valign=topgt

lttd align=rightgtSelect shipping methodlttdgtlttd align=leftgtltinput type=radio name=shipping value=upsgtUPSltbrgtltinput type=radio name=shipping value=expressgtExpressltbrgtlttdgtlttd align=leftgtcinput type=radio name=shipping value=normalgtNormalltbrgtltinput type=radio name=shipping value=abnormalgtAbnormalltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtReceiver Namelttdgtlttd col span=2 a lign= leftx inpu t type=text name=receiver size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtAddresslttdgtlttd colspan=2 align= leftx input type=text name=address size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCitylttdgtlttd colspan=2 align= leftx inpu t type=text name=city size= 4 0 x td gt

lttrgtlttrgt

136

lttd align=rightgtStatelttdgtlttd colspan=2 align= leftx inpu t type=text name=state s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtZipcodelttdgtlttd colspan=2 align= leftx inpu t type=text name=zipcode size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtPhonelttdgtlttd colspan=2 align= leftx input type=text name=phone size= 40x tdgt

lttrgtlttablegtlt b rx b rgtcinput type=submit value=Process name=actiongt

ltformgt

ltbodygtlthtmlgt

137

APPENDIX C

Screen Display of the Test

138

mmm File Edit View Favorites T o d s Help

^ Jit j j ^ LJ U 3) ~ pound=J _Am Back - S top Refresh Home j Search Favorites History Mait Print Edit

Links gtgt Address |4S ] httDVIocalhost808QAvdcorne shtml

TinyBookStore com

Welcome to the TJnyBoakStoro com

F i v e H o t B o o k s

1 T h e C + + Programming LanguageU s u a l l y s h i p s i n 24 h o u r s

B j a r n e S t r o u s t r u p A d d i s o n - W e s l e y Pub Co 1997 Our P r i c e 31 47

2 - P r o g r a m m i n g V i s u a l C + +U s u a l l y s h i p s i n 24 h ou r I I

Local intranet

Search BooksHorne

Category

Author

Title

ISBNPublisherDate

3 iigt60

3 1 S earch T inybooksloiecom - Microsoft Internet Explorer

139

T inyB ookStorecom - Microsoft Internet Explorer

j File Edit View Favorites lo o k Help

q a a H 3 1 d B ack S top R efresh Home S earch Favorite History j M aJ Print

Links gtgt A ddress httpV localhost 308QoryleV PetailCorterV 020i8SC l4

MM

Edit

Search Books

Home

Category

Author

Title

ISBN

PublisherDate

TinyBookStore com

The C++ Programming Languageby B j a r n e S t r o u s t r u p

0

ISBN 0 2 0 1 8 8 9 5 4 4 A d d i s o n - W e s 1e y P ub Co 199 7

Reviews

P r i c e 31 47A v a i 1ab i 1i t y U s u a l 1 ys h i p s w i t h i n 24h o u r s

Aic t o c a r t

ijgJ Local intranet

140

^ | I myBook5torecom Shopping Cart - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

[v] I ^ -J JB ack - Stop R efresh Home S earch Favorites History lsquo Mail Print

Links A ddress 0 1 h ttp localhost8080servetA ddT oShoppingCart ~3 ltGdeg

Shopping Cart Item s Price

The C++ Programmi ng LanguageB j a r n e S t r o u s t r u p Q u a n t i 1 7 1

Price $ 3 1 4 7 Subtotal $ 3 1 4 7

d e l e t e

Total 31 47

Customer Information Microsoft Internet Explorer

File Edit View Favorites lo o ls Help bull _

bullgt 3i 4 n j j d a 31Back ~-j Stop- R efresh Home S earch Favorites History j Mail Print Edit

Link gtgt j Address ] j j h ttplocalhost SOSOcheekoot html

EMH1

~3

Customer Information

First name jFang

Middle initial |a

Last name Xiao

Email address fxiaomitecnet

Account password pooooc

0 1 Done

Credit card number 1234567891234567

Credit card type VisaC MasterCard

C Bluebir d C Fisher

Credit card holder jr ong Xiao

ard expire date (mmddyy) J010102

Select shipping method UPSO Express

O Normal C Abnormal

J |sect Local intranet

141

lt2] Order List - Microsoft Internet ExplorerFile |d i t View Fayotites lo o t Help

^ 3 ^ S i l S - j S tep R efresh Home Search Favorite History Mail Print h-

HFte-LLinks A ddress I g ] httplocalhost8030servletCustemeilrifoProcess 3 ^Go

Your order reads as followsE - M a i l A d d r e s s f x i a o

F a n g X i a o

ship to

T e l

11 e m s

pound] Pc

10821 W e s t e r n P l a z aOmahaME6 8 1 5 4

( 4 0 2 ) 4 9 6 - 7 5 7 0T i t l e T h e C++ P r o g r a m m i n g L a n g u a g e Q t y 1 P r i c e 31 47 S u b t o t a l 31 47

| a [ Local intianet rsquo

l i

T inyB ookSloiecom - Microsoft Internet Explorer

T 7 ~ J iii 4 a i t Vi 1+ a Si

5 E

P r i te i+ A d d ie r I ig l httplocalhot8080ervletReqCollectauthor

S e a r c h B o o k s

Horne

Ca t e g o r y

A u th o r

Title

ISBN

P ublishe r Date

jS 1 D one

TinyBookStore com

fc t i t e r l i t n o rYou can enter authors full name first name or last name

A u t h o r |sCOtt

O ExactName amp Last F irst Name (or Initial)

T itiv b o o k s to re c o m H o a e | C a te g o ry | A u th o r | T itle | ISBN | P u b lish e r D ate

C opyright and disclaim ercopy 1999-2001 F an g Xiao

T op o f P f

|sect g j Local intranet

142

linyBookStore^com- MiciosoFUnteinet ExplorerFite Edit View Favorites Tools Ftelp

IIl4 rsquojO IjjlI - 3 -Upraquo 8 a c k ltbullltbullbullltlaquo Stop R efresh Home S earch Favorites History Mail Print 1

| Links 1 Address j raquo 3 http7localhost8CI80servletAuthorProcess

l - i f l |x |

S e a r c h B o o k s

Home

C a t e g o r y

Ti t le

ISBN

P ublishe r D a te

D o n e-

TinyB o okStore com

1- Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

I G aleampory I A utho t | I jt te | ISBN | PubH shei^D atg

i t and disclaim erreg 1999-2001 F ang Xiao

Top of

l i Local intranet

j T iny8ookStorecom - M icrosoft Internet Explorer

Fite Edit View Favorites Tools Help

4- 5 ni M m ~ltpound C r =gt 2f|L i p | | | | | iAdiiill|^Thttp7localhost8080seivletD etailContent0201924889

U 3

S e a r c h B o o k s

H ome

C a t e g o r y

A u th o r

Title

ISBN

P u b lish e r P a te

TinyB o okStore com

Effective C++b y Scott Meyers

ISBN 0201924889 Addison-Wesley Pub Co 1995

R eviews

This is the review of Effective C++

R eader Comments

Price 3795 Availability U sually ships within 24 hours

Add to iosil

IIH LdcSiiihttahdt

143

l inyBookStorecom Shopping Cart - Microsoft Internet Explorer

4- -- _ t lS M JJ ltpound I 7 r mdash2--I or- Stop R efiesh Home S ea rch Favorites History Wait PrintBach

Links Y 1^ddtessj-^1 httDvVlocalliostiBOBOyservletMddToShoppinqCart 73 ^

0

Shopping Cart Item s

Effective C + +Scott Meyers Quantity 1

0 1 Done

delete

Price

Price $ 3 7 9 5 Su b to ta l $ 3 7 9 5

Total 3 7 9 5

IB~ht Locai intranet

bull 3 TinyBooKGIoFooom M icrosoft Internet Cxplorcr

Fite Edit View Favorites Tools Help

4- -4gt Lfl 4 r amp J J lt$ i icirsquo s J ~lAB ack Ti(^poundprV aTdV iS^Stop-T SfSjefre^ptr I i - M t s s j r y rvlih- i JPopSnr -JE

i i i l l l P I I I ^ I i l l ] httplocalhost8080servletR eqC ollectauthor

G3SJ

7 ^ Go

S e a r c h B o o k s

H om e

C a t e g o ry

A u th o r

Title

ISBN

Eytoiisiier Date

101 D one

T i n y B o o k S t o r e c o m

E n te r AuthorYou can enter authors full name first narne or last name

A u t h o r jCraig Larmen

E Exact N ante O Last F irst N ame (or Initial)

Search Now 1 Clear Form

I C ategory | A u th o r | j j t l s | ISBN |

C opyright and ctiiclali[er copy 1999-2001 F an g Xiao

T o p o fP ag e

^tDpcafihttangfe-

144

gj TinyBbokSlorecom - Microsoft Internet ExplorerFile Edit View F a v o n te s - Pools

4-1 4 gt_poundj Q Jl3S top R efresh Home S ea rch Favorites History Mail PrintCacl-

lsquo Unko A ddress j ig ] httplocalhostSOSCiservletAuthorProces 71

S e a r c h B o o k s

Home

C a t e o o r v

A u th o r

Tit le

ISBN

P ub l i she r D a t e

Titty Bo okStore com

1 Applying UM L and Pattern Usually ships in 24 hours Craig Larmen Prentice Hall 1997 Our Price 450

T im booksto re com Home | C ateg o ry | A u th o r | Title | I3BM | Publisher P a ts

C opyrigh t and disclaimer copy 1999-2001 F an g X iao IIg ] http7localhost 8080eopyright html Local intranet

7 j T inyBookStorecom - Microsoft Internet Explorer

^ 03 4 31 0 i -_r _j _T B ack ~j~ S top R efresh Hom e Search Favorites History Mail Print Edit

I Links Addiess AocalhcistiiiOciOserv-letCctailConfent0137488S07

u m m

S e a r c h B o o k s

HorneC a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r Date

Tiny Bo okStore com

Applying LOVIL and Patternby Craig Larmen

0 Price 450 Availability TJ sually ships within 24 hours

ISBN 013748880 Prentice Halil 997

R ev iew s

Tins is the review o f Applying UML and Pattern

R ea d er Com ments

Add to cart

01ll iPdSSIihirSdety

145

3 TinyBookStorecom Shopping Cart bull Microsoft internet ExplorerFile Edit View Favorites Tools Help

vJBeck

JStop Refresh

4Home

H Si - iS- -=dSearch Favorites History Mail Pnnt

Links rdquo Address jlti] httpVlocalhostBOSOservletAddToShoppingCart 3 ^ Gc

r o 1

Shopping Cirt J toms Price

A pplying UML and PatternCraig Larmen Quantity 1 Effective C++Scott Meyers Quantity 1

l i l le t e

delete

Price $ 4 5 0 Subtotal $45 0

Price $ 3 7 9 5 Subtotal $ 3 7 9 5

Total 82 95

d f g a j Local intranet

146

lt3 TinyBookStoiecom - Microsoft Internet ExplorerFile Edit View Favorites Io o ls Help

gt j i 4 a - a i [j JB ack Forward Stop Refresh Home S earch Favorites Histeiy Mail Print Edit

Links Address ] pound ] hiipVonahost803CeerveirsquoReqColectlsquoauthor

0 1 i

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r D a te

Tiny Bo okStore com

You can enter authors full name first name or last name

A u t h o r jJeff

O Exact N ame Last First N ame (or Initial)

Search Now i Clear Form

T inybookstorecotti H oinf | Category | A trthor | Title j ISBN | Publisher Date

Copyright and disclaimer copy 1999-2001 Fang Xiao

Top of Page

M Local intraZl

m TinyBook Stote com - Microsoft Internet Explorer

Fife Edit View Favorites Joo ls Help

ISregBack Stop Refresh Home S earch Favorites History Marl Print c

Lirrks Address samp] httplocalhost8080servletAuthorProcess ~z ^ Gc

S e a r c h B o o k s

H ome

CategoryA u th o r

Title

ISBN

P u b lishe r D a te

i M

TinyBookStore com

1 Progi aimning Windows bullwith M FC Usually slaps in 24 hours JeffProsise Microsoft P ress 1999 Our Price 4799

jnybo-okstorscom Homo | Category | A u th or | Title | ISBN | Publisher P a h

C opyright and disclaijRief copy 1999-liOO1 FangX iao

Loccii intranet

147

148

m I myUookSlorecom - Microsoft Internet ExplorerFile- pound d it View Favorite T ools Help

^ J ] 4 U J j j =jgt Stop R efresh Home S e a rc h Favorites History i Mail Print EditBack

Links AddressilaquojigThttplocalhost5 i380ser4eM D etailContent157231 pound350

rfgKxi

ldquo3 gt6deg

S e a r c h B o o k s

HorneC a teg o ry

A u th o r

Ti tle

ISBN

P ub l i she r D a t e

TinyBookStorecom

Programming Windows with M FCby JeffProsise

0

ISB N 1572316950 Micro s oft Pre s s 19 9 9

Price 4799 Availability Usually ships within 24 hours

R e N ew s

This is the review of Programming Windows with MFC

R eader Comments

A dd to cart

D one i jh j Local intranet

lt 3 TjryBook S tore com Shop p in g Cart - M icrosoft Internet Exolorer

File Edit View f a nute T ools Help

r 1B ack

J 3 Q 0J amp poundlr - Jlilip isS h lA ld rS s httpy |ocalhost8U 80AervletA ddToShoppingCait TSIIlli

Shopping Cart Item s

Program m ing W indow s w ith M F CJeffProsise Quantity 1A pplying UML a n d PatternCraig Larmen Quantity 1 E ffective C++Scott Meyers Quantity 1

d e le te

d elete

d elete

Price

Price $ 4 7 9 9 S u b to ta l $ 4 7 9 9

P rice $ 4 5 0 S u b to ta l $ 4 5 0

Price $ 3 7 9 5 S u b to ta l $ 3 7 9 5

Total 1 3 0 9 4

^ h W h e iM

S s i Local intranet

149

File Edit View Favorites lo o ls Help n4- -0 iS - M L U

Back Stop Refresh Home Search FavoritesJ

History I3 H H H B H H H BMail Pm Edit

Links rdquo Addrecs |s] hHplocalhogt5t8080servletReqCollectcategorii ^_____ bulllt bullbull llilltllll

Search Books

Home

Category

Author

Title

ISBNPublisherDate

TinyBookStore com

P r o g r a m m in g

AI g o r i t Lins CampC++ D e l p h i J a v a MFC P e r l s o f t w a r e D e s i g n UML V i s u a l B a s i c M o r e

Done

Web D e v e lo p m e n t

ASP Commercem C y b e r c u l t u r e HTML J a v a S c r i p t S e c u r i t y Web D e s ig n XML more

G r a p h i c s amp S o f t w a r e

Asobe CAD D es k t op P u b l i s h i n g G r a p h i c s M i c r o s o f t More

I J J ig Local intranet

150

finvBookStorecom - Microsoil Internet Explorer - j g j x

j Fite Edit Jfiew Favorites lo o ts Help

bull j 5 a i B ack lsquolti S top Refresh Home S e a tc h Favorites History Mail Print Edit

Links 1 Address |ltg] hitpVocalhostl-i030seryletCateciofyPreceigtVc03 ^ | g

S e a r c h B o o k s

Home CategoQ

A u th o r

Title

ISBN

Publishe r D a te

TinyBookStore com

1 Core Ja v a 2 Usually ships in 24 hoursCay S Horstmaun Prentice Hall 1999 Our Price 2579

2 Ja v a S erv let Programm itig Usually ships in 24 hoursJason Hunter i O Reilly 1993 Our Price 1977

3 Ju st J a v a 2 Usually ships in 24 hoursPerter van der Linden Prentice Hall 1999 Our Price 3149

Tinybookstorecom Home | C ategory | A u th o r | T itle | IbBN | Publisher D ateloRoIEage

n g Local intranet

ta

151

41 Tinytfookbtorecom - Microsoft Internet ExplorerFile gdit y iew Favorites JLools Help

1 ^ hgt a a a amp a j ri i - 3 bull a Back Forward Stop Refresh Home S earch Favorites History Mart Print Edit

lisLinteslsii Address ji^]h ttp localhost8D 8o7serv letD etailC ontent0130319336

M i

3 f^Gc

S e a r c h B o o k s

Homec a t e g o r y

Tiny Bo okStore com

Core Java 2by Cay S Horstmaun

El

ISBN 0130819336 Prentice H alil999

Reviews

This is the review of Core Java

R eader Comments

Price 2579 Availability U sually ships within 24 hours

I Add to car

S ] Done S i Local intranet

TinyBookStorecom Shopping Cart - Microsoft Internet Explorerfel11 File Eefit View Favorite l o o k H e lp

tljH|V| 4 a 3 j 09 c T J

Stop Refresh Home S e a rc h Favorites History j Mail Print

jiiLihkIi87js ^ B ie s S ij^ ] http Z localhost8080servletiddT oShoppirigC art

B I B

3= i

Shopping Cart Item s

Core Java 2Cay S Horstmaun Quantity 1

Icopy

t i l

delete

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Total 2 5 7 9

sal Local intranet

152

a TinvBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites J o o lr Fjelp

NBack

amp Id b iStop Refresh Home

ISearch Favorifes History - Mail Print Edit

Links gty I Address [ jg l httplocalhost8080servletD etailContent156592391 x d

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

T i t le

IS B N

Publisher Date

ampJ Lrl e

Tiny Bo okStore com

J a v a S erv le t Piograitmmigby Jason Hunter

a Price 1977 Availability XT sually ships within 24 hours

ISBN 15659239 lx O Refflvl998

R e N ew s

In this brand-new third edition of Java Servlet Programming author Bjame Stroustrup the creator of Java presents the full specification for the Java language and standard library a spec that will soon become the joint ISOANSI Java standard

j ~2J Local intranetm

dH T iny8ook5torecom Shopping Cart - Microsoft Internet Explorer

File pound d t y iew Favorites Io o ls HelpB H

a $ a i a a -Stop Refresh Home S ea rch Favorites Hi lory Mjl

3- lsquonr I

| j | i | H | g i | i | i d ^ | | | | l Q httplocalhost80S0servletAddToShoppirigCart J P

m

Shopping Cart Item s

Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d e le te

d e le te

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Price $ 1 9 7 7 S y b to ta l $ 1 9 7 7

Total 4 5 5 6

I O I

aiil

153

Lustomer Information - Microsoft Internet Explorerpoundite pounddit View Favorites Xoo|s Help

v- _) _ l 4 J I VB ack - Stop R efresh Home Search Favorites History Mail

Links gty] A ddress ] j i l h ttD localhost8080checkouthtm l

F -iVj ~f

l l i l i i

C u sto m er In fo rm a tio n

First name jFang

Middle initial lA

Last name fXiao

Email address jfxiao m itecnet

Account password jxxxxx

Credit card number ]1234567B91234567

Credit card type C VisaC M asterCard

C Bluebird O Fisher

Credit card holder jFang Xiao

Credit card expire date (mmddyy) jo 10102

Select shipping method c u p sC Express

NormalAbnormal

0 ] D one Local intranet

poundpound Order List - Microsoft Internet Explorer

s

Back

Li il raquo

Yiew Favorites l o o h Help

bullV Y lJ j X I T- lty S to p Refresh H o m e

amp 1 3 J - jrS earch Favorite History lt Mail Print

fcesssaampl httplocalhost8080servletCustom erlnfoProcess

Y o u r ord er reads as fo llow sE-Mail Address 6daomitecnet

Fang Xiao

ship to

Tel

Items

12345 Western PlazaOmahaNE68154(402) 123-4567

Title C ore Java 2 Qty 1 Price2579 Subtotal 2579

Tide Java Servlet ProjammingQty 1 Pnce 1977Subtotal 1977 Total4556

ffl|b ] Done kl Local intranet

154

mammmm 1

File Edit View Favorites lo o ts tieip

E=cl i u F t l H -n e -i i rdquo F j-oiilsquoiBillHistory lsquo gt1 ll Print Edit

iiiiiiiiiiiiiiiiiirsquo Links Address j-copy] http localhust 8080servletReqCollectisbn J

TinyBookStore com

Search Books

Home ISBN

Author

Title

IS B N

S e a r c h Hew C le a r Form

PubnsheuDate

Top o f PageITnjrbooksj^ore^ com Horne I C a te g o rv | ^ i t h o r | T i t Ie I ISBN | Publisher Date

- g ] http locdlho-st SOSOwelcome shtrnl

TinvBookStorecom - Microsoft Internet Exploier

poundaj Local intranetId

| File Edit View Favorites Tools Help

i -e -e u u r5_ _ _ a u ^ 4 - a a j Back Forward S top Refresh Home S earch Favorites History Hail Print Edit

Links A d d re ss ^ hitp rsquoIdcanc-stEtnSOservlltlsquoF-aqZoll-~ntispn z raquo h

TinyB o okStore com

S e a r c h B o o k s

Horne

A utho r

T itle

ISBN

P u b lish e r P a t e

fcntar ISBN

I SB H 1565922840

|sectplli||pbw||l| IliM M pifiillj

T rgU onL cirrti -nr Kini- | Cgtgpound-gg | Agithor | Title | ISBN f uhhe-rt Pete

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top o f Pag e

aipoundbull] O o n e Local intranet

155

File Edit View Favorites Tools Help

HUTinyBookStorecom - MicrosoH InternetExplorer

B ad-J J A J d -2r =3

Stop R efresh Home S e a rc h Favorites History Mail Print

Links ygt A ddress j ^ ] httpVlocalhost8080servletrsquoISBM Process

S e a r c h B o o k s

Horne

C a t e g o r y

A u th o r

T itle

IS B N

Pub l i she r D a t e

TinyB o okStore com

1 Learning Perl Usually ships m 24 hours Randal L Schwartz O Reilly 1997 Our Price 1997

T in vh ooksto re c o m H orne | C at ego tv | A u th o r | Title | ISBM | Publisher D ate

C opy rig h t a n d d isclaim ercopy 1999-2001 F a n g X iao

0 ] Done

yen

ighj Local i

TinyB ookStoiecom - Microsoft Internet Explorer

Erie Edrt View Favorites- lo o ls Help

-s pound] 4 pound1 jLl icArdquo =pound 2 S top Refresh Home S earch Favorites History Marl Print Edit

iilHI

NpBack

httpyiocalhostSOBOservleMDetailContentAI 565922840 ~T] Cm

Tiny Bo okStore com

S e a r c h B o o k s

H o m e i

C a teg o ry

A u th o r

T itle

ISBN

Publishe r D a te

Learning Perlby Randal L Schwartz

I ^

ISBN 1565922840 O Reillvl997

Price 1997 Availability U sually ships within 24 hours

Reviews

This is the review of learning Perl

Reader Comments M0 ] Done lsquofR | Local intranet

156

IHHHHHI _ I f f i x |

File E d t yiew Favorites J o e ls H elp 11v- -__ l

Back ~ rc Stop R efresh Home S earch Favorites HistoryJ rMail

HH1111Pgtnt

Links A ddress | ] http7docalhost8030servleM AddToShoppingCart 3 tgt G o

O S III

Shopping Cart Item s

Learning PeriRandal L Schwartz Quantity 1

delete

Price

Price $ 1 9 9 7 Subtota l $ 1 9 9 7

Total 1 9 9 7

s

Done Local intranet

Eg W illi 1 lttMM41 i H H p n B n 1 0 1 x i

Fite Edit View Favorites Toots Help E H

1$3 L plusmn J8ack Forward Stop Refresh Home Search Favoutes

4History i

- i V -=JMail Print

-Edit

71 Address http7localhost8080lsquoservletFleqCollecVisbn I l f i l l l

TinyBookStore com

Search Books

Home

C ateao rv

Author

Title

ISBN

Publisher D a te

Enter ISSN

i s bit [l 565921496

Search Now I Clear Form

Tinybookstore o n Home | Category | A uthor | Titb | ISBN | Publisher Dte

Copyright arid disclaimer copy 1999-2001 Fang Xiao zl amp j Done Js J Local intranet I

157

H H H r f e i x i File Edit View Favorites Lools Help

- J j j j ] JBack Stop Fiefresh Home Search

J JFavorites-

-J i C rHistory Mail Print

111111811i n

r Links wj i Address |reg] http docalhost 8080servletIS8N Process

S ea rch B ooks

Home

Category-

rdquo A u th o r

T i t l e

IS B fi

P u b l i s h e r D a ta

Tiny Bo okStore com

1 Programtning Perl Usually ships in 24 hours Larry Wall O Reilly 1997 Our Price 2397

T o o k s t o r e c o m H P in e | C a t e g o r y | A u t h o r | Till | IS B N | P -ubtu-hai D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g X ia

T o p o f P a g e

zlamp2 Done Local intranet

158

lt3 l mytfookSlorecom - Microsoft Internet ExplorerF3e Edit View FavoMes lo o ts Help

Back3 U Si S rsquo IStop Refresh Home lt Search Favorites History Mail Print Edit

httplocalhost8080servletDetailContent15S5321496 j3

Search Books

Horns

Category

Author

Title

ISBN

Publisher Date

Done

TinyB o okStore com

Programming Perlby Larry Wall

0 Price 2397 Av ail ability U sually ships within 24 hours

ISBN 1565921496 O Reillyl997

Reviews

This is the review of Programming Perl

Reader Comments

Add to cart

l or=lM

159

Tm vBookSlorecom Shopping Cart - M icrosoft Internet Explorer

i Fite Edit View Favorites lo o k Help

^ Beck R efresh Home

ampS earch Favorites History j Mail Print

E Links I Address ] pound http localhost 8080servletA ddT oShoppingCart rsquo ] O rai

i O

Shopping Cart Jlems

Learning Peri Randal L Schwartz Quantity 1 Program m ing PeriLarry W all Quantity 1

delete

d e le te

Price

Price $ 1 9 9 7 S u b to ta l $ 1 9 9 7

Price $ 2 3 9 7 S u b to ta l $ 2 3 9 7

Total 4 3 9 4

3SJ Done j | s [ Local intranet

160

m m mmmHi mmmHHHHHi1 File Edit View Favorites Tools Help

^ - J J -ih Ji - j| B a d Forward Stop Refresh Home S earch FavoritesHIH ctuv Mjl Print

IHIlllliEd

B l

MbfeifcssfjP Address httplocalhost8080servletFleqCollectpLiblisher_date_ ___ ________ ___________ _ bull bull bull bull_________________ Zi T gt 6 o

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

Title

ISBN

Publishe r P a t e

S ] Done

TinyBo okStore com

T rsquov -

Publisher

sind IPpiIs1iclaquoifciori OsifiC

jAd cl i so n-VVe oI e y Fuo C o ~

P u b l i c a t i o n D a t e 1U97

Search Now Clear Form

T inybookstore com Home | C ategory j A u tho r j I itle | ISBN | Publisher Ds

C opyright and disclaimer copy 1999-2001 F an g Xiao

T op o f Page

g a l Local intranet

161

lt|j TinyBookStoiecom - Microsoft Internet Explorerlsquo Erie Edit View Favorites lo o ls Help

v-1 Q rij - 3 rsquo- a u -=pound Ci Back s lsquoi i 1 Stop Refresh Home S earch Favorites History Mail Print i

jL inks i A ddress 0 1 http7localhost8Q80servletPublisherDateProcess

EMM

3

S e a r c h B o o k s

Home

C a t e g o r y

Author Title

ISBN

Publisher D a te

TinyBookStore com

1- Algorithm s in C Usually ships in 24 hoursRobert Sedgewick Addison-Wesley Pub Co 1997 Our Price 4495

2 The C++ P rogr amming L anguage Usually ships in 24 hourBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

3 Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

4- U M L D istilled Usually ships in 24 horn sMartin Fowler Addison-Wesley Pub Co 1997 Our Price 2995

Done | s j L ocalm

TinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorites l o o k Help

Backamp 3 $ -Q 3 3 AJStop Refresh Home S earch Favorites History Mail Print Edit

Lipikkigt7i Ajddr$esjhttpv7localhost8080-servletDetailCoriterit0201314525

m

3 rgtGc

S earch B ooks

Horne

A uthor

Title

ISBN

Publisher D a te

Tiny BookStore com

Algorithms in Cby Robert Sedgewick

S

ISBN 0201314525 Addison-Wesley Pub Co 1995

Reviews

This is the review of Algorithms in C

Reader Comments

Price 4495 Availability U sually ships within 24 hours

Add to cart

0I reg S a i t^ s a l intranet

162

File Edit View Favorites lo o ls Help

2 ^ iVi ^ ^ t j j B ack gt Stop Refresh Home S ea rch Favorites History ||

- i -Mail Print

WB0BUBSSSI B ifl

Links ygt Addrese |isect ] httpvVlocalhostSOSChservletAddToShoppingCart

Shopping Cart Item s

A lgontfim s in CRobert Sedgewick Quantity 1

0 1 D one

delete-

Price

Price $ 4 4 9 5 Subtota l $ 4 4 9 5

Total 4 4 9 5

Local intranet

163

^ l inyBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

ls31

3 bullrsquo -I- _J _jj - j i_ 3 - j rdquo -= $ ABack Forward Stop Refresh Home Search Favorites History Mail Print Edit

Links rdquo Address 6 J http Vlocalhost SOSOAervletR eqCollectpublisher_date j ^G

Search B o o k s

Home

categoryAutho r

Title

IS B N

Publi sher D a te

TinyBookStore com

liter Publisher and Publication Date

P u b l i s h e r Wrox Press Inc

P u b l i c a t i o n D a t e ]1

Search Now j Clear Form

T invbookstor ecotnHomg | Category | A uthor | Title | ISBN | Pu b lish e rP a t

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top of Page

zD one Local infra

m TinyB ookStoiecom - Microsoft Internet Explorer

R e Edit View Favorites Tools Help

- -i 13 4 St 2J amp t r - JHB-1

fff ij if P S | Address |sjpound~| httpVlocalhost8030servletPublisherDateProcess

S e a r c h B o o k s

Home

C a t e g o r y

A utho r

T itle

ISBN

Publisher D a te

0 ] Done

TinyBookStore com

1 Beginning Visual Basic 6 Database Programming Usually ships in 24 hour John Connell W rox Press Inc 1998 Our Price 3199

2 Befmiung Visual Basic 6 Usually ships in 24 hours Peter Wright Wrox Press Inc 1998 Our Price 3199

T inybookstore com H orae | C ategory | A u thor | Title | ISBN | Publisher Date

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top o f Fas

Local intranet

64

| File Edit Yiew Favorites T ook Help

i A - + - - a S 3 rsquo reg - pound J -3 Back ldquo d Stop Refresh Home Search Favorites History

- vMail Print

i

Edit

IllplBlllll________ g - M

isisfcinbsijp Addre s | g ) httplocalhost8080servletDetailCoritent1861001061 3 Gdeg

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

T itle

ISBN

Publishe r D a te

TinyBookStore com

Beginning Visual Basic 6 Database Programmingby John Connell

a Price 3199 Availability U sually ships within 24 hours

ISBN 1861001061 Wrox Press Inc 1998

Reviews

This is the review of beginning Visual Basic 6 Database Programming

Reader Comments

A d d to c a n

S] pone Local intranet

m u i

lillllEHl ^ bdquo A 3 2tl 4 t M liJ i

Back Forward Stop Refresh Home Search Favorites3

History 4 _ r

M j 1J

Print EditiSillilillllS

httplocalhost8080servletReqCollecttitle

S e a r c h B o o k s

Home

C a t e g o r y

Author

Title

ISBN

Publisher Date

TinyB o okStore com

Enter TicleYou can enter the exact title or part of title

T i t l e C++

O Exact Title Title Words

Search Now Clear Form

Example

bull Entering Java Servlet Programming in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title are related to Java _li

165

lt5 TinyBookStorecom - Microsoft Internet ExplorerFite Edit View Favorites lo o ts Help

Back Stop Refresh Home S earch Favorites History Mail Print

Links gty Addiess http-localhost8080servlet7TitleProcess

i|p1

I

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

Publi sher IS a t e

TinyBookStore com

1 The C++ Programming L anguage Usually ships in 24 hoursBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

2 Effective C+-F Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

3 Programttung Visual C-H- Usually ships in 24 hours David J Kmglinski Microsoft Press 1998 Our Price 3999

T m y h o o k s to e co m H o m e | C a te g o ry | A u th o r | T itle | ISBH | P u b lish er D ate

http iocalhost SOSOservletFleqCollectcategary

T op of P age

~hj Local intranet

bull a TlnjpBflOkStOfecom - Microsoft Internet Explorer

File Edit View Favorite Pools Help

0 3 4 S l i 3 O - J J i t of Stop Refresh Home S earch Favorites History - Mart Print Edit

HBack

i i i i lS i lB i I i f f id i l f f lH Q http Vlocalhost 8080AervletD etailContent1572318570

EEEI

J

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b lis h e r D a f t

TinyBookStore com

Programming Visual C++by David J KrngHnski

[Hj

ISBN 1572318570Microsoft Press 1998

Price 3999 Availability Usually ships within 24 hours

R e v ie w s

This is the review o f Programming Visual1

Reader Comments

Add to cart

if Local intranet

166

mm| File pounddtt View Favorites Jo o ls Help

c J J j j mdash JB ack - J Stop Refresh Home S earch Favorites History

- _ i -M u

J tPrint

t e t a f e w P A ddress | ^ ] httplocalhost8080servletAddToShoppingCart zl -lt1gtSo

Shopping Cart Item s

Programmeng Visual C + +David J Kmgbnski Quantity 1

delete-

Price

Price $ 3 0 9 0 Sub to ta l $ 3 9 9 9

Total 3 0 9 9

D one ^aj Local intranet

TinyBookStorecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

vHBack-

-J a 4 -a si fi- 3 aStop R efresh Home S earch Favorites History j Mail Print- Edit

Links gty A d d re s sL ^ ] hrtpWlocalhostSOSOservleVFIeqCollectAitle

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

ISBN

Pub l i she r Date

TinyBookStore com

Enter TitleYou can enter the exact title or part of title

Title Distil I nrfExact T itle V T itle W o rd s

Search Now | Cle ar Fo rm

Examples

rpound] Done

bull Entering Java Servlet Programming11 in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title arei date 11 j Java JZJ

167

a TlnyBA5kSioiecom - Microsoft Internet Explorergt 0e Edit ifiew Favorites Jock Jd lp

a a amp -a tii j k i Back s - Stop Refresh Home Search Favorites History Mail Print

liilP raquo httpiVlocalhostSOSOservletTitleProcess

E M 3

ldquo3 rgt-

S ea rch B ook s

Horne

C a t e d o r v

A utho r

TiUgt~ ISSN

Publi sher D a te

Tiny BookStore com

1- TJML D istilled Usually ships in 24 nowsMartin Fowler Addis on-Wesley Pub Co 1997 Our Price 2995

| C s rg g o ty | A u th o r | T itle | IStBH I P u b lis h e r D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g Xiao

-jg Local intranetS3

m n ^ i l a i i x l

File Edd View Favorites Joels- Help M Mi r J lt 3 L h f 4 - 0 lt 3

Back i t Stop Refresh Home S earch Favorites History Mail9

PrintM

Edit

Links raquo A ddress j | i ] http do ca lh o d 1030N m letDetailContenr0201325632 Mimas

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

Title

IS B N

Publisher Date

Tiny BookStore com

TJML Distilledby Martin Fowler

0

ISBN 0201325632 Addison-Weslev Pub Co 1997

Reviews

Tins is the review of The UML Distilled

Reader Comments

Price 2995 Avail abilityTJs u ally ships within 24 hours

Add to c a r t

0 3S i] Done |g^iLnealiihfrregei

TinyBookStorecom Shopping Cart Microsoft Internet ExplorerFile Edit View Favorites Jo o ls HetP

IBiiiBlll l l lHBlSglSlllllilMH MlllBliriilllgllSlIlBack - f - i - S top Refresh Home

a J i l ^ j 3 Search Favorites History 1 Mail Print liiii

3 Links ( A ddress j ig j hrtplocalhost803DservletAddToShoppingCart

Shopping Cart Herns Price

UML D istilledMartin Fowler Quantity 1Program m ing Visual C + +David J Kraglinski Quantity 1

Price $ 2 9 9 5 Subtota l $ 2 9 9 5

delete

Price $ 3 9 9 9 Subtota l $ 3 9 9 9d elete

Total 6 9 9 4

  • Electronic Commerce on Business Application
    • Recommended Citation
      • tmp1499779448pdf2JOpQ

1

Chapter 1

Introduction

As we step in the year 2000 we can no longer look to the past as the guide for the

future A combination of business social and technical possibilities drives the rapid

progress in electronic commerce

Electronic commerce can offer a company both short-term and long-term benefits

Not only can it open new markets enabling a business firm to reach new customers

but it can also make it easier and faster for the firm to do business with their existing

customer base Moving business practices such as ordering invoicing and customer

support to network-based systems can also reduce the paperwork involved in

business-to-business transactions When more of the information is digitized it

allows that business firm to focus on meeting their customerrsquos needs Tracking

customer feedbacks and presenting customer solutions for their clientele are just

some of the opportunities that can stem from electronic commerce

2

Chapter 2

Electronic- Commerce

21 What Is Electronic Commerce

For some time now large business enterprises have used electronic commerce to conduct

their business-to-business transactions In early 1960 private networks were dedicated

for the use of electronic data interchange (EDI) and electronic funds transfer (EFT) in the

banking industry Recently however with the increased awareness and popularity of the

Internet electronic commerce has come to encompass individual consumers as well as

businesses of all size

To many electronic commerce is defined as the buying and selling of products and

service over the Internet But there are many other aspects Depending on whom you ask

electronic commerce has different definitions

From a communications perspective electronic commerce is the delivery of information

productsservices or payments via telephone lines computer networks or any other

means From a business process perspective electronic commerce is the application of

technology toward the automation of business transactions and workflow From a service

perspective electronic commerce is a tool that addresses the desire of firms consumers

and management to cut service costs while improving the quality of goods and increasing

3

the speed of service delivery From an online perspective electronic commerce provides

the capability of buying and selling products and information on the Internet and other

online services [16]

These definitions are valid with their perspectives It is a matter of which lens is used to

view the electronic commerce landscape Broadly speaking electronic commerce

emphasizes the generation and exploitation of new business opportunities by ldquogenerating

business valuerdquo or ldquodoing more with lessrdquo

22 The Importance of Electronic Commerce

As we approach the year 2000 we can no longer look to the past as guide to the future In

the face of strong market forces created by electronic commerce and mounting

competition corporations can no longer plod along historical tracks or seek the

preservation of the status quo Companies are discovering that old solutions do not work

with new problems The business parameters have changed and so have the risks and

payoffs

23 Types of Electronic Commerce

From a broad view there are three distinct general classes of electronic commerce

applications Inter-organizational (business-to-business) intra-organizational (within

business) and customer-to-business application [16]

4

231 Inter-Organizational Electronic Commerce

Inter-organizational electronic commerce makes business more convenient on the

following aspects

Firstly e-commerce can improve supplier management since electronic applications can

reduce the processing costs and cycle times for each purchase order and it can reduce the

number of people who work on purchase orders

Secondly e-commerce can improve inventory management since electronic applications

make the business partners can fast exchange information and easy track their documents

to ensure that they were received This not only can eliminate out-of-stock occurrences

but also can reduce inventory and improve inventory turn

Thirdly e-commerce can improve distribution management since electronic applications

can make the business partners receive the shipping documents as soon as possible and

enable better resource management by ensuring that the documents contain more accurate

data

Fourthly e-commerce can improve channel management since electronic application can

let the business partner post the information to electronic bulletin boards This can

eliminate repeated telephone calls and countless labor hours

Fifthly e-commerce can improve payment management since the business partner are

linked by network so the payments can be sent and received electronically Electronic

payment is more accurate and fast than traditional payment

232 Intra-Organizational Electronic Commerce

5

Intra-organizational electronic commerce facilities the following business applications

Workgroup communications Electronic applications enable manager to

communicate with employees using electronic mail videoconferencing and

bulletin boards

Electronic publishing Electronic applications enable companies to publish

information by using tools such as the World Wide Web On-line publishing can

show information immediately and clearly and reduce costs for printing and

distributing documentation

Sales promotion Electronic application improve the flow of information between

the production and sales forces and between the firms and customers This can

make companies have greater access to market and competitor information

Today Intranets are primarily set up to publish and access vital corporate information

Some of the most common types of information are Human Resources information

employee communications product development and project management data internal

catalogs sales support data equipment and shipment tracking and accessing corporate

database

233 Consumer-To-Business Electronic Commerce

In consumer-to-business transactions customers learn about products through electronic

publishing buy products with electronic cash and other secure payment systems and

even have information goods delivered over the network

6

From the consumerrsquos perspective there are three transactions

1 Electronic applications enable consumers to communicate with each other through

electronic mail videoconferencing and news groups

2 Electronic applications enable consumers to manage investments and personal finances

using online banking tools

3 Electronic application enable consumers to find online information about existing and

new products services

Consumers consistently demand greater convenience and lower prices Electronic

commerce provides consumers with convenient shopping methods from online catalog

ordering to phone banking both of which eliminate the costs of expensive retail

branches Electronic commerce facilitates factory orders by eliminating many

intermediary steps thereby reducing manufacturersrsquo inventory and distribution costs and

indirectly providing consumers with lower prices

24 Why Most Internet Based Electronic Commerce Is In The Business-To-

Consumer World

For the Business-to-Business e-commerce the lack of well-accepted standards is

hindering the success in promoting Business-to-Business electronic commerce

solutions[5] VAN (Value-Added Networks) EDI (Electronic Data Interchange) based

solutions are only accessible to large organizations due to the cost factor Corporate

buyers and suppliers large and small are looking for Internet based solutions to

streamline the procurement procedures and to reduce the cost of establishing trading

relationship and the trading transactions Such demands put forward some fundamental

challenge on issue like trust infrastructure on the Internet standards and inter-operability

etc

25 Current State of Business-To-Consumer E-Commerce

Business activity on the Internet is currently limited to publicizing the business

opportunity and to catalog based sales but it will rapidly expand to include the

negotiations conducted to settle the price of the goods or commodities being traded

These negotiations are currently conducted by human intermediaries through various

forms of auctions bidding systems for awarding contracts and brokerages The role of

the intermediaries can now be performed by Internet trading applications at a fraction of

the cost[4] Trading on the Internet allows a business to reach a large number of potential

customers and suppliers in a shorter time and a lower cost than possible by other modes

of communication and to settle business transaction with lower cost overhead in a shorter

time

Auctioned or brokered sales are the norm in business world for negotiating trades of large

monetary value But consumer sales and small-scale purchases have used the fixed price

mode perhaps because of the high overhead cost of using the auction or brokerage

method The new economics of the Internet will make auctions popular in consumer and

small business transactions also

Auctions are just one form of business negotiations Other examples are competitive bids

for procurement brokeragesexchangescartels and two party negotiations

Nowadays the free-market economy of software agents is in the embryonic stage But in

the near future the software agents will populate the Internet and provide trade and use

a rich variety of information goods and services in an open free-market economy In a

free-market economy of software agents information is produced traded and consumed

by vast numbers of autonomous self-motivated agents An essential task in such an

economy is the retailing or brokering of information gathering it from the right

producers and distributing it to the right consumers[10] The overall research goal is to

characterize and understand the dynamic behavior of information economies very large

open economies of automated information agents that are likely to come into existence in

the Internet

26 The Structure of The On-Line Store

9

Nowadays there are thousands of on-line stores running on the Internet A few well-

known ones are amazoncom and bookpoolcom Most of such applications involve

common functions which are as following

Searching for product information

Ordering products

Paying for goods and services

Providing online customer service

So they have a similar structure as shown in Figure 261 The system contains the

following components

1 A web server running continuously accepts userrsquos connection gets user requests and

forward requests to business procedure retrieves data (answers to user requests) from

business procedure and send it back to user

2 Business procedure usually consists of a user identification procedure like credit card

check user request analysis procedure analyzing requests calculating discomposing (if

necessary) and dispatching request to different data source component Also in some

case business procedure is responsible to compose data obtained from different data

sources into user-readable format

3 Database is the place to hold relevant data These data not only serve as a data source

describing commercial goods and prices but can be used for data mining to improve

store service quality as well Database is updated and maintained by both customersrsquo

input and system applications A customerrsquos input usually includes order information

10

Figure 261 The Structure of An Online Store

(through browser)

Databas

(through browser)client

client

serverWeb

Systemapplication

Busines

procedu

4 System applications can include a search engine running all the time and searching

relevant information from the internet data mining application deals with mining and

analyzing customer and sale data for management use database maintaining application

handles update data when product information changes Varying from system size to

system size not every system has cleardistinct boundaries between these components

The system can be 3-tired or n-tired but these systems all operate in similar ways

11

Chapter 3

Technologies For On-Line Store System

An on-line store system is different from traditional web publishing It needs customerrsquos

interactive communications and frequent data update The traditional HTML page is

insufficient because all it does is provide static content publishing Other technologies

are required in order to implement the on-line store

Currently there are three mainstream technologies which are widely used Common

Gateway Interface (CGI) Microsoft Active Server Page (ASP) and Server-side Java

application We briefly explore these technologies here

31 Traditional Web Application - Common Gateway Interface (CGI)

The common Gateway Interface normally referred to as CGI is one of the first practical

techniques for creating dynamic content With CGI a web server passes certain requests

to an external program The output of this program is then sent to the client in place of a

static file The advent of CGI makes it possible to implement all sorts of new

functionality in web pages and CGI quickly become a defacto standard implemented on

dozens of web servers Even though a CGI program can be written in almost any

language the Perl programming language is the predominant choice However CGI have

some distinct disadvantages

Firstly CGI program is transient A request is made each time to a CGI program It must

be loaded and executed by the Web server When the CGI program is complete it is

removed from memory and the results are returned to the client All program

initialization (such as connecting to a database) must be repeated each time a CGI

program is used

Secondly when a server receives a request that accesses a CGI program it must create a

new process to run the CGI program and then pass to it via environment variables and

standard input Every bit of information might be necessary to generate a response

Creating a process for every such request requires time and significant server resources

which limits the number of requests a server can handle concurrently

Thirdly a CGI program cannot interact with the web server or take the advantage of the

serverrsquos abilities once it begins execution because it is running in a separate process

32 Active Server Page

As shown in figure 321 the following list walks you step-by-step through what

happens if the client requests the page xyzasp

The client requests the page xyzasp from the server The Web server checks the file

extension to see whether a special program (such as the Active server Pages engine)

13

must be invoked to process the request If therersquos a asp extension the Web server

determines that it should invoke ASP to process this page

Figure 321 Handle Requests Flow Chart

Request

Response

WEB SERVERComponents

Databas

ns

ASP File

CLIENT

Active X Data

VBScript

If this page has never been requested before or has been changed since the last

request it must be parsed and the syntax checked and then be compiled by the Web

server Otherwise the page might be read from a cache of recently processed pages

which aids in performance During the parsing process the HTML and scripting code

14

are separated IIS (Internet Information Server) determines which scripting engine is

responsible for which part of the script and delegates the work of syntax checking and

compiling to the proper scripting engine (such as VB Script)

Now the code is executed by the scripting engine using resources from IIS which is

hosting the scripting engines All objects that the language engine cannot handle are

requested by the IIS which is also responsible for handling inputs and outputs for the

external ActiveX objects that are created and used inside the script If it is not able to

supply the object an error is generated

Script output and static HTML code in the ASP file are merged

The final HTML is sent back to the user in an HTTP response

The important point about ASP is that the Script runs entirely in a server to protect the

intellectual property by shielding it from browser which are different from the account

for when writing client-side code The entire server-side code is processed and only plain

HTML - or whatever kind of content you chose to generate - is sent to the client

33 Server-Side Java Application

The rise of server-side Java applications is one of the latest and most exciting trends in

Java programming A Servlet can be thought of as a server-side applet Servlets are

loaded and executed by a Web server in the same manner that applets are loaded and

executed by a Web browser

15

As shown in Figure 331 a servlet accepts requests from a client (via the Web server)

performs some task and returns the results

The client (mostly likely a Web browser) makes a request via HTTP The Web server

receives the request and forwards it to the servlet If the servlet has not yet been loaded

the Web server will load it into the Java virtual machine and execute it The servlet will

receive the HTTP request perform some type of process and return a response back to

the Web server The Web server will forward the response to the client

Figure 331 HttpService of The Java Web Server Using Servlets

RequestResponseRequestResponse

RequestResponse

Java Web Server

Administrative SERVLET

SERVLETHTTP

SERVLETWeb Proxy

Servlets have distinct advantages over CGI program

Servlets are persistent Servlets are loaded only once by the Web server and can

maintain services (such as a database connection) between requests

Servlets are fast since servlets only need to be loaded once

16

Servlets are platform independent Servlets are written in Java and conform to a well-

defined and widely accepted API They are highly portable across operating systems

and across server implementations A servlet can be developed on a Windows NT

machine running the Java Web Server and later can be deployed effortlessly on a

high-end Unix server running Apache

Servlet portability is not the stumbling block it so often is with applets There are two

reasons Firstly servlet portability is not mandatory Unlike applets which have to be

tested on all possible client platforms servlets have to work only in the server

machines that you are using for development and deployment Unless you are in the

business of selling your servlets you donrsquot have to worry about complete portability

Secondly servlets avoid the most error-prone and inconsistently implemented portion

of the Java language the Abstract Windowing toolkit (AWT) that forms the basis of

Java graphical user interfaces

Servlets are extendable Servlets that are written in Java brings all of the other

benefits of Java to servlet Java is a robust object-oriented programming language

which can be extended easily to suit our needs

Servlets are secure The only way to invoke a servlet from the outside world is

through a Web server This brings a high level of security especially if the Web

server is protected behind a firewall

Servlets can be used with a variety of clients

Servlets are tightly integrated with the server This integration allows a servlet to

cooperate with the server For example a servlet can use the server to translate file

paths to perform logging and to check authorization

Servlets are quite flexible An HTTP servlet can be used to generate a complete web

page it can be added to a static page using a ltSERVLETgt tag in whatrsquos know as a

server-side include and it can be used in cooperation with any number of other

servlets to filter content in something called a servlet chain

18

Chapter 4

Design of On-line Bookstore Using Java Servlets A Practical

Verification

Server-side Java application is one of the latest technologies used to implement an onshy

line store system Servlet is a set of classes that come up from Java language It is

designed to be used for server-side Java applications There are many techniques people

can use when they utilize servlet such as Server-Side Include (SSI) Servlet Chaining

Applet and Servlet communication etc We tried to use as many such techniques as

necessary in our implementation to demonstrate the advantages of servlets

The demonstration system module is same as the one we mentioned above Figure 331

We use this module to show how such system works

The system called Tiny Book Store emulates an on-line bookstore selling computer

books It has the full functionality of other on-line stores The only difference between

this system and the other on-line systems is the database size We donrsquot want to spend

much developing time for database maintaining part because this part is similar to

ordinary database maintaining and it is an independent subsystem The Tiny Book Store

mainly consists of three modules user interface business procedure and data access

19

41 The Design of Home Page of Tiny Book Store

The home page - welcome page - is designed using the Server-Side Include technique

That is embedding a servlet inside HTML file with a specific HTML tag ltSERVLETgt

In our case this servlet when invoked can run a query on database via data access

objects to retrieve most recent top 5 best-seller books and then returns the retrieved data

to the place within the page where the ltSERVLETgt tag was As long as the data in

database update timely it is guaranteed that customer will get the most recent data

The embedded servlet is invoked by Java Web Server before the page is sent back to

client Java Web Server processes any HTML file having shtml extension and invokes

the embedded servlet marked by ltSERVLETgt tags

Server-Side Includes are useful when a page is primarily static but contains a few distinct

dynamic portions One of the servlets produces the ldquo Five Hot Books ldquo which is shown in

the following example

Example 411 A Part of Code of welcomeshtml

lt P gt

lth3xstrongxf ont color= f f 6347 gtWelcome to theltigt

TinyBookStorecomltigtltfontgtltstronggtlth3 gt

20

ltstrongxbxh3gtltcentergtFive Hot

Booksltc e n t e r x h3gtltbgtltstronggt

ltbrgt

ltservlet code=EchoServletTaggt

ltservletgt

The servlet EchoServletTag searches database according to some business rule and gets

data from data access objects to produce the Five Hot Books The following example is

the sample code

Example 412 A Part of Code of The EchoServletTagjava

public void service(HttpServletRequest req

HttpServletResponse res)

throws ServletException IOException

res setContentType ( text Jhtml)

PrintWriter out = resgetWriter()

try

Statement stmt = concreateStatement()

21

ResultSet rs = stmtexecuteQuery(select from

book where

title like Programming)

int count = 1

outprintln(ltdlgt)

while (rsnext() ampamp count lt 6)

out print In ( ltdtxbgt + count + )

String isbn =

rsgetObj ect(ISBN) toString()

outprintln(lta

href=servletDetailContent + isbn +

outprintln(rsgetObj ect(Title) toString()

+ lt a x bgt )

out println ( ltddxnobrxfont color=990033gtUsuallY

ships in 24 hoursltBRxfontxnobrgt )

outprintIn(ltbrgt +

rsgetObject(Author) toString() )

outprintIn( +

r s getObject(Publisher)toString() + +

r s getObj ect(PublicationDate) toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

out println ltbrxbrgt )

22

count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()

The servelt EchoServletTag by the business mle that searching a specific table sends a

request query through data access object stmt and gets search result through another

data access object rs It then passes data to the page The content between ltservletgt and

ltservletgt tags in the HTML of home page is replaced by the search result at run time

The center part of the sample result page in Figure 411 is an example

23

Figure 411 The Home Page of Tiny Book Store

gj Search TinybookstGiecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

^ bullgt o a 4 i a a j ugt- a a Back lt7gtn Stop Refresh Home j Search Favorites History Mail Print Etfe

-Six

sfekinlfeSsI 3 Address |iS1 httpiVlocalhosLSOSCVwelcomeshtrnl Cj

f S M B l TinyBookStorecom

Search B o o k sW e l c o m e tc f l i e

HomeFive H ot Books 1 1

Category i-si

IA uthor

Title1 The C + + Programming L a n g u a g e B

Usually ships in 114 hoursISBN

k

IPublisher D a teBjame Stroustrup Addis on-Wesley Pub Co 1997Our Price 3147

m2 Programming Visual C+ +

Usually ships in 24 hours y

David J Krn^dinski Dlicrosoft Press 1998 c damp Local intranet

From this practice we know Server-Side Include not only can produce dynamic portion

of the page but also prevent from other people spy into your code Since Java servlet runs

entirely on a server thus protecting your intellectual property and shielding you from the

browser This means what the client sees can be totally different from what the server

does From the client side it is difficult to figure out how the server works

The left-hand menu items are implemented by using a characteristic of servlet - extra

path information or virtual path The extra path information can be used as a kind of

parameter passed to a servlet In general this extra path information is used to indicate a

24

file on the server that should use for something We use this feature here in an abnormal

way to manage customer requests and process these requests in a single place

Consider a traditional method When a menu item is selected by a customer it redirects

the customer to another page where it hyperlinks to If we have several ten items we

need to pre-create several ten pages This is the disadvantage of static HTML pages

However with servlet which can dynamically generate page content we can direct all the

customer requests to a central servlet and process the requests there according to some

condition (parameters) and then generate the page which customer need to see In this

way we only need one place to hold the code to save serverrsquos space And this place is

easy to maintain

The following is how it was doing for the Tiny Book Store

The Author item uses the following hyperlink

ltA

href = servlet ReqCo 11 ect author gtAuthorlt fontx AxTDgt

ltTRgt

The ReqCollect is the name of a servlet We pass the ldquoauthorrdquo in the hyperlink as a

parameter to ReqCollect When the Author item is selected ReqCollect is invoked by

lava Web Server ReqCollect generates a html page to let a user input author search

condition The ReqCollect code is listed below

25

Example 413 A part of Source Code of ReqCollectjava

public class ReqCollect extends HttpServlet

protected final String AUTHOR = author

public void service(HttpServletRequest req

HttpServletResponse res) throws ServletException

IOException

PrintWriter out = resgetWriter()

String path = reqgetPathlnfo ()

if (path == null)

error handling

else

Create standard header

CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

26

path = pathsubstring(1)

if (pathequalsIgnoreCase(CATEGORY))

Create category request collect

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

outprintln(ltfont color=CC66 0 0

face-verdana arial helvetica size = + lxbgtEnter

Authorltbgtltfontgt )

outprintln(ltbrgt You can enter

authors full name first name or last nameltpgt)

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess

id=forml name=formlgt)

outprintln(lttable border=0gt)

outprintln(lttrgt lttd valign=middle

align = lef txttgtltbgtAuthor ltbxttxtdgt )

outprintln(lttd valign=middle

align = lef txinput type = text name= author size = 40

value=x tdgt )

outprintln(lttrgt)

27

outprintln(lttrgt lttd colspan=2gt ltfont

size=-lgt)

outprintln(ltcentergt ltinput

type=radio name=author_mode value=exact

checkedgt Exact Name)

outprintln(ltinput type=radio

name=author_mode value=lastgtLast First Name (or

Initial) )

outprintln(ltcentergt)

outprintln(ltfontgt)

outprintln(lttdgt lttrgt)

outprintln(lttrgt lttd colspan=2gt ltpgt

ltbrgt lttdgt lttrgt)

outprintln(lttablegt)

outprintln(ltcentergt)

outprintln(ltinput type=submit

value=Search Now id=submitl name=submitlgt)

outprintln(cinput type=reset

value=Clear Form id=resetl name=resetlxpgt )

outprintln(ltcentergt ltformgt)

Create standard footer

28

CreateFooter(out)

outflush()

outclose()

The generated page looks like this

Figure 412 One of The Searching by Author PagesTinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorite l o o k H e lp

^ 3 4 s j ] S o zdStop Refresh Home Search Favorites History Mail Print EditBack bull

I t i h f e l f f httplocalhost8080servletReqCollectauthor

S ea rch Books

Home

C a t e g o r y

Author

Title

ISBN Publisher Date

poundj

TinyBookStore com

You can enter authors foil name first name or last name

A u t h o r jbjarne

C Exact N ame amp Last First N atne (or Initial)

Search Now | Clear Form

Taw boekstofeeoraH om e | Category | A uthor | Title | IS3M | Publisher Date

jpyright and disclaimer copy 1999-2001 F ang Xiao

ihtterteti

42 Design of Search by Different Requests

29

According to different requests the different pages should be produced There are many

common parts in the produced pages So we donrsquot need to code the common parts for

each page We can design the common parts into standard utility classes or static

functions You can simply call the standard classes or functions when you needed them

An example looks like this

CreateHeader(out)

CreateLeftMenu(out)

CreateFooter(out)

The three lines above invoke the standard functions CreateHeader() CreateFooter() and

CreateLeftMenu() which are developed in this thesis writing The CreateHeader()

function produces the top part of the pages The CreateLeftMenu() function produces the

left part of the pages The Createfooter() function produces the bottom part of the pages

You can find the source code in several servlets in Appendix

43 Servlet Chaining To Process Requests In Different Levels

A request can be handled by a sequence of servlets This system is designed to use the

first level servlets to handle the search requests If needed the first level servlets can

cooperates with the second level servlets by passing their processing result to the second

level servlets and let them to proceed the request until the final result is obtained The

final result is returned by the last servlet This is called servlet chaining The request

30

from the client browser is sent to the first servlet in the chain The response from the last

servlet in the chain is returned to the browser In between the output from each servlet is

passed as an input to the next servlet Each servlet in the chain has the option to change

or extend the content W e can see the example in the ReqCollect code

Example 431 A Part of Code of The ReqCollectjava

if (pathequalsIgnoreCase(AUTHOR))

outprintln(ltform method=POST

action=httplocalhost8080servletAuthorProcess id=forml

name=formlgt)

The ReqCollect servlet uses the getPathInfo() method to get the extra path information

This method returns the extra path information associated with request According to the

different extra path information the first level servlet invokes the different servlet of the

second level In this case ReqCollect invokes AuthorProcess servlet The final output

has been listed in Figure 412

31

44 Database Connectivity and Search from Database

The biggest advantage for servlets with regard to database connectivity is that the servlet

life cycle allows servlets to maintain open database connections An existing connection

can trim several seconds from a response time compared to a CGI program that has to

reestablish its connection for every invocation

Another advantage of the servlets over CGI and many other technologies is that JDBC is

database-independent JDBC is a SQL-level API - one that allows you to execute SQL

statements and retrieve the results if any The API itself is a set of interfaces and classes

designed to perform action against any database

An individual database system is accessed via a specific JDBC driver that implements the

javasqlDrivers interface Drivers exist for nearly all-popular RDBMS systems The

database connection used for Tiny Book Store uses a JDBC-ODBC bridge driver coming

along with the JDK 12 to allow access to standard ODBC data source such as the

Microsoft Access database

The first step in using a JDBC driver to get a database connection involves loading the

specific driver class into the applicationrsquos Java Virtual Machine This makes the driver

available later when we need it for opening the connection An easy way to load the

driver class is to use the ClassforNameQ method

32

ClassforName(sunj dbcodbcJdbcOdbcDriver)

When the driver is loaded into memory it registers itself with the javasqlDriverManager

class as an available database driver

The next step is to ask the DriverManager class to open a connection to a given database

where the database is specified by a specified formatted URL The method used to open

the connection is DriverManagergetConnection() It returns a class that implements the

javasqlConnection interface

Connection con =

DriverManagergetConnection(j dbcodbcsomedb

user passwd)

A JDBC URL identifies an individual database in a driver-specific manner Different

drivers may need different information in the URL to specify the host database

During the call to getConnection() the DriverManager object asks each registered driver

if it recognizes the URL If a driver says yes the driver manager uses that driver to create

the Connection object Here is an example

Example 441 A Part of Code of AuthorProcessjava

public void init() throws ServletException

try

ClassforNamesunj dbcodbcJdbcOdbcDriver)

con =

DriverManagergetConnection(j dbcodbcfxbookstore null

null)

catch (ClassNotFoundException e)

catch (SQLException e)

After we got the database connection we need to have some way to execute queries The

simplest way to execute a query is to use the javasqlStatement class Statement objects

are never instantiated directly instead a program calls the createStatement() method of

Connection to obtain a new Statement object

Statement stmt = concreateStatement()

34

A query that returns data can be executed using the executeQuery() method of Statement

This method executes the statement and returns a javasqlResultSet that encapsulates the

retrieved data

Example 442 A Part of Code of AuthorProcessjava

String sqlStmt =

if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where author= + name +II i n

else

sqlStmt = select from BOOK where author like +

name +

ResultSet rs = null

Statement stmt = concreateStatement()

rs = stmtexecuteQuery(sqlStmt)

35

A ResultSet object can be thought as a representation of the query result returned one row

at a time The next() method of ResultSet is used to move from row to row The

ResultSet interface also boasts a multitude of methods designed for retrieving data from

the current row The getStringO and getObject() methods can be used for retrieving

column values

Example 443 A Part of Code of AuthorProcessjava

while (rsnextO )

count++

outprintln(ltdtgtltbgt + count + )

String isbn = rsgetObject(ISBN)toString()

outprintln(lta href=servletDetailContent + isbn +

gt )

outprintln(rsgetObj ect(Title) toString() +

ltagtltbgt)

outprintln (ltnobrxfont color=990033gtUsually ships

in 24 hoursltBRgtltfontxnobrgt)

outprintln(ltddgt +

rsgetObj ect(Author) toString() )

36

outprintln( +

rs getOb j ect ( Publisher) toString () + +

rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +

rsgetObj ect(Price) toString() )

outprintln(ltbrgtltbrgt)

One of the outputs of servlet AuthorProcess is show in Figure 421 and Figure 441

Figure 441 One of The Outputs of Servlet AuthorProcess

37

File Edit View Favorites lo o k - Help M i

T 1 bdquo - 0 L Q 4 pound $ L L lBack r s Stop Refresh Home S earch Favorites History

A - Mail Print

Links rdquo Address | jyen j http7ocalhost808O$ervletAuthorProcess 3

Search B ooks

Home

CategoryA uthor

Title

ISBN

P u b l i sh e r D a te

Tiny Bookstore com

1 The C++ Prograitmuitg Language Usually ships in 24 hour Bjame Stroustrup Addison-Wesley Pub Co i 1997 Our Price 3147

T in yb o oks to re c om H ora e | Category | A uthor | Till | ISBN | Publisher P a t

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top of Page

gk j Local intranet

45 Session Tracking

Session Tracking is one of the most important techniques for any on-line store systems

This is because that HTTP protocol is a stateless protocol A HTTP server sees only a

series of requests and it by itself has no way to know exactly who is making the request

This means that when a customer puts a book in his shopping cart and then goes to other

pages to find more books next time when he puts another book in his shopping cart there

is no guarantee that he puts the book in the same cart It is very possible that he uses

another customerrsquos shopping cart at this time

38

To solve this problem session-tracking is introduced Traditional techniques used by

CGI include hidden form fields URL rewriting user authorization and persistent cookies

For server-side Java applications a built-in class supplied servlet can be used easily to

handle such tasks

When a user first accesses the site web server assigns a new HttpSession object and a

unique session ID to the user The session ID identifies the user and is used to match the

user with the HttpSession object in subsequent requests Usually the session ID is saved

on the client in a cookie or sent as part of a rewritten URL The Tiny Book Store uses this

technique

The Tiny Book Store is a classic shopping cart application A client can put items in his

virtual cart accumulating them until he checks out several page requests later How to

make sure a userrsquos shopping items will be put in his shopping cart or delete from his

shopping cart The Java Servlet API provide built in session tracking to handle this

problem Every user of a site is associated with a javaxservlethttpHttpSession object

that servlets can use to store or retrieve information about that user We can save any set

of arbitrary Java objects in a session object For example a userrsquos session object provides

a convenient location for a servlet to store the userrsquos shopping cart contents An example

shows below

Example 451 A Part of Code of AddToShoppingCartjava

39

1 Get current session object create one if necessary

2 HttpSession session = reqgetSession(true)

3 m_cart = (ShoppingCart)sessiongetValue(cart)

4 if (ra_cart == null) need new cart

5 create a shopping cart

6 m_cart = new ShoppingCart()

7 add to current session

8 sessionputValue(cart m_cart)

9

10

11 try

12 Statement stmt = m_concreateStatement()

13 ResultSet rs = stmtexecuteQuery(select from

book where ISBN= + isbn +)

14 if (rsnext())

15 book - new

BookDetails(rsgetObj ect(ISBN) toString()

16 rsgetObject(Title)toString()

rsgetObj ect(Authorrdquo) toString()

17 rsgetDouble(Price)

rsgetObj ect(PublicationDate) toString() )

18

40

1 9

2 0 catch (SQLException e)

21 e printStackTrace()

22

23 m_cartadd(bookgetlSBN() book)

The servlet uses its request objectrsquos getSession() method to retrieve the current

httpSession object

public HttpSession HttpServeltRequestgetSession (boolean create)

This method returns the current session associated with the user making the request If

the user has no current valid session this method creates one if create is true or return

null if create is false To ensure the session is properly maintained this method must be

called at least once before any output is written to the response Please look at the line 2

in the example 451

If you want to add data to an HttpSession object you can use the putValueQ method

public void HttpSessionputValue(String name Object value)

41

This method binds the specified object value under the specified name Any existing

binding with the same name is replaced This specifies at line 8 of the example 451

If you want to retrieve an object from a session you can use getValue() method

public Object HttpSessiongetValue(String name)

This method specified at line 3 of example 451 returns the object bound under the

specified name or null if there is no binding

From line 4 to line 9 the servlet checks whether the user already has a shopping cart If

the user didnrsquot have a shopping cart the servlet assigns a shopping cart to this user and

add the shopping cart to the current session to keep tracking The ShoppingCartjava class

is developed in this thesis writing code is provided in the appendix

From line 10 to line 21 the servlet knows the user already has a shopping cart m_con is

a data member of AddtoShoppingCart class Lines 12-13 have been discussed in the

previous section Lines 16-20 get some information of the book which the user selected

The information will be the data members of the ldquobookrdquo object that is an instance object

of BookDetailsjava class BookDetailsjava class is developed in this thesis writing the

source code is provided in the Appendix

Line 25 puts the book which is selected by the user into the shopping cart

42

Please see a set of pages are shown below

Figure 451 A Page Show All Information About A Book

TinjiRnfikStnre com - M inrnsnfl Interned Explnrpr

File Edit View Favorites Tools Help-

^ O 4 4 1 f i tStop Refresh Home I Search Favorites History Mail Print Edit

I Link gtgt Address [gl hgtplocalhos9l]IBrit-rvetDetailConetit-Ll20183l)544

S e a r c h B o o k s

Home-

C a t e g o r y

Author

Title

ISSNPublisher Pate

TinyBookStore com

The C++ Programming Languageby Bjarne Stroustrup

aISBN 0201889544 Addison-Wesley Pub Co 1997

Price 3147 Availability U sually ships within 24 hours

Add to cart

Done

R ev iew s

In tins brand-new third edition of The C + + Programming Language author Bjame Stroustrup the creator of C++ presents the full specification for the C++ language and standard library a spec that will soon become the joint ISOANSI C++ standard

g ig L o ca l in tranet

43

Figure 452 A Page Show Items In The Shopping Cart after A User Added Books To The Shopping Cart

H H I H I - I I

j File Edit View Favorites l o o k Help I f

| S ack Stop Refresh Home Search FavoritesJ V

History Wail Print

j Links Address |S1 http7localhost8O80servletAddToShoppingCart i i i i a i i i

( O ldquo ii

Shopping Cart Item s Price

An Introduction to fen e tic Algorithm sMelanie MteheU Quantity 1 Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

drle trgt

delete

delete

Price $ 2 2 0 Subtotal $ 2 2 0

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 6 7 5 6

|euro

rfuj Local intranet

44

Figure 453 A Page Show Items In The Shopping Cart After A User Deleted A Book From The Shopping Cart

^ A m a z o n c o m Shopping Cart - Microsoft Internet Explorer

- J A l 4Stop Refresh Home

gtH bdquo ] Back bdquo

httplocalhost8080servletDeleteFromShoppingCartitemgetltem()getlSBN()

Ji _J 3Search Favorites History

j - JMarl Print

~U ccdeg

Shopping Cart Item s

Core Java 2Cay S Horstrnaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d elete

delete

Price

Price $ 2 5 7 9 Subtotal $ 2 5 7 9

Price $ 1 9 7 7 Subtotal $ 1 9 7 7

Total 4 5 5 6

rsquo0 1 Done gSsfLocat intranet

46 Check Out

This part is designed only using the HTML It collects all information from a user The

information will be written into the database

An important line in this HTML file is shown below

45

ltform method=POST

action=httplocalhost808 0servletCustomerlnfoProcessgt

This line will invoke the servlet CustomerlnfoProcess that will process all data collected

from the user This servlet will discuss in the next section The check out page shows in

Figure 461

Figure 461 A Check Out Page

M M iH M M M i M MmmrnfrnM File Edit View Favorites too ls Help

^ gt a 3 A hi -ltamp f V j HISllll mmB ack S lop R efresh H em e S earch 1 i l lie History M 1 Print Edit

^Links A ddrecs j ig ] h ltp localhostSO SO checkouth tm l i i i l a s

Custom er Information

First name (Fang

Middle initial |a

Last name [Xiao

Email address |fgtdaomitecnet

Account password Jxxxxx

C red it card num ber jl 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7

Credit card type ttV isa O BluebirdO MasterCard O Fisher

Credit card holder jFarig Xiao

Credit card expire date (tnmddyy) joi 0102 ~

Select shipping method t UPS 0 NormalO Express C Abnormal

| | ] Dorraquo raquo f j^ I o c a l intranet

47 Customer Information Processing

The customer information processing is handled by a servlet CustomerlnfoProces Its

source code is provided in the appendix

46

All information collected from the user should be written into the database therefore we

have to open a connection to a given database at first Example 461 is given for this

purpose

Example 471 A Part of Code of CustomerlnfoProcessjava

public void init() throws ServletException

try

ClassforName(sunjdbcodbcJdbcOdbcDriver)

m_con = riverManagergetConnection(jdbcodbcfxbookstore

null null)

catch (ClassNotFoundException e)

e printStackTrace()

catch (SQLException e)

e printStackTrace( )

There is a PO ST request in the check out page The servlet CustomerlnfoProcess will

handle the PO ST request by doPost function which is demonstrated in the following

example

47

Example 472 A Part of Source Code of CustomerlnfoProcessjava

public void doPost (HttpServletRequest req HttpServletResponse res)

throws ServletException IOException

ressetContentType(texthtml)

PrintWriter out = resgetWriter()

get information

String[] values = reqgetParameterValues(firstname)

if (values = null)

firstname = values[0]

values = reqgetParameterValues(middleinit)

if (values = null)

middleinit = values[0]

In the example the HttpServletRequest object res will get each data which was input by

the user by the getParameterValues() function

If the user is a returned user we donrsquot need open a new account again If the returned user

use the same credit card as previous we also donrsquot need to insert the credit card

48

information into the CREDITCARD table Otherwise we should insert all related

information into related table This is shown in the following example

Example 473 A Part of Source Code of CustomerlnfoProcessjava

Statement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where EmailAddress= +

email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext())

sql = insert into CUSTOMERACCOUNT (emailaddress password

firstname middleinit lastname) values ( + + email +

password + + firstname + + middleinit + lastname +

)

stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber= + creditcard

+

rs = stmtexecuteQuery (sql)

if (rsnext())

49

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype

HolderName ExpirationDate) values( + + creditcard + +

cardtype + + cardholder + 11 + expiredate + )

stmtexecute (sql)

All information related the books selected by the user can be obtained from the

shopping cart as shown in the following example

Example 474 A Part of Source Code of CustomerlnfoProcessjava

BookDetails book = null

ShoppingCartltern bookAndQuantity = null

Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getltems()

int aQuantity =0

String alSBN = null

while (itemshasMoreElements())

insert into Orderltems

bookAndQuantity = (ShoppingCartItem)itemsnextElement()

book = bookAndQuantitygetltem()

50

aQuantity = bookAndQuantitygetQuantity()

alSBN = book getISBN()

sql = insert into ORDERITEMS (shoppingCartID ISBN quantity)

values ( + + m_cartID + + aISBN + + aQuantity + )

stmtexecute (sql)

After all information inserted into related tables the servlet CustomerlnfoProcess will

produce invoice page The example page shows in Figure 471

51

Figure 471 An Invoice Page 3 Order List Microsoft Internet Explorer

is File Edit View Favorites Tools Help

J J J U r PS to p Refresh Hom e i -S earch Favorites History s Mai Print

Links Address iff 1 httpVlocalhostBOSOservletCustomerlnfoProcess 3

s5al Local intranet

Y ou r order reads as fo llow sE-MailAddress fiiiaomitecnet

ship to

Tel

Items

F ang Xiao12345 Western Plaza 23OmahaNE68154(402)123-4567

TitleCore Java 2Qtyl Price2579Subtotal2579

TitleJava Servlet PrograrnmingQtyl Price 1977 Sub total 1977 Total4556

i|51 D one

52

Chapter 5

Future Work

In this chapter we discuss two major problems for our future work They are the

Connection Pooling and Object-Oriented for better encapsulation

51 Connection Pooling

After we have used JDBC for a short time it will become evident that the major

performance bottleneck often comes right at the beginning when you are opening a

database connection This is because that opening a connection might involve a series of

low level communications between network protocols and database connection protocols

such as TCPIP ODBC etc

Servlet life cycle allows for extremely fast database access Servlet is loaded into Web

server only once Once it is loaded it can hold a connection to database all its life cycle

Every time it receives a request to read from or write data to database it can just use the

connection to do this

Here comes a problem however Suppose that a customer comes to the on-line store

During the period of selecting some items from the store he leaves his desktop and do

something else leaving this connection to database idling This will waste the precious

resource on the database From database port of view the connection to the database will

assign a space to hold corresponding status and to cache data For example Microsoft

SQL-Servertrade assigns about 36K bytes for each of its connection Resource on the

53

database is limited and idling connection causes such resource unable to be reused for

other users

To solve this problem we can use the technique called connection pooling Essentially a

connection pool is an object holding connections to backend database and managing the

number and status of connections For example if a connection in the pool idles over a

certain time of period the pool can terminate this connection if the requests are not the

same size of the connection pool the pool can dynamically shrink or expand the size of

itself A connection pool can run on a separate thread and is initialized when the server

starts or when a request to database is arrived

To implement a connection pool is pretty straight-forward Because of time constraint

however we did not do it in this paper and leave it as a possible future improvement

52 More Object-Oriented - Better Encapsulation

Another improvement might be done in the future is to create a HTML-related utility

class We have seen in this thesis that there are some duplicated code processing HTML

output such as ldquoout printIn ( lttbxtrgt lttrxtbgt)rdquo All these HTML-

related processes right now are used in a raw way That is they are not encapsulated A

better way to do this is to create a utility class or classes to deal with all HTML-related

processes and hide all HTML tags and format inside the class or classes For example

suppose that we create a Table class then we can use it in a way like

Table table = new Table()

54

table(somerow somecol contents)

table(somerow somecol some_image)

In this way we do not need to use HTML tags in our program and concentrate on the

programming logic The implementation is enriched with more object-oriented property

and therefore it is easy to maintain

55

Chapter 6

Conclusion

The increased awareness and popularity of the Internet make all kinds of electronic

commerce grow vigorously The most popular Web applications are the on-line stores

An on-line store system usually contains four components Web server business

procedure Database system application An on-line store system is different from web

publishing Currently there are three mainstream technologies which are widely used to

develop the on-line store systems CGI Microsoft ASP and Server-side Java application

Introducing the server-side Java application is one of the latest and most exciting trends

in Java programming We have discussed this technology in detail in this thesis The

server-side Java applications have many distinct advantages over CGI and other

technologies We present plenty of examples and figures to analysis the characteristics of

the server-side Java application

As a glance into the future electronic commerce will continue to grow driven by

purchases of home computers and other Web-enabled devices as well as new business

opportunities Electronic commerce is changing whole business procedures The future of

electronic commerce will be exciting and full of opportunities

56

APPENDIX A

Bibliography

57

[1] Karl Moss 1998 Java Servlets Mcgraw-Hill

[2] Jason Hunter William Crawford 1998 Java Servlet Programming O rsquoReilly

[3] Manoj Kumar Anand Rangachari Anant Jhingran Rakesh Mohan 1998 Sales Promitions on the Internet h ttpwwwibmcomiactech-paperhtml

[4] Manoj Kumar Stuart I Feldman 1998 Business Negotiations on the Internet httpwwwibmcomiactech-paperhtml

[5] Manoj Kumar Stuart I Feldman 1998 Internet Auction httpwwwibmcomiactech-paperhtml

[6] Shiwa Fu Jen-Yao Chung Walter Dietrich Vibby Gottemukkala Mitchell Cohen Shyhkwei Chen 1999 A Practical Approach to Web-Based Internet EDI httpwwwibmcomiacpapersicdcsws99indexhtml

[7] Zhong Tian Leo Y Liu Jing Li Jen-Yao Chung Vibby Guttemukkala 1999 Business-to-Business e-Commerce with Open Buying on the Internethttpw w w ibm comi acpapersobi -paperindex html

[8] Gerald J Tesauro Jeffrey O Kephart 1998 Foresight-Based Pricing Algorithms in an Economy os Software Agents http wwwi bm comi actech - paper html

[10] Jeffrey O Kephart James E Hanson Jakka Sairamesh 1998 Price and Niche Wars in a Free-Market Economy o f Software Agents httpwwwibmcomiactech-paperhtml

[11] Jeffrey O Kephart James E Hanson David W Levine Benjamin N Grosof Jakka Sairamesh Richard B Segal Steve R White 1998 Dynamics o f an Information-filtering Economy httpwwwibmcomiactech-paperhtml

[12] James E Hanson Jeffrey O Kephart 1998 Spontaneous Specialization in a Free-Market Economy os Agents httpwwwibmcomiactech-paperhtml

[13] Jakka Sairamesh Jeffrey O Kephart 1998 Price Dynamics o f Vertically differentiated Information Markets httpwwwibmcomiactech-paperhtml

[14] David Kosiur 1997 Understanding Electronic Commerce Microsoft Press

[15] Gunther Birznieks Selena Sol 1997 CGI fo r Commerce MampT Books - A Division of MIS Pres

58

[16] Ravi Kalakota Andrew B Whinston 1997 Electronic Commerce Addison Wesley

[17] Alex Fedorov Richard Harrison Dave Sussman Brian Francis Stephen Wood 1998 Profession Active Server Page 20 Wrox Press

[18] Calvin Austin Minica Pawlan 1999 Writing Advanced Application for the Java PlatformhttpVdeveloper iavasuncomdeveloperonlineTrainingProgrammin gJDCBooki ndexhtml

59

APPENDIX B

The Source Code of An On-Line Store System - Tiny Book Store

60

1 welcomeshtml

lthtmlgtltheadgtlttitlegtSearch Tinybookstorecomlttitlegtltheadgtltbodygt

lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=eeeeccgtlttrgtlttd rowspan=2 align=left valign=top width=15 cellspacing=0 cellpadding=0xIM G border=0 hspace=0 id=IMGl src=flowergif gtlttdgtlttd rowspan=2 align=left valign=centergtltstronggtlth2gtltigtTinyBookStorecomltigtlth2gtltstrongxtdgtlt trx tab legt

lttable border=0 width=100 cellspacing=0 cellpadding=0gtlttrgtlttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtltPgt

lttable width=100 cellspacing=0 cellpadding=5 border=0gtltTRgt ltTDgt ltTDgt ltTD colspan=2gt ltFONT FACE=verdanaarialhelvetica SIZE=-1 gtampnbsp ltFONTgt ltTDgt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD co lsp an = 2 x stro n g x fo n t face=verdanaarialhelvetica size=-lgtSearch B ooksltfontxstronggt ltTDgt ltTRgtltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt ltTD x f o n t face=verdanaarialhelvetica size=-l gt

lta href=w elcom eshtm lgtH om eltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt c T D x fo n t face=verdanaarialhelvetica size=-1 gt

lt A href= servletReqC ol 1 ec tc ategory gtC ate gory ltf o n tx A x T D gtltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollectauthorgtA uthorltfontxA xTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=2gtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-1 gt

ltA href=servletReqCollecttitlengtTitleltorfo n tx A x T D gt ltTRgt

61

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectisbngtISBN ltA xfontxTD gt ltTRgt

ltTRgt ltTDgt ltTDgt ltTD width=lgtampnbspltTDgt lt T D x fo n t face=verdanaarialhelvetica size=-l gt

ltA href=servletReqCollectpublisher_dategtPublisherD a telt A x fo n tx T D gtltTRgtlt tab lex p gtlttdgt

lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgtlttd valign=top align=leftgt

ltbr clear=allgtltPgtlt h 3 x s tro n g x fo n t color=ff6347gtWelcome to theltigt T in y B o o k S to rex o m lt ix fo n tx s tro n g x h 3 gt

ltbrgtlt s tro n g x b x h 3 x c e n te rgt F iv e Hot B o o k slt cen te rx h 3 x B x s tro n g gt

ltbrgtltservlet code=EchoServetTag myArgI=myValuel myArg2=myValue2gt ltparam name=myParm 1 value=Hellogtltparam name=myParml value=Worldgtltparam name=myParm2 value=myParmValue2gtltservletgt

lt td x trgt

lttablegt

ltTABLE width=100gtltTRgt ltTD width=50 valign=top align=Ieftgt ltTDgtltTD width=50 valign=top align=rightgtltfont size=-lgtltA href=topgtTop of P ag elt A x fo n tx T D gt ltTRgt

62

ltTABLEgt

ltcentergtltfont size=-lgtltA href=indexhtml gtTinybookstorecom HomeltAgt ampnbsplampnbsp ltA href=categoryhtml gtCategoryltAgt ampnbsplampnbspltA href= author html gtAuthorltAgt ampnbsplampnbspltA href= title html gtTitleltAgt ampnbsplampnbspltA href=7isbnhtml gtISBNltAgt ampnbsplampnbspltA href=publisherhtmrgtPublisher DateltAgtltpgtltfontgtltcentergt

ltPgtltcentergtlt b rx fo n t size=-lgtltA href=copyrighthtml gtCopyright and disclaimerltAgt copy 1999-2001 Fang Xiao ltfontgtltcentergt

ltbodygtlthtmlgt

63

2 AddToShoppingCartjava

ltpgt AddToShoppingCart is the servlet that process the action of adding item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javasql import javautil import javaxservlet import javaxservlethttp

public class AddToShoppingCart extends HttpServlet

protected Connection m_con = null protected ShoppingCart m_cart protected BookDetails book

public void initQ throws ServletException try

Class forName( sunj dbc odbc JdbcOdbcDriver)m_con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintstackTrace ()catch (SQLException e)

e prints tackT race ()

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

String[] params = reqgetParameterValues(isbn)

64

String isbn = get isbn from extra path infomationif (params = null)

isbn = params [0]

Get current session object create one if necessary HttpSession session = reqgetSession(true) m_cart = (ShoppingCart)sessiongetValue(cart)

if (m_cart == null) need new cart create a shopping cart m_cart = new ShoppingCart() add to current session sessionputValue(cart m_cart)

try Statement stmt = m_concreateStatement()ResultSet rs = stmtexecuteQuery(select from book where

ISBN=rsquo + isbn + rsquo)

if (rsnext()) book = new BookDetails(rsgetObject(ISBN)toString()

rsgetObject(TitIe)toStringOrsgetObject( Author) toStringO

rsgetDouble( Price) rs getObj ect( PublicationDate) toStringO)

catch (SQLException e)

eprintStackTrace()m_cartadd(bookgetISBN() book)

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lt h tm lxheadx titlegt T inyB ookS tore com S hopping

Cartlttitlexheadgt)outprintln(ltbody bgcolor=FFFFFF lmk=003399

alink=FF9933 vlink=996633 text=000000ngt)outprintln(lta nam e= topxmdashTop of Pagemdashx a gt )

65

outprin tln(ltpxa href=httplocalhost8080checkouthtmlximg src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=cccc99 gt)ou tp rin tln (lt tdxbrx tdgt )ou tp rin tln (lt tdxbrx tdgt )o u tp rin tln (lt tdxbrx tdgt )outprintln(lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=2xfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=left valign=topxfont

face=verdanaaria lhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=cccc99gt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lt td x b rx td gt ) outprintln(lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantityQ

outprintln(lttr bgcolor=FFFFFFgt) ou tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt )outprintln(ltbrgt + item getltem() get Author()) outprintln(ltbrgtQuantity + itemgetQuantityO) outprintln( ltbrgt) outprintln(lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=POST

action=7servletDeleteFromShoppingCartitemgetItem()getISBN()gt)

66

outprintln(ltpgt cinput type=hidden name=isbn value= + itemgetItem()getISBN())

outprintln(ltpgt ltinput type=submit name=ditemvalue=deletegt)

outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelve tica color=000000gt)

outprintln(ltNOBRgtltbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fon tx bx N O B R gt ltbrgt )

outprintln(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantity() + lt fo n tx b x N O B R x b rgt )

outprintln(ltfontgt) out println( lttdgt)

out printl n( lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)out println( lt fo n tx fo n tgt )outprintln(lttdxtrgt)outprintln(lttablegt)outprin tln(ltpxa href=httplocalhost8080checkouthtmlYximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)outprintln(ltbodygt lthtmlgt)

outflush()outclose()

67

3 AuthorProcessjava

bull ltpgt AuthorProcessbull This is the servlet that process the Author-search request and generatebull search resultbull Author Fang Xiao Purpose Thesis project Copyrightcopy Fang Xiao 1999-2001

import javaxservlet import jav ax servlet http import javaio import javasql

public class AuthorProcess extends HttpServlet protected final String EXACT = ldquoexactrdquo protected final String OTHERS = ldquolastrdquo

protected Connection con = null

public void init() throws ServletException try

ClassforName(ldquosunjdbcodbcJdbcOdbcDriverrdquo)con = DriverManagergetConnection(ldquojdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(ldquotexthtmlrdquo)PrintWriter out = resgetWriterQ

68

String[] valuesString name =

values = reqgetParameterValues(ldquoauthorrdquo) if (values = null)

name = values [0]

String mode = ldquordquovalues = reqgetParameterValues(ldquoauthor_moderdquo) if (values = null)

mode = values [0]

String sqlStmt = ldquordquo if (modeequalsIgnoreCase(EXACT))

sqlStmt = ldquoselect from BOOK where author=rsquordquo + name +else

sqlStmt = ldquoselect from BOOK where author like lsquordquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

ldquoYour Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ldquoltdlgtrdquo) 11 start Glossary List

while (rsnext()) count++outprintln(ldquolt d tx b gt rdquo + count + ldquo ldquo)String isbn = rsgetObject(ldquoISBNrdquo)toString()

69

outprintln(ldquolta href=servletDetailContentrdquo + isbn+

outprintln(rsgetObject(ldquoTitlerdquo)toString() +ldquolt a x b gt rdquo)

outprintln(ldquolt n o b rx fo n t color=990033gtUsually ships in 24 h o u rslt B R x fo n tx n o b rgt rdquo)

outprintln(ldquoltddgtrdquo +rsgetObject(ldquoAuthorrdquo)toString())

outprintln(ldquo ldquo +rsgetObject(ldquoPublisherrdquo)toString() + ldquo ldquo + rsgetObject(ldquoPublicationDaterdquo)toString())

outprintln(ldquoltbrgt Our Price ldquo +rsgetObject(ldquoPrice)toString())

outprintln(ldquolt b rx b rgt rdquo)

if (count == 0) outprintln(ldquoltdtgt No matched data foundrdquo)

outprintln(ldquoltdlgtrdquo) end Glossary List

catch (SQLException e) create footer here outprintln(ldquolttdgt lttrgtrdquo) outprintln(ldquolttablegtrdquo)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(ldquolthtmlgtrdquo) outprintln(ldquoltheadgtrdquo) outprintln(ldquolttitlegt TinyBookStorecom lttitlegtrdquo) outprintln(ldquoltheadgtrdquo)

outprintln(ldquoltbodygtrdquo)

70

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspacing=0 cellpadding=0 bgcolor=rdquoEEEECCYrsquogtrdquo)

outprintln(ldquolttrgtrdquo)outprintln(ldquolttd align=left valign=top width=90 gtrdquo) outprintln(ldquoltIMG border=0 hspace=0 id=IMGl

src=rdquodJavaWebServer20public_htmlflowergifrdquogtlttdgtrdquo) outprintln (ldquolttd width=30gtlttdgtrsquorsquo) outprintln(ldquolttd align=left valign=center width=300gtrdquo)

outprintln(ldquolt stro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x s tro n g x td gt rdquo) outprintln(ldquolttd align=right valign=centergtrdquo) outprintln(ldquolttdgtrdquo) outprintln(ldquolttd w id th= 20x tdgt rdquo) out pri ntln (ldquolttrgtrsquo rsquo) outprintln(ldquolttablegtrdquo)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ldquolttable width= 100gtrdquo)outprintln(ldquolttrgt lttd width=50 valign=top align=leftgt lttdgtrdquo) outprintln(ldquolttd width=50 valign=top align=rightgtrdquo) outprintln(ldquoltfont s iz e = - lx a href=rdquotoprdquogtTop of P agelt ax fon tgt rdquo) outprintln(ldquolttrgtrdquo) outprintln(ldquolttablegtrdquo)

outprintln(ldquoltcentergtrdquo) outprintln(ldquoltfont size=-lgtrdquo) outprintln(ldquolta

href=rdquohttplocalhost 8080welcomeshtmlrdquogtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080$ervletReqCollectcategoryrdquogtCategoryltagtampnbsplampnbsprdquo)

outprintln(ldquoltahref=Yhttplocalhost8080servletReqCollectauthorrdquogtAuthorltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagt ampnbsplampnbsprdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_daterdquogtPublisheramp44Dateltagtrdquo)

outprintln(ldquoltpgtrdquo)

71

outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltpgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquolt b rx fo n t size=-lgtrdquo)outprintln(ldquoltA href=Y7copyrighthtmlrdquogtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiaordquo)outprintln(ldquoltfontgtrdquo) outprintln(ldquoltcentergtrdquo) outprintln(ldquoltbodygtrdquo) outprintln(ldquolthtmlgtrdquo)

i

protected void CreateLeftMenu(PrintWriter out) System out println(ldquoLeftMenurdquo)

outprintln(ldquolttable border=0 width=rdquo 100rdquo cellspaeing=0 cellpadding=0gtrdquo)

outprintln(ldquolttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgtrdquo)

outprintln(ldquoltpgtrdquo)

outprintln(ldquolttable width=rdquo 100rdquo cellspaeing=0 cellpadding=5border=0gtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquoltfont face=verdanaarialhelvetica SIZE=rdquo- l rdquogtampnbsp

ltfontgtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd colspan=rdquo2rdquogtrdquo) outprintln(ldquolt strongxfon t face=verdanaarialhelvetica size=rdquo-

1 rdquogtSearch B ooksltfontxstronggtrdquo)outprintln(ldquolttdgt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd ldquo) outprintln(ldquoltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080welcomeshtmlYgt H o m elt fo n tx ax td gt lttrgtrdquo)outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=rdquo-1rdquogtrdquo) outprintln(ldquolta

href=rdquohttplocalhost8080servletReqColIectcategoryrdquogt C ateg o ry lt fo n tx ax td gtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

72

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectauthorrdquogtAuthorltfontgtltagtlttdgtlttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width-2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l W rsquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollecttitlerdquogtTitleltfontgtltagtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo- l rdquogtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectisbnrdquogtISBNltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=rdquo-lYgtrdquo)

outprintln(ldquoltahref=rdquohttplocalhost8080servletReqCollectpublisher_dateVrsquogtPublisher Dateltagtltfontgtlttdgt lttrgtrdquo)

outprintln(ldquolt tab lex p gt rdquo)

outprintln(lsquolsquolttdgtrdquo)outprintln(ldquolttd rowspan=4 width=5gtampnbspampnbspltbrgtlttdgtrdquo) outprintln(ldquolttd valign=top align=leftgtrdquo) outprintln(ldquoltbr clear=allgtrdquo)

73

4 BookTeatailsjava

ltpgt This is the class describing a book item in shopping cart

Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class BookDetails private String m_isbn = null private String m_title = null private String m_author = null private double m_price = 00 private String m_year = null

public BookDetails(String isbn String title String author double price String year)

thism_isbn = isbn thism_title = title thism_author = author thism_price = price thism_year = year

public String getISBN() return m_isbn

public String getTitle() return m_title

public String getAuthor() return m_author

public double getPrice() return m_price

ipublic String getYearQ

return m_year

75

5 CategoryProcessjava

ltpgt CategoryProcess This is the servlet that process the Category-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql import javautil

public class CategoryProcess extends FlttpServlet protected final String EXACT = exactprotected final String OTF1ERS = last

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e) need do something here catch (SQLException e) need do something here

76

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentType( texthtml)Print Writer out = resgetWriterQ

String[] values String name = String sqlStmt =

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

else

path = pathsubstring(l) if (pathequalsIgnoreCase(cO 1))

sqlStmt = select from BOOK wherecategoryid=rsquo + cOl +

else if (pathequalsIgnoreCase(c02))sqlStmt = select from BOOK where

categoryid=rsquo + c02 +else if (pathequalsIgnoreCase(c03))

sqlStmt = select from BOOK wherecategoryid=rsquo + c03 +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftM enu(out)

Your Book Search Results try

77

if (con = null) Statement stmt = concreateStatement() rs = stmt executeQuery (sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn

+outprintln(rsgetObject(Title)toString() +

lt ax bgt )outprintln(ltnobrxfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltddgt +

rsgetObject( Author)toStringO)outprintln( +

rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)outprintln(ltbrgt Our Price +

rsgetObject( Price) toStringO) ltfont color=990000gtYou Save $1100

(20)ltfontgtoutprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

78

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)out println( lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20publicbdquohtmlflowergifgtlttdgt) outprintln(lttd width=3 0gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln( lt s tro n g x h 2 x igt T inyB ookS to re com lt ix h2x s tro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlngtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

79

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYrsquogtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln( ltfontgt)outprintln(ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rOwspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt)

outprintln(lttablewidth= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=Y2Ygt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y-1 Yrsquogtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2Yrsquogt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=Y-

lYrsquogtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=Y-lYgt)

80

outprintln(ltahref=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqColIectcategorygtCategoryltfontxagtlttdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(nltahref=httplocalhost8080servletReqCollectauthorVrsquogt A u th o rlt fo n tx ax td gtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httpIocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

6 CustomerlnfoProcessjava

ltpgt CustomerlnfoProcessThis servlet is responsible to process userrsquos information when heshe check out

Author Fang Xiao

Purpose Thesis projectCopyright (C) Fang Xiao 1999-2001

import javasql import javaio import j avau til import javaxservlet import javaxservlethttp

public class CustomerlnfoProcess extends HttpServlet protected Connection m_con = null protected HttpSession m_session = null protected static int m_cartID = 1 protected String firstname =protected String middleinit =protected String lastname =protected String email =protected String password =protected String creditcard =protected String cardtype =protected String cardholder =protected String expiredate =protected String shipping =protected String receiver =protected String address =protected String city =protected String state =protected String zipcode =protected String phone =

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)

82

m_con = DriverManagergetConnection(jdbcodbcfxbookstorenull null)

catch (ClassNotFoundException e)

eprintStackTrace()catch (SQLException e)

eprintStackTrace()i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

get informationString[] values = reqgetParameterValues(firstname) if (values = null)

firstname = values [0]

values = reqgetParameterValues(middleinit) if (values = null)

middleinit = values [0]

values = reqgetParameterValues(lastnameM) if (values = null)

lastname = values [0]

values = reqgetParameterValues(email) if (values = null)

email = values [0]

values = reqgetParameterValues(password) if (values = null)

password = values [0]

values = reqgetParameterValues(creditcard)

if (values = null) (creditcard = values [0]

values = reqgetParameterValues(cardtype) if (values = null)

cardtype = values [0]

values = reqgetParameterValues(cardholder) if (values = null) (

cardholder = values [0]

values = reqgetParameterValues(expiredate) if (values 1= null)

expiredate = values [0]

values = reqgetParameterValues(shippingrdquo) if (values = null)

shipping = values [0]

values = reqgetParameter Values (receiver) if (values = null)

receiver = values [0]

values = reqgetParameterValues(address) if (values = null)

address = values [0]

values = reqgetParameterValues(city) if (values = null) (

city = values [0])

values = reqgetParameterValues(state) if (values = null) (

state = values [0]

84

values = reqgetParameterValues(zipcode) if (values = null) (

zipcode = values [0]

values = reqgetParameterValues(phone) if (values = null)

phone = values[0]i

get session object m_session = reqgetSessionQ

try update databaseStatement stmt = m_concreateStatement()

String sql = select from CUSTOMERACCOUNT where Email Address=rsquo + email +

ResultSet rs = stmtexecuteQuery(sql)

if (rsnext()) Systemoutprintln(insert customeraccount)

sql = insert into CUSTOMERACCOUNT (emailaddress password firstname middleinit lastname) values ( +

+ email + + password + + firstname +V + middleinit + + lastname + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

sql = select from CREDITCARD where creditcardnumber=rsquo +creditcard +

rs = stmtexecuteQuery (sql)

if (rsnext()) Systemoutprintln(insert creditcart)

sql = insert into CREDITCARD (CreditcardNumber CreditCardtype HolderName ExpirationDate) values( +

+ creditcard + + cardtype + +cardholder + + expiredate + rdquo)

Systemoutprintln(sql)stmtexecute (sql)

i

85

sql = insert into SHOPPINGCART (ShoppingCartIDEmail Address CreditCardNumber ShippingType ReceiverName ReceiverAddress ReceiverCity ReceiverState ReceiverZipcode ReceiverPhone) values ( + m_cartID + V + email + Vrdquo +

creditcard + V + shipping + + receiver ++ address + V +

city + V + state + V + zipcode + V + phone +gt gt

Systemoutprintln(sql)stmtexecute (sql)

BookDetails book = nullShoppingCartltem bookAndQuantity = null Enumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

int aQuantity =0 String alSBN = null

while (itemshasMoreElementsO) insert into Orderltems bookAndQuantity =

(ShoppingCartItem)itemsnextElement()book = bookAndQuantitygetItem()

aQuantity = bookAndQuantitygetQuantity() alSBN - book getISBN()

Systemoutprintln(insert Orderltems)sql = insert into ORDERITEMS (shoppingCartED ISBN

quantity) values ( + m_cartID + +alSBN + + aQuantity + rsquo)

Systemoutprintln(sql)stmtexecute (sql)

im_cartID++ must increase by one

86

catch (SQLException e) eprintS tackTrace()

printOrder(out)

public void printOrder(PrintWriter out) outprintln( lthtmlgt ltheadgt lttitlegt Order List lttitlegt ltheadgt) outprintln( ltbodygt)outprintln(lthlgt Your order reads as follows lthlgt)outprintln(lttablegt)outprintln( lttrgt)outprintln( lttdgtE-Mail Addres s lttdgt) outprintln(lttdgt+ em ail+lttdxtrgt) outprintln(lttrgt) outprintln(lttdgtship tolttdgt) outprintln(lttdgt+ receiver +ltbrgt) outprintln(address +ltbrgt) outprintln(city +ltbrgt) outprintln(state +ltbrgt) outprintln(zipcode + lt b rx td x trgt ) outprintln(lttrgt) outprintln( lttdgtTel lttdgt) outprintln(lttdgt+ phone +lttdxtrgt) outprintln(lttrgt) outprintln( lttdgtItems lttdgt)

BookDetails book = nullShoppingCartltem bookAndQuantity = nullEnumeration items =

((ShoppingCart)m_sessiongetValue(cart))getItems()

double total = 00

while (itemshasMoreElements()) bookAndQuantity = (ShoppingCartItem)itemsnextElement()

total += bookAndQuantitygetItem()getPrice() bookAndQuantitygetQuantityO

book = bookAndQuantitygetltem()

87

outprintln(lttdgtTitle+ bookgetTitle() + Qty + bookAndQuantitygetQuantity() + ltbrgt)

outprintln(Price + bookgetPrice() + Subtotal + bookAndQuantitygetQuantityO bookgetPrice() +ltbrgt)

outprintln(Total + total )outprintln(lttdxtrgt)outprintln(lttablegt)outflush()outclose()

7 DeleteFromShoppingCartjava

ltpgt DeleteFromShoppingCart is the servlet that process the action of deleting item to shoppingcart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import javaio import javautil import javaxservlet imp ort j avax servlet http

public class DeleteFromShoppingCart extends HttpServlet

protected ShoppingCart m_cart protected BookDetails book

public void doPost(HttpServletRequest req FIttpServletResponse res) throws ServletException IOException res setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String[] params = reqgetParameterValues(isbnrsquo) String isbn = get isbn hidden fieldif (params = null)

isbn = params [0]

Systemoutprintlnfisbn = + isbn)

Get current session objectHttpSession session = reqgetSession()m_cart = (ShoppingCart)sessiongetValue(carf)

m_cartremove(isbn)

89

showCartContents(out)

public void showCartContents(PrintWriter out) outprintln(lthtm lgtltheadxtitlegtAm azoncom Shopping

C artlt titlexheadgt)out pri ntln ( ltb ody bgcolor=FFFFFF link=003399

alink=FF9933 vlink=Yrsquo996633Y text=rdquo000000rdquogtrdquo)outprintln(lta nam e= top xmdashTop of Pagemdashx a gt ) ou tp rin tln (lt pxa href=httplocalhost8080checkouthtmlximg

src=dJavaWebServer20servletsimageproceed-to-checkoutgifxagt)

outprintln(lttable width=100 cellpadding=0 cellspacing=0 border=0gt)

outprintln(lttr bgcolor=Yrsquocccc99Yrsquo gt)ou tp rin tln (lt tdxbrx tdgt )out pri ntln ( lt td x b r x td gt )outprintln( lt td x b r x td gt )out println (rsquo1 lttrgt)

outprintln(lttr bgcolor=cccc99gt)outprintln(lttd align=left valign=top colspan=Y2Yxfont

face=verdanaarialhelveticaxbgtShopping Cart I tem slt fo n tx b x td gt )outprintln(lttd align=YleftY valign=YtopYxfont

face=verdanaarialhelveticaxbgtPricelt fontxbxtdgt) outprintln( lttrgt)outprintln(lttr bgcolor=Ycccc99Yrsquogt) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) ou tp rin tln (lt tdxbrx tdgt ) outprintln( lttrgt)

Enumeration allltems = m_cartgetltems()ShoppingCartltem item = nullBookDetails book = null double total = 00

while (allltemshasMoreElements()) item = (ShoppingCartItem)allItemsnextElement() total += itemgetItem()getPrice() itemgetQuantity()

outprintln(lttr bgcolor=FFFFFFgt) o u tp rin tln (lt td x em x b gt + itemgetItem()getTitle() +

lt bxem gt)outprintln(ltbrgt + itemgetItem()getAuthor())

90

outprintln(ltbrgtQuantity + itemgetQuantityO)outprintln(ltbrgt)outprintln( lttdgt)

outprintln(lttd align=leftgt) outprintln(ltform method=VPOST

action=7servletDeleteFromShoppingCartVgt)outprintln(ltpgt ltinput type=hidden name=isbn value= +

itemgetItem()getISBN())outprintln(ltpgt cinput type=submit name=ditem

value=Y rsquo deletegt rsquo rsquo)outprintln(lttdgt)

outprintln(lttd bgcolor=FFFFFF x f o n t size=2 face=verdanaarialhelvetica color=000000gt)

outprintln(ltNOBRxbgtPrice ltfont color=990000gt$ + itemgetItem()getPrice() + lt fo n tx b x N O B R x b rgt )

outprintin(ltNOBRxbgtSubtotal ltfont color=990000gt$ + itemgetItem()getPrice() itemgetQuantityO + lt fo n tx b x N O B R x b rgt )

outprintln( ltfontgt) outprintln( lttdgt)

i

outprintln(lttrgt)outprintln(lttd colspan=3 align=rightgt)outprintln(ltfont face=verdanaarialhelvetica size=2xbgtTotal

ltfont color=990000gt + total + ltbgt)outprintln(ltfontxfontgt)outprintln( lt td x trgt ) outprintln(lttablegt)ou tp rin tln (lt pxa href=Yhttplocalhost8080checkouthtmlYximg

src=YdYJavaWebServer20servletsimageproceed-to-checkoutgifYxagt)outprintln(ltbodygt lthtmlgt)

outflushOoutcloseQ

91

8 Detailcontentjava

ltpgt DetailContent is the servlet responsible for generating detailed information page for a book The book is identified by its ISBN Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaio import javasql import jav ax servlet import javaxservlethttp

public class DetailContent extends FIttpServlet protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s setContentT ype( texthtml)PrintWriter out = resgetWriterQ

String isbn = reqgetPathInfo()isbn = isbnsubstring(l) skip over rsquo rsquo

92

try String sql = select from book where ISBN=rsquo + isbn +

Statement stmt = concreateStatement()ResultSet rs = stmtexecuteQuery(sql)

create header here CreateHeader(out)

create left menu here CreateLeftMenu(out)

outprintlnfctd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintlnfctd valign=top align=leftgt)

cellpadding=0gt)

outprintln(ltbrgt)

create detailcontent here while (rsnext())

String strlSBN = rsgetObject(ISBN)toString() outprintln(lttable width=100 border=0 cellspacing=0

+ltbgtlttdxtrgt)

+ lt tdx trgt)

outprintln(lttrgt lttd colspan=3 align=leftxbgt) outprintln( rsgetObject(Title)toString()

outprin tln(lt trxtd colspan=3 align= leftxbgt by ltbgt) out println( rs getObj ec t( Author) toS tringQ

cellpadding=0gt)

outprin tln(lt trx td x i m g src=xtdgt) outprintln( lttd valign=topgt) outprintln( lttable border=0 cellspacing=0

outprintln( lt t r x td valign=topxbgtPrice )outprintln(

rsgetObject(Price)toString() + lt b x td x trgt ) outprintln(

lt trx td x b gt A v ailab ility lt b gt U su a lly lt td x trx b rgt )outprintln( lt t r x td vlign=topgtships within 24

hou rs lt td x trgt )outprintln( lt tab lextdgt)

93

outprintln( lttd align=rightgt) outprintln( lttable border=0 cellspacing=0

cellpadding=0gt)outprintln( lt trx td gt )outprintln( ltform

method=POST action=httplocalhost8080servletAddToShoppingCartgt)outprintln( ltinput

type=hidden name=isbn value= + strlSBN +outprintln( cinput

type=submit value=Add to cart )outprintln( lt tdx trgt )

outprintln( lt tab lex tdgt ) outprintln(rdquolttrgt)outprintln(lttrgt lttd clospan=3 align=leftgt ISBN ) outprintln( strlSBN +lttdxtrgt)outprintln(lttrgt lttd clospan=3 align=leftgt) outprintln( rsgetObject(Publisher)toString()

+rsgetObject(PublicationDate)toString() + lt tdx trgt )outprintln(lttablegt)outprintln(ltbrgt)outprintln(ltbrgt)

output reviewString review = rsgetObject(BookReview)toString() if (review = null)

review =DJavaWebServer20servletsreview + review

outprintln(ltbgtReviewsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(review))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprin tin (thisLine) ou t println( ltpgt)

)

icatch (IOException e)

need do something here eprintstackTrace ()

94

outprintln(ltbrgt)String comment =

rsgetObject(BookComment)toString()if (comment = null) comment = DJavaWebServer20servletscomment +

commentoutprintln(ltbgtReader Commentsltbgt ltbrgt) try

BufferedReader br = newBufferedReader(new FileReader(comment))

String thisLine = null while ((thisLine = brreadLine()) = null)

outprintln(ltpgt) outprintln(thisLine) outprintln(ltpgt)

catch (IOException e)

need do something here eprintstackTrace ()

ou t pri ntln ( ltb rgt)

catch (SQLException e)

need to do something here

add table end tab outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outcloseQ

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt)

95

ou t pri ntln ( lthe adgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=YTOO cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d J avaW eb S erver 2 Opublic_htmlflo wer gif gtlttdgt) outprintln(lttd width=30gtlttdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyBookStorecomltigtlth2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln( lttd width=20gtlttdgt) out pri ntln ( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-1 gt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

96

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsptampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out prin tin ( ltcen tergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

eellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=Yhttplocalhost8080Avelcom eshtm lgtHom eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-1gt)

97

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=http7localhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref-httpIocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lVgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

98

9 EchoServlettagjava

import javaio import j avasql import javaxservlet import javaxservlethttp

public class EchoServletTag extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

eprintStackTrace ()catch (SQLException e)

eprintStackTrace()

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentT ype( texthtml)PrintWriter out = resgetWriter()

try Statement stmt = concreateStatementQResultSet rs = stmtexecuteQuery(select from book where title

like rsquoProgrammingrsquo)int count = 1outprintln(ltdlgt)while (rsnext() ampamp count lt 6)

outprintln(ltdtxbgt + count + )

99

String isbn = rsgetObject(ISBN)toString() outprintln(lta href=servletDetailContent + isbn + outprintln(rsgetObject(Title)toString() + lt ax bgt ) outprintln(ltddxnobrgtltfont color=990033gtUsually

ships in 24 hourslt B R xfon tx nobrgt )outprintln(ltbrgt + rs getObject( Author) toStringO) outprintln( + rsgetObject(Publisher)toStringO +

+ rsgetObject(PublicationDate)toStringO)outprintIn(ltbrgt Our Price +

rsgetObject(Price)-toStringO)

out println( lt b rx b rgt ) count++

outprintln(ltdlgt)

catch (SQLException e)

eprintStackTrace ()outprintln(lttdgt lttrgt) outprintln(lttablegt) outflush() outcloseO

ii

100

10 ISBNProcessjava

ltpgt ISBNProcess This is the servlet that process the ISBN-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javax servlet import javaxservlethttp import javaio import j a vasql

public class ISBNProcess extends HttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forN ame( sun j dbc odbc J dbcOdbcDri ver)con = DriverManagergetConnection(j dbc odbc fxbookstore

null null)catch (ClassNotFoundException e)

catch (SQLException e)

i

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException re s s e tC on te n tTy pe ( tex th tm l)PrintWriter out = resgetWriter()

String[] values

String alSBN =

values = reqgetParameterValues(isbn) if (values = null)

alSBN = values [0]

String sqlStmt = select from BOOK where ISBN= + alSBN

ResultSet rs = null int count = 0

create header here bullCreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject( IS BN) toStringO

outprintln(lta href=servletDetailContent + isbn+ gt)

outprintln(rsgetObject(Title)toStringO +lt ax bgt )

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toStringO)

outprintln( +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

102

outprintln(ltbrgt Our Price +rsgetObject(rdquoPrice) toStringO)

outprintln(ltbrxbrgt)

if (count == 0) outprintln(ltdtgt No matched data found)

outprintln(ltdlgt) end Glossary List

catch (SQLException e) create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width= 100 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src= d Uava WebS erver2 Opubhc_htmlflo wer gif gtlttdgt) outprintln(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS tore com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt)

103

out println( lttdgt) outprintln(lttd w id th= 20x tdgt ) out pri ntln( lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)out pri ntln (lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) out pri ntln ( lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsp1ampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)outprintln(ltfontgt)out println( ltcentergt)outprintln(ltpgt)outprintln(ltcentergt)outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt)outprintln(ltcentergt)outprintln(ltbodygt)outprintln(lthtmlgt)

104

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 eellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Books lt fontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocaihost8080servletReqCollectcategorygtCategoryltfontxaxtdgt lttr gt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontxaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBN ltaxfontxtdgt lttrgt)

105

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lttablegtltpgt)

o u t println( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

ii

106

11 PublisherDataProcessjava

ltpgt AuthorProcess This is the servlet that process the PublisherampDate-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import javaxservlet import javaxservlethttp import javaio import javasql

public class PublisherDateProcess extends FIttpServlet

protected Connection con = null

public void init() throws ServletException try

Class forName(sunjdbc odbc JdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstore

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException res setContentT ype ( texthtml)PrintWriter out = resgetWriterQ

String[] valuesString namel =

107

values = reqgetParameterValues(publisher) if (values = null)

nam el = values [0]

String name2 =values = reqgetParameterValues(rdquopublication_date) if (values = null)

name2 = values [0]

String sqlStmt =sqlStmt = select from BOOK where publisher=rsquo + namel + rsquoand

publicationdate=rsquo +name2

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprin tln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toStringO outprintln(lta href=servletDetailContent + isbn

+ gt)outprintln(rsgetObject(Title)toString() + (

lt ax bgt )

108

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rs getObj ect( Author) toS tring())

outprintln(V +rsgetObject(Publisher)toStringO + + rsgetObject(PublicationDate)toStringO)

outprintln(ltbrgt Our Price +rsgetObject( Price) toStringO)

outprintln( lt b rx b rgt )

if (count == 0) (outprintln(ltdtgt No matched data found)

outprintln(rdquoltdlgt) end Glossary List

catch (SQLException e) ( create footer here outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out) outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=100 cellspacing=0 celipadding=0

bgcolor=EEEECCgt)outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt)

109

outprintln(ltIMG border=0 hspace=0 id=IM Gl src=dJavaW ebServer20public_htmlflowergifxtdgt)

outprintln(lttd width=3 0 x td gt ) outprintln(lttd align=left valign=center width=300gt)

ou tp rin tln (lt strongxh2x igt T inyB ookS to re com lt ix h2x strongx tdgt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(ctable w idths 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsp lampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt) outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) ou t println( ltcentergt)

no

outprintln(ltbrxfont size=-lgt)outprintln(ltA href=copyrighthtmlgtCopyright and disclaim er^A gt

ampcopy 1999-2001 Fang Xiao)outprintln(ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) out pri ntln ( lthtml gt)

protected void CreateLeftMenu(PrintWriter out) Systemoutprintln(LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln(ltpgt)

outprintln(lttable width=100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=-1 gtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=V-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-1gt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtA uthorltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-1gt)

I l l

outprintln(ltahref=Yhttplocalhost8080servletReqCollecttitleYrsquogt T itle lt fo n tx a x td gt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(nltahref=Yhttplocalhost8080servletReqCollectisbnY gtISBNltaxfontxtdgt lttrgt)

outprindn(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdana arial helvetica size=Y -1 gt)

outprintln(ltahref=Yhttplocalhost8080servletReqCollectpublisher_dateYgtPublisher D a te lt a x fo n tx td gt lttrgt)

outprintln(lttablexpgt)

outprintln( lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

1 12

12 ReqCollectjava

ltpgt This is a servlet responsible for generating search request collection page It read extra path information from URL and then according to the extra path information it generates corresponding page format Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001import javaxservlet import javaxservlethttp import javautil import javaio

public class ReqCollect extends HttpServlet

protected final String CATEGORY = categoryrdquo protected final String AUTHOR = author protected final String TITLE = titlerdquo protected final String ISBN = isbnprotected final String PUBLISHER_DATE = publisher_date

public void service(HttpServletRequest req HttpServletResponse res) throws ServletException IOException

res setContentType( texthtml)PrintWriter out = resgetWriter()

String path = reqgetPathInfo()if (path == null) should not happen

outprintln(Check the URL to make sure it is correct)outflush()outclose()

)else

Create standard header CreateHeader(out)

Create left side menu

CreateLeftMenu(out)

path = pathsubstring(l) if (pathequalsIgnoreCase(CATEGORY))

I I Create category request collect

outprintln(ltpgt)outprintln(lth3xstronggtProgrammingltstronggtlth3gt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc01gtAlgorithmsltagt)outprintln(lta

href=httplocalhost8080servletCategoryProcessc02gtCampC++ltagt)outprintln( Delphi) outprintln(lta

href=httplocalhost8080servletCategoryProcessc03gtJavaltagt)outprintln( MFC Perl)

outprintln(software Design UML Visual Basic More)

outprintln(lth3xstronggtW eb Developm entltstrongxh3gt) outprintln(ASP Commercem Cyberculture HTML

JavaScript)

outprintln(Security Web Design XML more)

outprintln(lth3xstronggtGraphics amp Softwareltstrongxh3gt) outprintln(Asobe CAD Desktop Publishing Graphics)

outprintln(Microsoft More)

outprintln(lth3xstronggtNetW orking amp O Sltstrongxh3gt) outprintln(Linux Macs Oracle PCs SAp R3 SQL)

outprintln(TCPIP Unix WindowsampDOS W indowsNT)

out println( More)

else if (pathequalsIgnoreCase(AUTHOR))

Create author request collect

1 14

outprintln(ltfont color-CC6600 face=verdana arial helvetic a size=+1 gtltbgtEnter Authorltbgtltfontgt)

outprintln(ltbrgt You can enter authorrsquos full name firstname or last nameltpgt)

outprintln(ltform method=POST action=httplocalhost 8080servletAuthorProcessY id=form 1 name=form 1 gt)

outprintln( lttable border=0gt) outprintln(lttrgt lttd valign=middle

ahgn= leftx ttx b gt A u th o rlt b gt lt ttx td gt )outprintln(lttd valign=middle align= leftx input

type=YtextY name=author size=40 value=YYxtdgt)outprintln(lttrgt)outprintln(lttrgt lttd colspan=2gt ltfont size=-lgt) outprintln(ltcentergt ltinput type=radio

name=Yauthor_modeY value=YexactY checkedgt Exact Name)outprintln(ltinput type=radio name=author_mode

value=lastgtLast First Name (or Initial))outprintln(ltcentergt) outprintln(ltfontgt) outprintln(lttdgt lttrgt)outprintln(lttrgt lttd colspan=2gt ltpgt ltbrgt lttdgt lttrgt)outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search NowY

id=submitl name=submitlgt)outprintln(cinput type=reset value=YClear Form

id=resetl nam e= rese tlxpgt )outprintln(ltcentergt ltformgt)

else if (pathequalsIgnoreCase(TITLE))

Create title request collect

outprintln(ltfont color=CC6600 face=verdanaarialhelvetica s ize= + lxbgt E n ter T itlelt bxfontgt)lsquo

outprintln(ltbrgtYou can enter the exact title or part oftitleltPgt)

outprintln(ltform method=YPOSTY action=Yhttplocalhost8080servletTitleProcessY id=form l name=formlgt)

outprintln(lttable border=0gt) outprintln(lt trxtd valign=middle

a lig n = le ftx ttx b gt T itle lt b x t tx td gt )

115

outprintln(lttd valign=middle align= leftx input type=text name=title size=40 value=xtdgt)

outprintln(lttrgt) outprintln(lttrgt) outprintln( lttd colspan=2gt) outprintln( ltfont size=-lgt) outprintln( ltcentergt)outprintln( ltinput type=radio name=title-mode

outprintln(value=exact checkedgt) outprintln( Exact Title)outprintln( ltinput type=radio name=title-mode

outprintln( value=titlewords gt ) outprintln( Title Words )outprintln(ltcentergt ltfontgt lttdgt lttrgt)outprin tln(lt trxtd c o ls p a n = 2 x p x b r x td x tr gt ) outprintln(lttablegt)

outprintln(ltcentergt)outprintln( ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln( ltinput type=reset value=Clear Form

id=resetl nam e= resetlxP gt )outprintln(ltcentergt) ou t println ( ltformgt)

outprintln(lthr noshade size=lgt)

outprintln(ltBgtExamplesltBgt)outprintln(ltULgt)outprintln(ltLIgtEntering ltbgtampquotJava Servlet

Programmingampquotltbgt in the title field )outprintln(and choosing ltemgtExact Titleltemgt finds the

book without also finding the many books)

outprintln(ltLIgtEntering ltbgtampquotJavaampquotltbgt in the Title field and choosing ltemgtTitle Wordsltemgt)

outprintln( finds all books whose title are related toltigtJavaltigt)

outprintln(ltULgt)

out printl n( lttdgtlttrgt) outprintln(lttablegt)

ielse if (pathequalsIgnoreCase(ISBN))

Create isbn request collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n ter ISBN ltbxfontgt)outprintln(ltbrgt) outprintln(ltform method=POSTY

action=httplocalhost8080servletISBNProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

a lig n = le ftx ttx b gt IS B N lt b x t tx td gt ) outprintln(lttd valign=middle a lign= leftx input

type=text name=isbn size=40 value=xtdgt)outprintln(lttrgt)

outprin tln(lt trxtd c o ls p a n = 2 x p x b rx td x trgt ) outprintln(lttablegt)

out println( ltcentergt)outprintln(ltinput type=submit value=Search

Now id=submitl name=submitlgt)outprintln(ltinput type=reset value=Clear

FormV id=resetl nam e= resetlxP gt )outprintln(ltcentergt)outprintln(ltformgt)

outprintln(lthr noshade size=lgt)

outpiintln(ltULgtrdquo)outprintln(lttdxtrgt)outprintln(lttablegt)

else if (pathequalsIgnoreCase(PUBLISHER_DATE))

Create publisher date collect outprintln(ltfont color=CC6600

face=verdanaarialhelvetica s ize= + lx b gt E n te r Publisher and Publication D ate ltb gtltfontgt)

1 17

outprintln( ltbrgt) outprintln(ltform method=POST

action=httplocalhost8080servletPublisherDateProcess id=forml name=formlgt)outprintln(lttable border=0gt) outprintln(lttrgt) outprintln(lttd valign=middle

align=leftgtlt ttxbgt P ub lisher lt b x t t x t d gt )outprintln(lttd valign=middle align= leftx input

type=text name=publisher size=40 value=xtdgt)outprintln(lttrgt) outprintln(lttrgt lttd valign=middle

a lign= leftx ttxbgt P ub lica tion D a te lt b x ttx td gt )outprintln(lttd valign=middle align= leftx input

type=text name=publication_date size=40 value=xtdgt)outprintln(lttrgt)outprintln( c t r x td c o l s p a n = 2 x p x b r x td x t r gt )outprintln(lttablegt)outprintln(ltcentergt)outprintln(ltinput type=submit value=Search Now

id=submitl name=submitlgt)outprintln(ltinput type=reset value=VClear FormYrsquo

id=resetl nam e= resetlxpgt )outprintln(ltcentergt) outprintln(ltformgt) outprintln(lthr noshade size=lgt)

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush()outclose()

)

protected void CreateHeader(PrintWriter out) outprintln(lthtmigt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding bgcolor=EEEECCgt)

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaWebServer20pubiic_htmlflowergifgtlttdgt) outprindn(lttd w idth=30xtdgt) outprintln(lttd align=left valign=center width=300gt)

outprintln(lt s tro n g x h 2 x igt T in y B o o k S to re co m lt ix h 2 x stro n g x td gt ) outprintln(lttd align=right valign=centergt) outprintln(lttdgt)outprintln(lttd w idth=20xtdgt) ou t println ( rsquo lttrgt) outprintln(lttablegt)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width=100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln(lttrgt) outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(lta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

out pri ntln ( ltfon tgt) outpri ntln( ltcentergt ) out pri ntln ( ltpgt) outprintln(ltcentergt) outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disclaimerltAgt

ampcopy 1999-2001 Fang Xiao)out pri ntln ( ltf on tgt) outprintln(irltcentergt) out println ( ltbodygt) out pri ntln( lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) outprintln(lttable border=0 width=100 cellspacing=0

cellpadding=0gt)outprintln(lttrgt lttd valign=top width=155 rowspan=3

bgcolor=eeeeccgt)outprintln(ltpgt)

outprintln(lttable width=YT00 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE= -lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

1 gtS earch B ookslt fontx stronggt)outprintln(lttdgt lttrgt)out pri ntln (lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttd gt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=l-lgt)

outpri ntln(ltahref=httplocalhost8080servletReqCoilectauthorgtA uthorltfontxaxtdgtlttrgt)

120

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltagtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprindn(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=V-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln(lttablexpgt)outprintln(lttdgt)outprintln(lttd rowspan=4 width=5gtamp nbspamp nbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

121

13 ShoppingCartjava

ltpgt This is the definition for ShoppingCart Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

import Javautil

public class ShoppingCart Hashtable items = null int numberOfltems = 0

public ShoppingCart() items = new Hashtable()

add BookDetails to cart param bookID isbn param book book need to be added to cart copyreturn void

public void add(String bookld BookDetails book) if(itemscontainsKey(bookId))

ShoppingCartltem scitem = (ShoppingCartltem)itemsget(bookld) scitemincrementQuantity ()

else ShoppingCartltem newltem = new ShoppingCartltem(book) itemsput(bookId newltem)

numberOftems++

param bookld isbn

public void remove(String bookld) if(itemscontainsKey(bookd))

items remove (bookld) numberOfltems - -

public Enumeration getltems() return itemselements()

protected void finalize() throws Throwable items clear()

public int getNumberOfItems() return numberOfltems

public void clear() items clear() numberOfltems = 0

123

14 ShoppingCartltemjava

ltpgt This is the definition for the shoppingcart item Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999 - 2001

public class ShoppingCartltem BookDetails item int quantity

public ShoppingCartItem(BookDetails anltem) this item = anltem this quantity = 1

public void decrementQuantity() if (quantity gt 0)

quantitymdash

public void incrementQuantity() thisquantity++

i

public BookDetails getltem() return thisitem

public int getQuantity() ( return thisquantity

i

124

15 StandardFooterjava

package servlets

import j avax servlet

ltpgt This is a server side include servlet that will format the TinyBookStore HTML footer

public class StandardFooter extends GenericServlet

ltpgtPerform the servlet service

param req The request from the client param res The response from the servlet public void service (ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the response javaioPrintW riter out = new

javaioPrintWriter(resgetOutputStream())

Format the standard footeroutprintln(ctable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(lttd width=50 valign=top align=rightgt) outprintln(rdquoltfont s iz e = - lx a href=topgtTop of

P agelt ax fon tgt )outprintln(lttrgt) out println( lttablegt) outprintln(ltcentergt) outprintln(rsquoltfont size=-lgt)outprintln(lta href=7welcomeshtmlYgtTinybookstorecom

Homeltagt ampnbsplampnbsp)outprintln(lta href=categoryhtmlgtCategoryltagt

ampnbsplampnbsp)outprintln(lta href-authorhtmlgtAuthorltagt

ampnbsplampnbsp)outprintln(lta href=titlehtmlrdquogtTitleltagt ampnbsplampnbsp)

125

outprintln(lta href=isbnhtmlgtISBNltagt ampnbsplampnbsp) outprintln(lta href=7publisherhtmlgtPublisheramp44

Dateltagt)outprintln(ltpgt)outprintln(ltfontgt)ou t println ( ltcen tergt)outprintln(ltpgt)out println (ltcentergt )outprintln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and

disclaim er^A gt ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln( ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

outflush()outclose()

126

16 StandardHeaderjava

package servlets

import javaxservlet

ltpgt This is a server side include servlet that will format the standard TinyBookStore HTML header The Title of the page will be set to the value of the title property

public class StandardHeader extends Generic Servlet

ltpgt Performs the servlet service param req The request from the client param res The response from the servlet

public void service(ServletRequest req ServletResponse res)

throws ServletException javaioIOException Create a PrintWriter to write the responsejavaioPrintWriter out = new javaioPrintWriter(resgetOutputStream())

Get the title of the page Set to empty string if no title parameter was givenString titles[] = reqgetParameterValues(title)String title = if (titles = null)

if (titleslength gt 0) title = titles [0]

outprintln(lthtmlgt) outprintln(ltheadgt) outprintln(lttitlegt + title + lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)outprintln(lttable border=0 width=T00 cellspacing=0 cellpadding=0

bgcolor=EEEECCgt)

127

outprintln(lttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IM Gl

src=dJavaWebS erver2 Opublic_htmlflower gi A gtlttdgt) out println(lttd width=3 O x td gt ) outprintln(lttd align=left valign=center width=300gt)

outprintln(ltstrongxh2gtltigtTinyB ookStorecom ltigtlth2xstrongxtdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) out printl n ( lttd width=20gtlttdgt) out printl n( lttrgt) outprintln(lttablegt)

outflush()outclose()

128

17 TitleProcessjava

ltpgt TltleProcess This is the servlet that process the Tltle-search request and generate search result Author Fang Xiao Purpose Thesis project Copyright (C) Fang Xiao 1999-2001

import j avax servlet import javaxservlethttp import javaio import j avasql

public class TitleProcess extends HttpServlet protected final String EXACT = exact protected final String OTFIERS = titleWords

protected Connection con = null

public void init() throws ServletException try

ClassforName(sunjdbcodbcJdbcOdbcDriver)con = DriverManagergetConnection(jdbcodbcfxbookstorerdquo

null null)catch (ClassNotFoundException e)

icatch (SQLException e)

public void doPost(HttpServletRequest req HttpServletResponse res) throws ServletException IOException ressetContentType(texthtml)PrintWriter out = resgetWriter()

129

String[] valuesString name =

values = reqgetParameterValues(title) if (values = null)

name = values [0]

String mode =values = reqgetParameterValues(title_mode) if (values = null)

mode = values [0]

String sqlStmt =if (modeequalsIgnoreCase(EXACT))

sqlStmt = select from BOOK where title=rdquo + name +else

sqlStmt = select from BOOK where title like rsquo + name +

ResultSet rs = null int count = 0

create header here CreateHeader(out)

Create left side menu CreateLeftMenu(out)

Your Book Search Results try

if (con = null) Statement stmt = concreateStatement() rs = stmtexecuteQuery(sqlStmt)

outprintln(ltdlgt) start Glossary List

while (rsnext()) count++outprintln(ltdtxbgt + count + )String isbn = rsgetObject(ISBN)toString()

130

outprintln(lta href=servletDetailContent + isbn+

outprintln(rsgetObject(Title)toString() +ltagtltbgt)

outprintln(ltnobrxfont color=990033gtUsually ships in 24 hourslt B R xfon tx nobrgt )

outprintln(ltddgt +rsgetObject( Author)toString())

outprintln( +rsgetObject(Publisher)toString() + + rsgetObject(PublicationDate)toString())

outprintln(ltbrgt Our Price +rsgetObject(Price)toString())

outprintln(ltbrxbrgt)i

if (count == 0) outprintln(ltdtgt No matched data found)

ioutprintln(ltdlgt) II end Glossary List

catch (SQLException e) i create footer here

outprintln(lttdgt lttrgt) outprintln(lttablegt)

Create standard footer CreateFooter(out)

outflush() outclose()

protected void CreateHeader(PrintWriter out) outprintln(lthtmlgt) outprintln(ltheadgt)outprintln(lttitlegt TinyBookStorecom lttitlegt) outprintln(ltheadgt)

outprintln(ltbodygt)

131

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0 bgcolor=EEEECCgt)

outprintln(rdquolttrgt)outprintln(lttd align=left valign=top width=90 gt) outprintln(ltIMG border=0 hspace=0 id=IMGl

src=dJavaW ebServer20public_htmlflowergifxtdgt) outprintln(lttd w idth=30xtdgt) outprintln(rdquolttd align=left valign=center width=300gt)

outprintln(ltstronggtlth2gtltigtTinyBookStorecomltixh2gtltstronggtlttdgt) outprintln(lttd align=right valign=centergt) outprintln( lttdgt) outprintln(lttd w idth=20xtdgt) outprintln(lttrgt) outprintln(lttablegt)

)

protected void CreateFooter(PrintWriter out) Create StandardFooter outprintln(lttable width= 100gt)outprintln(lttrgt lttd width=50 valign=top align=leftgt lttdgt) outprintln(rdquolttd width=50 valign=top align=rightgt) outprintln(ltfont s iz e = - lx a href=topgtTop of Pageltaxfontgt) outprintln( lttrgt)outprintln(lttablegt)

outprintln(ltcentergt) outprintln(ltfont size=-lgt) outprintln(rdquolta

href=httplocalhost8080welcomeshtmlgtTinybookstorecom Homeltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectcategorygtCategoryltagtampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltagt ampnbsplampnbsp)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltagt ampnbsplampnbsprdquo)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagt ampnbsplampnbsp)

outprintln(rdquoltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisheramp44Dateltagt)

outprintln(ltpgt)

132

out println( ltfontgt) outprintln(ltcentergt) outprintln(ltpgt) outprintln( ltcentergt) outprin tln(ltbrxfont size=-lgt)outprintln(ltA href=7copyrighthtmlgtCopyright and disciaimerltAgt

ampcopy 1999-2001 Fang Xiao)outprintln( ltfontgt) outprintln(ltcentergt) outprintln(ltbodygt) outprintln(lthtmlgt)

protected void CreateLeftMenu(PrintWriter out) S y s te m out println( LeftMenu)

outprintln(lttable border=0 width=100 cellspacing=0 cellpadding=0gt)

outprintln(lttrgt lttd valign=top width=155 rowspan=3 bgcolor=eeeeccgt)

outprintln( ltpgt )

outprintln(lttable width= 100 cellspacing=0 cellpadding=5border=0gt)

outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltfont face=verdanaarialhelvetica SIZE=Y- lgtampnbsp

ltfontgt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd colspan=2gt) outprintln(ltstrongxfont face=verdanaarialhelvetica size=-

lgtSearch Booksltfontxstronggt)outprintln(lttdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt) outprintln(ltfont face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost 8080w elcom eshtm lgtH om eltfontxaxtdgt lttrgt)outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont

face=verdanaarialhelvetica size=-lgt) outprintln(lta

href=httplocalhost8080servletReqCollectcategorygtCategoryltfontxaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

133

outprintln(ltahref=httplocalhost8080servletReqCollectauthorgtAuthorltfontgtltaxtdgtlttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=2gtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollecttitlegtTitleltfontgtltaxtdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectisbngtISBNltagtltfontgtlttdgt lttrgt)

outprintln(lttrgt lttdgt lttdgt lttd width=lgtampnbsplttdgt lttdgt ltfont face=verdanaarialhelvetica size=-lgt)

outprintln(ltahref=httplocalhost8080servletReqCollectpublisher_dategtPublisher Dateltagtltfontgtlttdgt lttrgt)

outprintln( lt tab lex pgt )

ou t pri ntl n ( lttdgt)outprintln(lttd rowspan=4 width=5gtampnbspampnbspltbrxtdgt) outprintln(lttd valign=top align=leftgt) outprintln(ltbr clear=allgt)

134

18 checkouthtml

lthtmlgtltheadgt lttitlegtCustomer Informationlttitlegt ltheadgtltbodygt

lt hlgt ltcentergt ltbgt Customer Information ltbgt ltcentergt lt hlgt

ltform method=POST action=httplocalhost8080servletCustomerInfoProcessgt lttable border=0gt

lttrgtlttd align=rightgtFirst namelttdgtlttd colspan=2 align= leftx input type=text name=firstname size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtMiddle initiallttdgtlttd colspan=2 align= leftx input type-text name=middleinit s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtLast namelttdgtlttd colspan=2 align= leftx input type-text name=lastname size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtEmail addresslttdgtlttd colspan=2 align= leftx input type=text name=email s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgt Account pass word lttdgtlttd colspan=2 align= leftx input type=text name=password s ize= 40x tdgt

lttrgtlttrgt

lthrgtlttrgt

lttablegtltbrgt

ctable border=0gtlttrgt

lttd align=rightgtCredit card numberlttdgtlttd colspan=2 align= leftx input type=text name=creditcard s ize= 40x tdgt

lttrgtlttr valign=topgt

135

lttd align=rightgtCredit card typelttdgtlttd align=leftgtltinput type=radio name=cardtype value=visagtVisaltbrgtltinput type=radio name=cardtype value= mastercard gtMasterCardltbrgt lttdgtlttd align=leftgtltinput type=radio name=cardtype value=bluebirdgtBluebirdltbrgtltinput type=radio name=cardtype value=fishergtFisherltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtCredit card holderlttdgtlttd colspan=2 a lign= leftx input type=text name=cardholder s ize= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCredit card expire date (mmddyy)lttdgtlttd colspan=2 align= leftx inpu t type=text name=expiredate size= 40x tdgt

lttrgtlt trx trgtlt trx trgtlttr valign=topgt

lttd align=rightgtSelect shipping methodlttdgtlttd align=leftgtltinput type=radio name=shipping value=upsgtUPSltbrgtltinput type=radio name=shipping value=expressgtExpressltbrgtlttdgtlttd align=leftgtcinput type=radio name=shipping value=normalgtNormalltbrgtltinput type=radio name=shipping value=abnormalgtAbnormalltbrgtlttdgt

lttrgtlttrgt

lttd align=rightgtReceiver Namelttdgtlttd col span=2 a lign= leftx inpu t type=text name=receiver size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtAddresslttdgtlttd colspan=2 align= leftx input type=text name=address size= 4 0 x td gt

lttrgtlttrgt

lttd align=rightgtCitylttdgtlttd colspan=2 align= leftx inpu t type=text name=city size= 4 0 x td gt

lttrgtlttrgt

136

lttd align=rightgtStatelttdgtlttd colspan=2 align= leftx inpu t type=text name=state s ize= 40x tdgt

lttrgtlttrgt

lttd align=rightgtZipcodelttdgtlttd colspan=2 align= leftx inpu t type=text name=zipcode size= 40x tdgt

lttrgtlttrgt

lttd align=rightgtPhonelttdgtlttd colspan=2 align= leftx input type=text name=phone size= 40x tdgt

lttrgtlttablegtlt b rx b rgtcinput type=submit value=Process name=actiongt

ltformgt

ltbodygtlthtmlgt

137

APPENDIX C

Screen Display of the Test

138

mmm File Edit View Favorites T o d s Help

^ Jit j j ^ LJ U 3) ~ pound=J _Am Back - S top Refresh Home j Search Favorites History Mait Print Edit

Links gtgt Address |4S ] httDVIocalhost808QAvdcorne shtml

TinyBookStore com

Welcome to the TJnyBoakStoro com

F i v e H o t B o o k s

1 T h e C + + Programming LanguageU s u a l l y s h i p s i n 24 h o u r s

B j a r n e S t r o u s t r u p A d d i s o n - W e s l e y Pub Co 1997 Our P r i c e 31 47

2 - P r o g r a m m i n g V i s u a l C + +U s u a l l y s h i p s i n 24 h ou r I I

Local intranet

Search BooksHorne

Category

Author

Title

ISBNPublisherDate

3 iigt60

3 1 S earch T inybooksloiecom - Microsoft Internet Explorer

139

T inyB ookStorecom - Microsoft Internet Explorer

j File Edit View Favorites lo o k Help

q a a H 3 1 d B ack S top R efresh Home S earch Favorite History j M aJ Print

Links gtgt A ddress httpV localhost 308QoryleV PetailCorterV 020i8SC l4

MM

Edit

Search Books

Home

Category

Author

Title

ISBN

PublisherDate

TinyBookStore com

The C++ Programming Languageby B j a r n e S t r o u s t r u p

0

ISBN 0 2 0 1 8 8 9 5 4 4 A d d i s o n - W e s 1e y P ub Co 199 7

Reviews

P r i c e 31 47A v a i 1ab i 1i t y U s u a l 1 ys h i p s w i t h i n 24h o u r s

Aic t o c a r t

ijgJ Local intranet

140

^ | I myBook5torecom Shopping Cart - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

[v] I ^ -J JB ack - Stop R efresh Home S earch Favorites History lsquo Mail Print

Links A ddress 0 1 h ttp localhost8080servetA ddT oShoppingCart ~3 ltGdeg

Shopping Cart Item s Price

The C++ Programmi ng LanguageB j a r n e S t r o u s t r u p Q u a n t i 1 7 1

Price $ 3 1 4 7 Subtotal $ 3 1 4 7

d e l e t e

Total 31 47

Customer Information Microsoft Internet Explorer

File Edit View Favorites lo o ls Help bull _

bullgt 3i 4 n j j d a 31Back ~-j Stop- R efresh Home S earch Favorites History j Mail Print Edit

Link gtgt j Address ] j j h ttplocalhost SOSOcheekoot html

EMH1

~3

Customer Information

First name jFang

Middle initial |a

Last name Xiao

Email address fxiaomitecnet

Account password pooooc

0 1 Done

Credit card number 1234567891234567

Credit card type VisaC MasterCard

C Bluebir d C Fisher

Credit card holder jr ong Xiao

ard expire date (mmddyy) J010102

Select shipping method UPSO Express

O Normal C Abnormal

J |sect Local intranet

141

lt2] Order List - Microsoft Internet ExplorerFile |d i t View Fayotites lo o t Help

^ 3 ^ S i l S - j S tep R efresh Home Search Favorite History Mail Print h-

HFte-LLinks A ddress I g ] httplocalhost8030servletCustemeilrifoProcess 3 ^Go

Your order reads as followsE - M a i l A d d r e s s f x i a o

F a n g X i a o

ship to

T e l

11 e m s

pound] Pc

10821 W e s t e r n P l a z aOmahaME6 8 1 5 4

( 4 0 2 ) 4 9 6 - 7 5 7 0T i t l e T h e C++ P r o g r a m m i n g L a n g u a g e Q t y 1 P r i c e 31 47 S u b t o t a l 31 47

| a [ Local intianet rsquo

l i

T inyB ookSloiecom - Microsoft Internet Explorer

T 7 ~ J iii 4 a i t Vi 1+ a Si

5 E

P r i te i+ A d d ie r I ig l httplocalhot8080ervletReqCollectauthor

S e a r c h B o o k s

Horne

Ca t e g o r y

A u th o r

Title

ISBN

P ublishe r Date

jS 1 D one

TinyBookStore com

fc t i t e r l i t n o rYou can enter authors full name first name or last name

A u t h o r |sCOtt

O ExactName amp Last F irst Name (or Initial)

T itiv b o o k s to re c o m H o a e | C a te g o ry | A u th o r | T itle | ISBN | P u b lish e r D ate

C opyright and disclaim ercopy 1999-2001 F an g Xiao

T op o f P f

|sect g j Local intranet

142

linyBookStore^com- MiciosoFUnteinet ExplorerFite Edit View Favorites Tools Ftelp

IIl4 rsquojO IjjlI - 3 -Upraquo 8 a c k ltbullltbullbullltlaquo Stop R efresh Home S earch Favorites History Mail Print 1

| Links 1 Address j raquo 3 http7localhost8CI80servletAuthorProcess

l - i f l |x |

S e a r c h B o o k s

Home

C a t e g o r y

Ti t le

ISBN

P ublishe r D a te

D o n e-

TinyB o okStore com

1- Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

I G aleampory I A utho t | I jt te | ISBN | PubH shei^D atg

i t and disclaim erreg 1999-2001 F ang Xiao

Top of

l i Local intranet

j T iny8ookStorecom - M icrosoft Internet Explorer

Fite Edit View Favorites Tools Help

4- 5 ni M m ~ltpound C r =gt 2f|L i p | | | | | iAdiiill|^Thttp7localhost8080seivletD etailContent0201924889

U 3

S e a r c h B o o k s

H ome

C a t e g o r y

A u th o r

Title

ISBN

P u b lish e r P a te

TinyB o okStore com

Effective C++b y Scott Meyers

ISBN 0201924889 Addison-Wesley Pub Co 1995

R eviews

This is the review of Effective C++

R eader Comments

Price 3795 Availability U sually ships within 24 hours

Add to iosil

IIH LdcSiiihttahdt

143

l inyBookStorecom Shopping Cart - Microsoft Internet Explorer

4- -- _ t lS M JJ ltpound I 7 r mdash2--I or- Stop R efiesh Home S ea rch Favorites History Wait PrintBach

Links Y 1^ddtessj-^1 httDvVlocalliostiBOBOyservletMddToShoppinqCart 73 ^

0

Shopping Cart Item s

Effective C + +Scott Meyers Quantity 1

0 1 Done

delete

Price

Price $ 3 7 9 5 Su b to ta l $ 3 7 9 5

Total 3 7 9 5

IB~ht Locai intranet

bull 3 TinyBooKGIoFooom M icrosoft Internet Cxplorcr

Fite Edit View Favorites Tools Help

4- -4gt Lfl 4 r amp J J lt$ i icirsquo s J ~lAB ack Ti(^poundprV aTdV iS^Stop-T SfSjefre^ptr I i - M t s s j r y rvlih- i JPopSnr -JE

i i i l l l P I I I ^ I i l l ] httplocalhost8080servletR eqC ollectauthor

G3SJ

7 ^ Go

S e a r c h B o o k s

H om e

C a t e g o ry

A u th o r

Title

ISBN

Eytoiisiier Date

101 D one

T i n y B o o k S t o r e c o m

E n te r AuthorYou can enter authors full name first narne or last name

A u t h o r jCraig Larmen

E Exact N ante O Last F irst N ame (or Initial)

Search Now 1 Clear Form

I C ategory | A u th o r | j j t l s | ISBN |

C opyright and ctiiclali[er copy 1999-2001 F an g Xiao

T o p o fP ag e

^tDpcafihttangfe-

144

gj TinyBbokSlorecom - Microsoft Internet ExplorerFile Edit View F a v o n te s - Pools

4-1 4 gt_poundj Q Jl3S top R efresh Home S ea rch Favorites History Mail PrintCacl-

lsquo Unko A ddress j ig ] httplocalhostSOSCiservletAuthorProces 71

S e a r c h B o o k s

Home

C a t e o o r v

A u th o r

Tit le

ISBN

P ub l i she r D a t e

Titty Bo okStore com

1 Applying UM L and Pattern Usually ships in 24 hours Craig Larmen Prentice Hall 1997 Our Price 450

T im booksto re com Home | C ateg o ry | A u th o r | Title | I3BM | Publisher P a ts

C opyrigh t and disclaimer copy 1999-2001 F an g X iao IIg ] http7localhost 8080eopyright html Local intranet

7 j T inyBookStorecom - Microsoft Internet Explorer

^ 03 4 31 0 i -_r _j _T B ack ~j~ S top R efresh Hom e Search Favorites History Mail Print Edit

I Links Addiess AocalhcistiiiOciOserv-letCctailConfent0137488S07

u m m

S e a r c h B o o k s

HorneC a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r Date

Tiny Bo okStore com

Applying LOVIL and Patternby Craig Larmen

0 Price 450 Availability TJ sually ships within 24 hours

ISBN 013748880 Prentice Halil 997

R ev iew s

Tins is the review o f Applying UML and Pattern

R ea d er Com ments

Add to cart

01ll iPdSSIihirSdety

145

3 TinyBookStorecom Shopping Cart bull Microsoft internet ExplorerFile Edit View Favorites Tools Help

vJBeck

JStop Refresh

4Home

H Si - iS- -=dSearch Favorites History Mail Pnnt

Links rdquo Address jlti] httpVlocalhostBOSOservletAddToShoppingCart 3 ^ Gc

r o 1

Shopping Cirt J toms Price

A pplying UML and PatternCraig Larmen Quantity 1 Effective C++Scott Meyers Quantity 1

l i l le t e

delete

Price $ 4 5 0 Subtotal $45 0

Price $ 3 7 9 5 Subtotal $ 3 7 9 5

Total 82 95

d f g a j Local intranet

146

lt3 TinyBookStoiecom - Microsoft Internet ExplorerFile Edit View Favorites Io o ls Help

gt j i 4 a - a i [j JB ack Forward Stop Refresh Home S earch Favorites Histeiy Mail Print Edit

Links Address ] pound ] hiipVonahost803CeerveirsquoReqColectlsquoauthor

0 1 i

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b l i s h e r D a te

Tiny Bo okStore com

You can enter authors full name first name or last name

A u t h o r jJeff

O Exact N ame Last First N ame (or Initial)

Search Now i Clear Form

T inybookstorecotti H oinf | Category | A trthor | Title j ISBN | Publisher Date

Copyright and disclaimer copy 1999-2001 Fang Xiao

Top of Page

M Local intraZl

m TinyBook Stote com - Microsoft Internet Explorer

Fife Edit View Favorites Joo ls Help

ISregBack Stop Refresh Home S earch Favorites History Marl Print c

Lirrks Address samp] httplocalhost8080servletAuthorProcess ~z ^ Gc

S e a r c h B o o k s

H ome

CategoryA u th o r

Title

ISBN

P u b lishe r D a te

i M

TinyBookStore com

1 Progi aimning Windows bullwith M FC Usually slaps in 24 hours JeffProsise Microsoft P ress 1999 Our Price 4799

jnybo-okstorscom Homo | Category | A u th or | Title | ISBN | Publisher P a h

C opyright and disclaijRief copy 1999-liOO1 FangX iao

Loccii intranet

147

148

m I myUookSlorecom - Microsoft Internet ExplorerFile- pound d it View Favorite T ools Help

^ J ] 4 U J j j =jgt Stop R efresh Home S e a rc h Favorites History i Mail Print EditBack

Links AddressilaquojigThttplocalhost5 i380ser4eM D etailContent157231 pound350

rfgKxi

ldquo3 gt6deg

S e a r c h B o o k s

HorneC a teg o ry

A u th o r

Ti tle

ISBN

P ub l i she r D a t e

TinyBookStorecom

Programming Windows with M FCby JeffProsise

0

ISB N 1572316950 Micro s oft Pre s s 19 9 9

Price 4799 Availability Usually ships within 24 hours

R e N ew s

This is the review of Programming Windows with MFC

R eader Comments

A dd to cart

D one i jh j Local intranet

lt 3 TjryBook S tore com Shop p in g Cart - M icrosoft Internet Exolorer

File Edit View f a nute T ools Help

r 1B ack

J 3 Q 0J amp poundlr - Jlilip isS h lA ld rS s httpy |ocalhost8U 80AervletA ddToShoppingCait TSIIlli

Shopping Cart Item s

Program m ing W indow s w ith M F CJeffProsise Quantity 1A pplying UML a n d PatternCraig Larmen Quantity 1 E ffective C++Scott Meyers Quantity 1

d e le te

d elete

d elete

Price

Price $ 4 7 9 9 S u b to ta l $ 4 7 9 9

P rice $ 4 5 0 S u b to ta l $ 4 5 0

Price $ 3 7 9 5 S u b to ta l $ 3 7 9 5

Total 1 3 0 9 4

^ h W h e iM

S s i Local intranet

149

File Edit View Favorites lo o ls Help n4- -0 iS - M L U

Back Stop Refresh Home Search FavoritesJ

History I3 H H H B H H H BMail Pm Edit

Links rdquo Addrecs |s] hHplocalhogt5t8080servletReqCollectcategorii ^_____ bulllt bullbull llilltllll

Search Books

Home

Category

Author

Title

ISBNPublisherDate

TinyBookStore com

P r o g r a m m in g

AI g o r i t Lins CampC++ D e l p h i J a v a MFC P e r l s o f t w a r e D e s i g n UML V i s u a l B a s i c M o r e

Done

Web D e v e lo p m e n t

ASP Commercem C y b e r c u l t u r e HTML J a v a S c r i p t S e c u r i t y Web D e s ig n XML more

G r a p h i c s amp S o f t w a r e

Asobe CAD D es k t op P u b l i s h i n g G r a p h i c s M i c r o s o f t More

I J J ig Local intranet

150

finvBookStorecom - Microsoil Internet Explorer - j g j x

j Fite Edit Jfiew Favorites lo o ts Help

bull j 5 a i B ack lsquolti S top Refresh Home S e a tc h Favorites History Mail Print Edit

Links 1 Address |ltg] hitpVocalhostl-i030seryletCateciofyPreceigtVc03 ^ | g

S e a r c h B o o k s

Home CategoQ

A u th o r

Title

ISBN

Publishe r D a te

TinyBookStore com

1 Core Ja v a 2 Usually ships in 24 hoursCay S Horstmaun Prentice Hall 1999 Our Price 2579

2 Ja v a S erv let Programm itig Usually ships in 24 hoursJason Hunter i O Reilly 1993 Our Price 1977

3 Ju st J a v a 2 Usually ships in 24 hoursPerter van der Linden Prentice Hall 1999 Our Price 3149

Tinybookstorecom Home | C ategory | A u th o r | T itle | IbBN | Publisher D ateloRoIEage

n g Local intranet

ta

151

41 Tinytfookbtorecom - Microsoft Internet ExplorerFile gdit y iew Favorites JLools Help

1 ^ hgt a a a amp a j ri i - 3 bull a Back Forward Stop Refresh Home S earch Favorites History Mart Print Edit

lisLinteslsii Address ji^]h ttp localhost8D 8o7serv letD etailC ontent0130319336

M i

3 f^Gc

S e a r c h B o o k s

Homec a t e g o r y

Tiny Bo okStore com

Core Java 2by Cay S Horstmaun

El

ISBN 0130819336 Prentice H alil999

Reviews

This is the review of Core Java

R eader Comments

Price 2579 Availability U sually ships within 24 hours

I Add to car

S ] Done S i Local intranet

TinyBookStorecom Shopping Cart - Microsoft Internet Explorerfel11 File Eefit View Favorite l o o k H e lp

tljH|V| 4 a 3 j 09 c T J

Stop Refresh Home S e a rc h Favorites History j Mail Print

jiiLihkIi87js ^ B ie s S ij^ ] http Z localhost8080servletiddT oShoppirigC art

B I B

3= i

Shopping Cart Item s

Core Java 2Cay S Horstmaun Quantity 1

Icopy

t i l

delete

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Total 2 5 7 9

sal Local intranet

152

a TinvBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites J o o lr Fjelp

NBack

amp Id b iStop Refresh Home

ISearch Favorifes History - Mail Print Edit

Links gty I Address [ jg l httplocalhost8080servletD etailContent156592391 x d

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

T i t le

IS B N

Publisher Date

ampJ Lrl e

Tiny Bo okStore com

J a v a S erv le t Piograitmmigby Jason Hunter

a Price 1977 Availability XT sually ships within 24 hours

ISBN 15659239 lx O Refflvl998

R e N ew s

In this brand-new third edition of Java Servlet Programming author Bjame Stroustrup the creator of Java presents the full specification for the Java language and standard library a spec that will soon become the joint ISOANSI Java standard

j ~2J Local intranetm

dH T iny8ook5torecom Shopping Cart - Microsoft Internet Explorer

File pound d t y iew Favorites Io o ls HelpB H

a $ a i a a -Stop Refresh Home S ea rch Favorites Hi lory Mjl

3- lsquonr I

| j | i | H | g i | i | i d ^ | | | | l Q httplocalhost80S0servletAddToShoppirigCart J P

m

Shopping Cart Item s

Core Java 2 Cay S Horstmaun Quantity 1Java Servlet ProgrammingJason Hunter Quantity 1

d e le te

d e le te

Price

Price $ 2 5 7 9 S u b to ta l $ 2 5 7 9

Price $ 1 9 7 7 S y b to ta l $ 1 9 7 7

Total 4 5 5 6

I O I

aiil

153

Lustomer Information - Microsoft Internet Explorerpoundite pounddit View Favorites Xoo|s Help

v- _) _ l 4 J I VB ack - Stop R efresh Home Search Favorites History Mail

Links gty] A ddress ] j i l h ttD localhost8080checkouthtm l

F -iVj ~f

l l i l i i

C u sto m er In fo rm a tio n

First name jFang

Middle initial lA

Last name fXiao

Email address jfxiao m itecnet

Account password jxxxxx

Credit card number ]1234567B91234567

Credit card type C VisaC M asterCard

C Bluebird O Fisher

Credit card holder jFang Xiao

Credit card expire date (mmddyy) jo 10102

Select shipping method c u p sC Express

NormalAbnormal

0 ] D one Local intranet

poundpound Order List - Microsoft Internet Explorer

s

Back

Li il raquo

Yiew Favorites l o o h Help

bullV Y lJ j X I T- lty S to p Refresh H o m e

amp 1 3 J - jrS earch Favorite History lt Mail Print

fcesssaampl httplocalhost8080servletCustom erlnfoProcess

Y o u r ord er reads as fo llow sE-Mail Address 6daomitecnet

Fang Xiao

ship to

Tel

Items

12345 Western PlazaOmahaNE68154(402) 123-4567

Title C ore Java 2 Qty 1 Price2579 Subtotal 2579

Tide Java Servlet ProjammingQty 1 Pnce 1977Subtotal 1977 Total4556

ffl|b ] Done kl Local intranet

154

mammmm 1

File Edit View Favorites lo o ts tieip

E=cl i u F t l H -n e -i i rdquo F j-oiilsquoiBillHistory lsquo gt1 ll Print Edit

iiiiiiiiiiiiiiiiiirsquo Links Address j-copy] http localhust 8080servletReqCollectisbn J

TinyBookStore com

Search Books

Home ISBN

Author

Title

IS B N

S e a r c h Hew C le a r Form

PubnsheuDate

Top o f PageITnjrbooksj^ore^ com Horne I C a te g o rv | ^ i t h o r | T i t Ie I ISBN | Publisher Date

- g ] http locdlho-st SOSOwelcome shtrnl

TinvBookStorecom - Microsoft Internet Exploier

poundaj Local intranetId

| File Edit View Favorites Tools Help

i -e -e u u r5_ _ _ a u ^ 4 - a a j Back Forward S top Refresh Home S earch Favorites History Hail Print Edit

Links A d d re ss ^ hitp rsquoIdcanc-stEtnSOservlltlsquoF-aqZoll-~ntispn z raquo h

TinyB o okStore com

S e a r c h B o o k s

Horne

A utho r

T itle

ISBN

P u b lish e r P a t e

fcntar ISBN

I SB H 1565922840

|sectplli||pbw||l| IliM M pifiillj

T rgU onL cirrti -nr Kini- | Cgtgpound-gg | Agithor | Title | ISBN f uhhe-rt Pete

C opyright and disclaim ercopy 1999-2001 F ang Xiao

Top o f Pag e

aipoundbull] O o n e Local intranet

155

File Edit View Favorites Tools Help

HUTinyBookStorecom - MicrosoH InternetExplorer

B ad-J J A J d -2r =3

Stop R efresh Home S e a rc h Favorites History Mail Print

Links ygt A ddress j ^ ] httpVlocalhost8080servletrsquoISBM Process

S e a r c h B o o k s

Horne

C a t e g o r y

A u th o r

T itle

IS B N

Pub l i she r D a t e

TinyB o okStore com

1 Learning Perl Usually ships m 24 hours Randal L Schwartz O Reilly 1997 Our Price 1997

T in vh ooksto re c o m H orne | C at ego tv | A u th o r | Title | ISBM | Publisher D ate

C opy rig h t a n d d isclaim ercopy 1999-2001 F a n g X iao

0 ] Done

yen

ighj Local i

TinyB ookStoiecom - Microsoft Internet Explorer

Erie Edrt View Favorites- lo o ls Help

-s pound] 4 pound1 jLl icArdquo =pound 2 S top Refresh Home S earch Favorites History Marl Print Edit

iilHI

NpBack

httpyiocalhostSOBOservleMDetailContentAI 565922840 ~T] Cm

Tiny Bo okStore com

S e a r c h B o o k s

H o m e i

C a teg o ry

A u th o r

T itle

ISBN

Publishe r D a te

Learning Perlby Randal L Schwartz

I ^

ISBN 1565922840 O Reillvl997

Price 1997 Availability U sually ships within 24 hours

Reviews

This is the review of learning Perl

Reader Comments M0 ] Done lsquofR | Local intranet

156

IHHHHHI _ I f f i x |

File E d t yiew Favorites J o e ls H elp 11v- -__ l

Back ~ rc Stop R efresh Home S earch Favorites HistoryJ rMail

HH1111Pgtnt

Links A ddress | ] http7docalhost8030servleM AddToShoppingCart 3 tgt G o

O S III

Shopping Cart Item s

Learning PeriRandal L Schwartz Quantity 1

delete

Price

Price $ 1 9 9 7 Subtota l $ 1 9 9 7

Total 1 9 9 7

s

Done Local intranet

Eg W illi 1 lttMM41 i H H p n B n 1 0 1 x i

Fite Edit View Favorites Toots Help E H

1$3 L plusmn J8ack Forward Stop Refresh Home Search Favoutes

4History i

- i V -=JMail Print

-Edit

71 Address http7localhost8080lsquoservletFleqCollecVisbn I l f i l l l

TinyBookStore com

Search Books

Home

C ateao rv

Author

Title

ISBN

Publisher D a te

Enter ISSN

i s bit [l 565921496

Search Now I Clear Form

Tinybookstore o n Home | Category | A uthor | Titb | ISBN | Publisher Dte

Copyright arid disclaimer copy 1999-2001 Fang Xiao zl amp j Done Js J Local intranet I

157

H H H r f e i x i File Edit View Favorites Lools Help

- J j j j ] JBack Stop Fiefresh Home Search

J JFavorites-

-J i C rHistory Mail Print

111111811i n

r Links wj i Address |reg] http docalhost 8080servletIS8N Process

S ea rch B ooks

Home

Category-

rdquo A u th o r

T i t l e

IS B fi

P u b l i s h e r D a ta

Tiny Bo okStore com

1 Programtning Perl Usually ships in 24 hours Larry Wall O Reilly 1997 Our Price 2397

T o o k s t o r e c o m H P in e | C a t e g o r y | A u t h o r | Till | IS B N | P -ubtu-hai D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g X ia

T o p o f P a g e

zlamp2 Done Local intranet

158

lt3 l mytfookSlorecom - Microsoft Internet ExplorerF3e Edit View FavoMes lo o ts Help

Back3 U Si S rsquo IStop Refresh Home lt Search Favorites History Mail Print Edit

httplocalhost8080servletDetailContent15S5321496 j3

Search Books

Horns

Category

Author

Title

ISBN

Publisher Date

Done

TinyB o okStore com

Programming Perlby Larry Wall

0 Price 2397 Av ail ability U sually ships within 24 hours

ISBN 1565921496 O Reillyl997

Reviews

This is the review of Programming Perl

Reader Comments

Add to cart

l or=lM

159

Tm vBookSlorecom Shopping Cart - M icrosoft Internet Explorer

i Fite Edit View Favorites lo o k Help

^ Beck R efresh Home

ampS earch Favorites History j Mail Print

E Links I Address ] pound http localhost 8080servletA ddT oShoppingCart rsquo ] O rai

i O

Shopping Cart Jlems

Learning Peri Randal L Schwartz Quantity 1 Program m ing PeriLarry W all Quantity 1

delete

d e le te

Price

Price $ 1 9 9 7 S u b to ta l $ 1 9 9 7

Price $ 2 3 9 7 S u b to ta l $ 2 3 9 7

Total 4 3 9 4

3SJ Done j | s [ Local intranet

160

m m mmmHi mmmHHHHHi1 File Edit View Favorites Tools Help

^ - J J -ih Ji - j| B a d Forward Stop Refresh Home S earch FavoritesHIH ctuv Mjl Print

IHIlllliEd

B l

MbfeifcssfjP Address httplocalhost8080servletFleqCollectpLiblisher_date_ ___ ________ ___________ _ bull bull bull bull_________________ Zi T gt 6 o

S e a r c h B o o k s

Horne

C a t e g o r y

A u t h o r

Title

ISBN

Publishe r P a t e

S ] Done

TinyBo okStore com

T rsquov -

Publisher

sind IPpiIs1iclaquoifciori OsifiC

jAd cl i so n-VVe oI e y Fuo C o ~

P u b l i c a t i o n D a t e 1U97

Search Now Clear Form

T inybookstore com Home | C ategory j A u tho r j I itle | ISBN | Publisher Ds

C opyright and disclaimer copy 1999-2001 F an g Xiao

T op o f Page

g a l Local intranet

161

lt|j TinyBookStoiecom - Microsoft Internet Explorerlsquo Erie Edit View Favorites lo o ls Help

v-1 Q rij - 3 rsquo- a u -=pound Ci Back s lsquoi i 1 Stop Refresh Home S earch Favorites History Mail Print i

jL inks i A ddress 0 1 http7localhost8Q80servletPublisherDateProcess

EMM

3

S e a r c h B o o k s

Home

C a t e g o r y

Author Title

ISBN

Publisher D a te

TinyBookStore com

1- Algorithm s in C Usually ships in 24 hoursRobert Sedgewick Addison-Wesley Pub Co 1997 Our Price 4495

2 The C++ P rogr amming L anguage Usually ships in 24 hourBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

3 Effective C++ Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

4- U M L D istilled Usually ships in 24 horn sMartin Fowler Addison-Wesley Pub Co 1997 Our Price 2995

Done | s j L ocalm

TinyBookStoiecom - Microsoft Internet Explorer

Fite Edit View Favorites l o o k Help

Backamp 3 $ -Q 3 3 AJStop Refresh Home S earch Favorites History Mail Print Edit

Lipikkigt7i Ajddr$esjhttpv7localhost8080-servletDetailCoriterit0201314525

m

3 rgtGc

S earch B ooks

Horne

A uthor

Title

ISBN

Publisher D a te

Tiny BookStore com

Algorithms in Cby Robert Sedgewick

S

ISBN 0201314525 Addison-Wesley Pub Co 1995

Reviews

This is the review of Algorithms in C

Reader Comments

Price 4495 Availability U sually ships within 24 hours

Add to cart

0I reg S a i t^ s a l intranet

162

File Edit View Favorites lo o ls Help

2 ^ iVi ^ ^ t j j B ack gt Stop Refresh Home S ea rch Favorites History ||

- i -Mail Print

WB0BUBSSSI B ifl

Links ygt Addrese |isect ] httpvVlocalhostSOSChservletAddToShoppingCart

Shopping Cart Item s

A lgontfim s in CRobert Sedgewick Quantity 1

0 1 D one

delete-

Price

Price $ 4 4 9 5 Subtota l $ 4 4 9 5

Total 4 4 9 5

Local intranet

163

^ l inyBookStorecom - Microsoft Internet ExplorerFile Edit View Favorites Tools Help

ls31

3 bullrsquo -I- _J _jj - j i_ 3 - j rdquo -= $ ABack Forward Stop Refresh Home Search Favorites History Mail Print Edit

Links rdquo Address 6 J http Vlocalhost SOSOAervletR eqCollectpublisher_date j ^G

Search B o o k s

Home

categoryAutho r

Title

IS B N

Publi sher D a te

TinyBookStore com

liter Publisher and Publication Date

P u b l i s h e r Wrox Press Inc

P u b l i c a t i o n D a t e ]1

Search Now j Clear Form

T invbookstor ecotnHomg | Category | A uthor | Title | ISBN | Pu b lish e rP a t

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top of Page

zD one Local infra

m TinyB ookStoiecom - Microsoft Internet Explorer

R e Edit View Favorites Tools Help

- -i 13 4 St 2J amp t r - JHB-1

fff ij if P S | Address |sjpound~| httpVlocalhost8030servletPublisherDateProcess

S e a r c h B o o k s

Home

C a t e g o r y

A utho r

T itle

ISBN

Publisher D a te

0 ] Done

TinyBookStore com

1 Beginning Visual Basic 6 Database Programming Usually ships in 24 hour John Connell W rox Press Inc 1998 Our Price 3199

2 Befmiung Visual Basic 6 Usually ships in 24 hours Peter Wright Wrox Press Inc 1998 Our Price 3199

T inybookstore com H orae | C ategory | A u thor | Title | ISBN | Publisher Date

C opyright and disclaimer copy 1999-2001 F ang Xiao

Top o f Fas

Local intranet

64

| File Edit Yiew Favorites T ook Help

i A - + - - a S 3 rsquo reg - pound J -3 Back ldquo d Stop Refresh Home Search Favorites History

- vMail Print

i

Edit

IllplBlllll________ g - M

isisfcinbsijp Addre s | g ) httplocalhost8080servletDetailCoritent1861001061 3 Gdeg

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

T itle

ISBN

Publishe r D a te

TinyBookStore com

Beginning Visual Basic 6 Database Programmingby John Connell

a Price 3199 Availability U sually ships within 24 hours

ISBN 1861001061 Wrox Press Inc 1998

Reviews

This is the review of beginning Visual Basic 6 Database Programming

Reader Comments

A d d to c a n

S] pone Local intranet

m u i

lillllEHl ^ bdquo A 3 2tl 4 t M liJ i

Back Forward Stop Refresh Home Search Favorites3

History 4 _ r

M j 1J

Print EditiSillilillllS

httplocalhost8080servletReqCollecttitle

S e a r c h B o o k s

Home

C a t e g o r y

Author

Title

ISBN

Publisher Date

TinyB o okStore com

Enter TicleYou can enter the exact title or part of title

T i t l e C++

O Exact Title Title Words

Search Now Clear Form

Example

bull Entering Java Servlet Programming in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title are related to Java _li

165

lt5 TinyBookStorecom - Microsoft Internet ExplorerFite Edit View Favorites lo o ts Help

Back Stop Refresh Home S earch Favorites History Mail Print

Links gty Addiess http-localhost8080servlet7TitleProcess

i|p1

I

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

Publi sher IS a t e

TinyBookStore com

1 The C++ Programming L anguage Usually ships in 24 hoursBjame Stroustrup Addison-Wesley Pub Co 1997 Our Price 3147

2 Effective C+-F Usually ships in 24 hoursScott Meyers Addison-Wesley Pub Co 1997 Our Price 3795

3 Programttung Visual C-H- Usually ships in 24 hours David J Kmglinski Microsoft Press 1998 Our Price 3999

T m y h o o k s to e co m H o m e | C a te g o ry | A u th o r | T itle | ISBH | P u b lish er D ate

http iocalhost SOSOservletFleqCollectcategary

T op of P age

~hj Local intranet

bull a TlnjpBflOkStOfecom - Microsoft Internet Explorer

File Edit View Favorite Pools Help

0 3 4 S l i 3 O - J J i t of Stop Refresh Home S earch Favorites History - Mart Print Edit

HBack

i i i i lS i lB i I i f f id i l f f lH Q http Vlocalhost 8080AervletD etailContent1572318570

EEEI

J

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

Title

ISBN

P u b lis h e r D a f t

TinyBookStore com

Programming Visual C++by David J KrngHnski

[Hj

ISBN 1572318570Microsoft Press 1998

Price 3999 Availability Usually ships within 24 hours

R e v ie w s

This is the review o f Programming Visual1

Reader Comments

Add to cart

if Local intranet

166

mm| File pounddtt View Favorites Jo o ls Help

c J J j j mdash JB ack - J Stop Refresh Home S earch Favorites History

- _ i -M u

J tPrint

t e t a f e w P A ddress | ^ ] httplocalhost8080servletAddToShoppingCart zl -lt1gtSo

Shopping Cart Item s

Programmeng Visual C + +David J Kmgbnski Quantity 1

delete-

Price

Price $ 3 0 9 0 Sub to ta l $ 3 9 9 9

Total 3 0 9 9

D one ^aj Local intranet

TinyBookStorecom - Microsoft Internet Explorer

File Edit View Favorites Tools Help

vHBack-

-J a 4 -a si fi- 3 aStop R efresh Home S earch Favorites History j Mail Print- Edit

Links gty A d d re s sL ^ ] hrtpWlocalhostSOSOservleVFIeqCollectAitle

S e a r c h B o o k s

Home

C a t e g o r y

A u th o r

ISBN

Pub l i she r Date

TinyBookStore com

Enter TitleYou can enter the exact title or part of title

Title Distil I nrfExact T itle V T itle W o rd s

Search Now | Cle ar Fo rm

Examples

rpound] Done

bull Entering Java Servlet Programming11 in the title field and choosing Exact Title finds the book without also finding the many books

bull Entering Java in the Title field and choosing Title Words finds all books whose title arei date 11 j Java JZJ

167

a TlnyBA5kSioiecom - Microsoft Internet Explorergt 0e Edit ifiew Favorites Jock Jd lp

a a amp -a tii j k i Back s - Stop Refresh Home Search Favorites History Mail Print

liilP raquo httpiVlocalhostSOSOservletTitleProcess

E M 3

ldquo3 rgt-

S ea rch B ook s

Horne

C a t e d o r v

A utho r

TiUgt~ ISSN

Publi sher D a te

Tiny BookStore com

1- TJML D istilled Usually ships in 24 nowsMartin Fowler Addis on-Wesley Pub Co 1997 Our Price 2995

| C s rg g o ty | A u th o r | T itle | IStBH I P u b lis h e r D a te

C o p y rig h t a n d d isclaim er copy 1999-2001 F a n g Xiao

-jg Local intranetS3

m n ^ i l a i i x l

File Edd View Favorites Joels- Help M Mi r J lt 3 L h f 4 - 0 lt 3

Back i t Stop Refresh Home S earch Favorites History Mail9

PrintM

Edit

Links raquo A ddress j | i ] http do ca lh o d 1030N m letDetailContenr0201325632 Mimas

S e a r c h B o o k s

Home

C a t e g o r y

A u t h o r

Title

IS B N

Publisher Date

Tiny BookStore com

TJML Distilledby Martin Fowler

0

ISBN 0201325632 Addison-Weslev Pub Co 1997

Reviews

Tins is the review of The UML Distilled

Reader Comments

Price 2995 Avail abilityTJs u ally ships within 24 hours

Add to c a r t

0 3S i] Done |g^iLnealiihfrregei

TinyBookStorecom Shopping Cart Microsoft Internet ExplorerFile Edit View Favorites Jo o ls HetP

IBiiiBlll l l lHBlSglSlllllilMH MlllBliriilllgllSlIlBack - f - i - S top Refresh Home

a J i l ^ j 3 Search Favorites History 1 Mail Print liiii

3 Links ( A ddress j ig j hrtplocalhost803DservletAddToShoppingCart

Shopping Cart Herns Price

UML D istilledMartin Fowler Quantity 1Program m ing Visual C + +David J Kraglinski Quantity 1

Price $ 2 9 9 5 Subtota l $ 2 9 9 5

delete

Price $ 3 9 9 9 Subtota l $ 3 9 9 9d elete

Total 6 9 9 4

  • Electronic Commerce on Business Application
    • Recommended Citation
      • tmp1499779448pdf2JOpQ