You are on page 1of 79

A Survey and Implementation

of

e-Commerce in Supply Chain Management

by Hui-
Hui-Chun Lee

Submitted in partial fulfillment of the requirements

for the degree of Master of Science in

Computer and Information Sciences

Approved by:________________________________
Dr. C.Y. Hsieh

KNOWLEDGE SYSTEMS INSTITUTE

Skokie, Illinois, U.S.A.


ACKNOWLEDGEMENTS

I am deeply indebted to my advisor, Professor C.Y. Hsieh, for his guidance

throughout the course of my master program at KSI. His patience and technical talents

have been integral to the success of this work.

I would like to thank Dr. Shi-Kuo Chang, with his guidance I learned how web

base system works.

Thanks to Dr. Fred Thulin for correcting my thesis.

Finally, I am forever thankful to and for my parents, for their love,

encouragement, and support. I dedicate this work to them.


ABSTRACT

A SURVEY AND IMPLEMENTATION OF E-COMMERCE


IN SUPPLY CHAIN MANAGEMENT
by
Hui-Chun Lee

With the growth of the Internet, more and more companies are dedicated to e-

business. Supply chain management has been deemed as one of the useful tools for

businesses to promote their competitiveness, and to build up their trust relationship with

up and down stream businesses. In order to link the whole value chain, information

technology (IT) application has already been essential for enterprises.

This study adopts a database-oriented approach and uses a server side program,

Java Servlets, to manage a web-based inventory management system. The idea is to make

information readily and easily available to people who are interested in the data. Once a

company integrates the all-internal systems, it can further combine its up and down

stream businesses.

In conclusion, enterprises must converge enterprise resource planning (ERP),

electronic supply chain management (E-SCM), and customer relationship management

(CRM) systems to win competitive advantage. Usually, it may take couple of years to

build an integrated ERP system and E-SCM system. Information technology provides a

more efficient way to build the system.


ii
TABLE OF CONTENTS

Chapter 1 Introduction 1

1-1 Background Information. 1

1-2 Objective. 2

Chapter 2 Supply Chain Management (SCM) 3

2-1 What Is Supply Chain Management?. 3

2-2 The Early Stage of SCM. 3

2-3 The Electronic Supply Chain Management 4

2-4 Execution in E-SCM.. 6

Chapter 3 Information Technology For SCM. 9

3-1 Introduction. 9

3-2 IT Standardization.. 11

3-3 Integrating Supply Chain Information Technologies. 13

Chapter 4 Introduction to Enterprise Resource Planning Systems. 15

4-1 Introduction.... 15

4-2 Implementation of ERP.. 16

4-3 Introduction to ERP Solutions 17

Chapter 5 Strategic Alliance.. 18

5-1 What Is Strategic Alliance? 18

5-2 The Elements of Alliance Strategy. 19

iii
TABLE OF CONTENTS
(Continued)

Chapter 6 Implementation.. 22

6-1 System Design and User Interface.. 22

6-2 Detailed Descriptions.. 34

Chapter 7 Conclusions.. 39

References.. 41

Appendix A Source Code List 43

Appendix B KIS Inventory Management System.. 65

iv
LIST OF FIGURES

Figure 2-1 The Early Stage of SCM.. 4


Figure 2-2 End-to-End Integration Model. 7
Figure 3-1 Legacy System Architecture 12
Figure 3-2 Client/Server System Architecture.. 13
Figure 6-1 The Initial Web Page of Shopping Basket... 23
Figure 6-2 The Product Page of Shopping Basket 23
Figure 6-3 The Different Category Product Web Page on the Shopping Basket.. 24
Figure 6-4 The Whole Shopping Basket Web Page.. 24
Figure 6-5 The Order Form Web Page of Shopping Basket.. 25
Figure 6-6 The System Flow of Inventory Management System.. 27
Figure 6-7 The Login Web Page 28
Figure 6-8 The Main Menu Page of Inventory Management System 28
Figure 6-9 The Add Category Web Page of Inventory Management System... 29
Figure 6-10 The Confirmed Web Page of Add Category.. 29
Figure 6-11 The Deletion Web Page of Delete Category.. 30
Figure 6-12 The Confirmed Web Page of Delete Category.. 30
Figure 6-13 The Search Web Page of Modify Category 31
Figure 6-14 The Modify Web Page of Modify Category.. 31
Figure 6-15 The Show Data Web Page of Display Category 32
Figure 6-16 The Display Web Page of Display Category. 32
Figure 6-17 The Add Product Web Page of Inventory Management System 33
Figure 6-18 The Confirmed Web Page of Add Product 33

v
CHAPTER 1 INTRODUCTION

1-1 Background Information

E-commerce has been booming for a while. More and more businesses are

dedicated to World Wide Web business. However, a well designed website is not enough.

Competition is more intense in the E-commerce age. Supply chain management (SCM),

customer relationship management (CRM), and enterprise resource planning (ERP) are

important issues in this new age. And the true power of E-commerce rests in the strategy

of the so-called electronic supply chain. The relationship between a company and its

supplier has been changed since the processes of supply and demand become electronic.

Strategy alliance in the web base offers a new way to create mutual benefits among the

whole value chain.

The E-commerce business-to-business (B2B) relationship breaks the boundaries

between companies. This new cooperation model makes E-commerce become more

attractive. With advanced information technology (IT), a company can adopt a suitable

approach to link the chain. In other words, there is no best solution realizable but there is

a near optimal solution for a company to cooperate with its supplier.

To link a supply chain is complex work. Data standardization, data analysis,

information collection, and diverse system connections are significant factors in the

whole value chain. How to integrate these systems and communicate with the external

systems in other businesses is also an important issue.


1
1-2 Objective

Through the implementation of information technology, this study demonstrates

how efficiently a web-based system can perform. This study builds an online shopping

basket as the front office tool and an online inventory management system as a back

office tool. Both can speed the information flow in a supply chain and reduce the chance

of failure resulting from artificial operation. The study uses the technology of Java

Servlets to deal with the server sides work. All related data is stored in a database.

It is hoped that the prototype system can be referred to when companies would

like to build an ERP system before joining a supply chain. Not only would this reduce the

schedule time to join a supply chain but it also would lower the building cost of using

information technology in order to increase the business' competitiveness.

2
CHAPTER 2 SUPPLY CHAIN MANAGEMENT

2-1 What Is Supply Chain Management?

Supply chain management (SCM) has broad scope that includes suppliers,

manufacturers, retailers, and customers. SCM covers the management of material,

information, and cash flows. Material flow includes the movement of goods from a

supplier to a customer. Information flow involves transmitting orders and updating the

delivery reports. Cash flow consists of credit terms and payment schedules. According to

the definition used at MIT, SCM is a process-oriented, integrated approach to procuring,

producing, and delivering products and services to customers.[15]

In simple terms, SCM refers to the methods, systems, and leadership that

continuously improve an organizations integrated processes for product and service

design, sales forecasting, purchasing, inventory management, manufacturing or

production, order management, logistics, distribution, and customer satisfaction.[18]

2-2 The Early Stage of SCM

For a single product, the raw material is procured from suppliers, transformed into

finished goods from manufacturers in a single step, and then transported to retailers and

customers. The whole supply chain involves marketing, manufacturing, distribution,

planning, and purchasing activities.

3
Figure 2-1 The Early Stage of SCM

Traditionally, these activities are generated independently by different

organizations. These organizations have their own objectives and these are often

conflicting. The difficulty of these factors is that there is not a single, integrated plan for

the organization; however, there are as many plans as businesses. Clearly, there is a need

for a mechanism through which these different functions can be integrated together. SCM

is a strategy through which such integration can be achieved.

2-3 Electronic Supply Chain Management

With the quick development of E-commerce, SCM can be made more effective

through electronic means. For instance, through the website each member in the chain

can access the shared database. Suppliers and manufacturers can quickly and accurately

respond to customers needs by utilizing electronic management.


4
Technologies let participants in electronic supply chain management (E-SCM)

outsource important functions. According to David Cahn, The need for communication

and collaboration increases as more and more manufacturing is outsourced to third-party

suppliers. [16] The core of E-SCM is integration through electronic means.

In order to manage integration among various organizations in the supply chain,

the organizations have to plan large-scale enterprise applications to address collaborative

planning and execution requirements. The planning process focuses on demand

forecasting, inventory simulation, distribution, transportation, and manufacturing

planning and scheduling. The planning software is designed to improve forecast

accuracy, optimize production scheduling, reduce inventory and transportation costs, and

improve customer service. Execution processing addresses procuring, manufacturing, and

distributing products throughout the value chain. Supply chain execution applications are

designed to manage the flow of products through distribution centers and warehouses and

help ensure that products are delivered to the right location using the best transportation

alternatives available. Supply chain planning can help make better operating decisions.

E-SCM is the optimal combination of technology and business processes. E-SCM

optimizes delivery of goods, services and information from the supplier to the customer

in an organized and efficient way. For efficient chain management, E-SCM involves

many processes and procedures, such as procurement, outsourcing, and forecasting etc.

5
2-4 Execution in E-SCM

Good planning and lower inventory levels are not enough for business activities.

Supply chain execution can increase a firms competitiveness in the market. Supply chain

execution is composed of order planning, production, replenishment, and distribution.

The order planning processes involve order entry and processing, order confirmation, and

fulfillment planning. The production processes include inventory availability, priority

orders, and production scheduling. The replenishment processes involve forecasting,

aggregating inventory plan, capacity planning, and sourcing. The distribution processes

involve distribution scheduling, pick and load, scheduling home delivery, and customer

service.

6
The figure 2-2 is an example of an integration model of E-SCM. [12]

Figure 2-2 End-to-End Integration Model

E-SCM uses e-business concepts and web technologies to manage beyond the

organization upstream and downstream. Using the Internet as a universal networking

standard, business partners can create seamless, automated supply chain systems that

function as smoothly as if the organizations operated as one entity. [4] E-SCM is a

strategic approach that unites all steps in the business cycle, from initial product design

7
and the procurement of raw materials, through production, shipping, distribution, and

warehousing until a finished product is delivered to a customer.

In the chain, organizations must work together to help each other succeed. Each

node in the supply chain is a strategic link. Strong links make strong supply chains; weak

links hurt every member in the chain. Today, companies are instructed to construct ever

more efficient and responsive supply chains because it will no longer be company

competing with company, but supply chain competing against supply chain. [3]

The goals of E-SCM are as below:

Collect information on each product from production to delivery or purchase point, and

provide complete visibility for all parties.

Access any data in the system from a single-point-of-contact.

Analyze, plan activities, and make trade-offs based on information from the entire

supply chain. [19]

8
CHAPTER 3 INFORMATION TECHNOLOGY FOR SCM

3-1 Introduction

Information technology (IT) plays an important role in an efficient supply chain

management. IT brings people and information together. With the progress of networking

technology, nowadays information can be accessed in different locations. Especially

through the World Wide Web, people can easily access the abundance of data from

different locations around the world.

The primary goal of IT in the supply chain is to link the point of production with

the point of delivery or purchase. The idea is to have an information trail that follows the

products physical trail. This allows planning, tracking, and estimating lead times based

on real data. Any party that has an interest in the whereabouts of the products should be

able to have access to this information. [19]

In order to make an intelligent supply chain decision, the availability of

information regarding the status of products and material is essential. Furthermore, in

addition to tracking products across the supply chain, the system also needs to alert

diverse systems to the implications of this movement. For instance, if the delay happens

in delivery, the appropriate systems need to be notified so the organization can make the

proper adjustments by either delaying the schedules or seeking alternative sources. One

important issue here is having a single-point-of-contact. The new generation of IT can

achieve this goal.


9
For many firms, IT also provides a competitive advantage. The typical IT benefits

are as in table 3-1. [1]

Table 3-1 Typical IT Benefits

Business Process Efficiency Effectiveness Performance


Business Planning Reduced planning Increased Sales Providing space
times Minimizing and capacity for
business risk business growth
Increased business Increasing
flexibility responsiveness of
Maintaining senior management
competitive to business
capacity problems
Marketing Reduced marketing Improved company Improved strategic
costs image intelligence for
Ability to handle Generating new new markets
more enquiries business Improved public
Increased market relations targeting
share and delivery
Procurement Reduced storage Maintaining Improving external
requirements competitive access to stock
Reduced capacity levels and price
transaction times Faster response to information
and costs supplier quotations More effective
Improved delivery Ability to provide identification and
scheduling instant price assessment of new
quotations to suppliers
clients
Finance Faster invoicing Minimizing Improved/new
Reduced business risk transaction methods
transaction costs Better control of Improved
cash flow forecasting and
Reduced lead times control
for financial Greater integration
reporting with other functions
Client Management Quicker response Improved quality Improved
to client enquiries of output information
Quicker response Faster delivery of exchange with
on current project services clients
progress Improved focus on Increased client
client requirements satisfaction

10
3-2 IT Standardization

There are several reasons for the necessity of IT standardization. First of all, in

order to reduce the cost of system maintenance the members in the chain need standards.

Secondly, the supply chain needs a standard to connect different systems and work across

networks. Thirdly, standards can reduce the price of system components, development,

integration, and maintenance.

One of the early data exchange standards is electronic data interchange (EDI).

Many larger companies want to simplify their supply chain by using networks to deliver

the information to their trading partners. EDI provides a simple way to allow for

communication between companies or with customers. Due to the prevalence of the

Internet and its standards (HTML, VRML, XML, etc.), today large corporations are

moving towards new object-based Inter/Intranet computing. Specifications for distributed

object computing and architectures are emerging, as in CORBA from the Object

Management Group (OMG), or the Microsoft OLE/DCOM model. And significant

efforts concerning middleware technologies like JAVA/RMI and JavaBeans, Active X

controls or server-side components etc, are being made.

Typically, IT infrastructure consists of interface devices, communications,

databases, and system architecture. Currently the most commonly used devices are

personal computers, Internet devices, bar-codes scanners, and personal digital assistants

(PDAs). In addition there are two standards competing with each other in the market. One

is the Windows interface on Intel-based computers and the other is the web browser with

11
Java standards. There are two major trends in communications. The first is wireless

communications. The second is the single-point-of-contact for communications.

Regarding databases, there are six types of database in the current market. These

are the legacy database, relational database, object database, data warehouse, data marts,

and groupware database.

Two major system architectures are legacy system and client/server system.

Legacy systems developed as departmental solutions using mainframe or minicomputers,

which were accessed through terminals.

Figure 3-1 Legacy System Architecture

Client/server systems are generally more powerful than legacy systems. The

major concept of the client/server system is in distributing functions among specialist

servers. In a client/server system data upgrades can be done entirely at the server side and

it is also easier to add new modules and functions. Application components can be spread

across multiple servers, allowing for better scalability. Access to external resources, such

as mainframe applications and other databases, is simplified. Also, the database

connections and drivers are not required on the client side.

12
Figure 3-2 Client/Server System Architecture

3-3 Integrating of Information Technologies

In the past the approach of application integration is to build point-to-point

integration, one application at a time. However, this cannot meet the demands of the

Internet environment. With the introduction of component-based models many

companies are using the component-based applications either by developing a new

application or by editing the existing applications.

Whenever there is a demand there should be a supply. The enterprise application

integration (EAI) system provides the integration function from security management,

protocol management, data mapping, and other related functions. EAI solutions can

benefit an organization by providing end-to-end visibility and control of business

operations. This control improves interactions with partners and customers, increases

responsiveness to business changes, enables new market opportunities, and makes

captured knowledge more widely available. [8]

13
Based on the Professor Marvin Manheim in Northwestern University, The

conventional wisdom states that information technology is the key to exploiting

opportunities for competitive advantage in the supply chain. While true this is not the

whole story without a proper integration of technology and people, much time and capital

can be wasted. [14] Computer program cannot replace the human judgment. Therefore

people are also an important factor in the process of integration.

In general, the first step for integration is to organize a project team. The team

manager should establish a time-line for integration the system. The team members

should work together to choose a proper technology and approach. After establishing the

system, the follow-up step is training and testing. The final step is to evaluate the

performance. From a macrocosmic point of view, a company can measure the

performance by data entry, the stock of inventory, profit margin, and customer

satisfaction.

14
CHAPTER 4 INTRODUCTION TO ENTERPRISE

RESOURCE PLANNING SYSTEMS

4-1 Introduction

Enterprise resource planning (ERP) is a set of applications that serve as the nerve

center of the organization. The whole system is just like a warehouse that stores and

tracks internal information such as inventory levels, pricing structures and other key

supply chain factors.

An ERP system can integrate all of a departments functions in a single computer

system. The system serves all the different departments' particular needs. For instance,

when one department finishes with an order, it is automatically routed via the ERP

system to the next department. To find out where the order is at any point, one needs only

log into the system and track it down. ERP also can apply to the other major business

processes, such as human resources management or financial reporting.

An integrated ERP system can have tremendous benefits if companies implement

the system correctly. It can help businesses with product planning, managing inventories,

and interacting with suppliers. Moreover, with ERP in place the company is prepared for

the vital upstream and downstream linkage of systems that enable network planning and

execution. According to the survey by Cisco Systems Inc., Today, more than 60 percent

of Fortune 1000 companies have implemented core ERP applications. Many smaller

15
companies, with revenues less than $250 million, have also installed ERP systems. [2]

Before a company moves to E-SCM, a company should think about implementing an

ERP system first, so that the data will be accessible and complete.

4-2 Implementation of ERP

Implementing an ERP system requires significant investments in time and money.

Business processes may need to change, and employees will need time to become

familiar with and efficient in using the new system. In addition to budgeting for

software costs, financial executives should plan to write checks to cover consulting,

process rework, integration testing and a long laundry list of other expenses before the

benefits of ERP start to manifest themselves. [11]

Every ERP deployment is different. The application modules are customized. The

architecture of the system and distribution of computing resources are also unique.

Before implementing an ERP system, it is essential to understand how the application

performs on the network. Testing the network in advance, understanding how these

applications will perform, and recognizing what impacts they will have on existing

applications are all the key factors to consider. The location of computing resources may

have a significant impact on how the application performs, particularly in three-tier

environments. It is important to understand the traffic flows between the client and the

server as well as the server-to-server communication flows.

ERP applications can help an organization improve efficiency, reduce costs, and

realize dramatic improvements in customer service. With proper planning the

16
implementation will be a success. Once companies achieve this level of internal

integration with ERP data and supply-chain planning, they can start extending their reach,

sharing information around anticipated demand with customers and suppliers. [7]

4-3 Introduction to ERP Solutions

Currently, there are two commonly used approaches to ERP systems. One is to

purchase an ERP package from one vendor. The other, called best-of-breed solution,

purchases the appropriate solution in each category from different vendors. The latter is

more complicated and takes longer to implement.

The major ERP vendors are Baan, J.D. Edwards, Oracle, PeopleSoft, SAP, and

others. ERP integration middleware vendors can be divided to two groups: data-oriented

vendors and messaging-oriented vendors. The data-oriented vendors need data files or

databases to transform data. Instead of using databases or data files, the messaging-

oriented vendors use a direct data-sharing approach.

In keeping with the general industry trend of avoiding proprietary solutions

whenever possible, most vendors of application development and deployment

environments are looking to industry standards such as Corba, Microsoft's Component

Object Model, JavaBeans, Enterprise JavaBeans, and the Extensible Markup Language as

the basis for their ERP adapters and connectors.[9]

17
CHAPTER 5 STRATEGIC ALLIANCE

5-1 What is Strategic Alliance?

Based on the work of Professor Alexander Knaani of Columbia University, a

strategic alliance is a business relationship between organizations in which they share

risks, pool strengths, or integrate business functions for mutual benefit. Each of the

partners in an alliance remains a distinct entity, unlike a merger, where the assets are

combined. [10]

Often, the opportunity for an alliance arises simply from an inquiry, a

competitor's move, or a CEO's conversations with a counterpart. Before the workers in a

company are aware of it, the company is constructing the alliance with suppliers rather

than determining whether it is needed or not, and, if so, what kind of deal is needed.

A good alliance strategy therefore starts at home. The company must not only

define the business logic for its alliances and manage the group of partners well, but it

must also invest resources in the strategy. [17] Firms that are undergoing this are often

cited for their capability. The essence of this capability is that alliances are part of

everyday functioning of the company. They are not special steps relegated to a group of

alliance experts. They are everyones responsibility. At the same time, where special

expertise is needed, the company can find a way to share information and practices

internally or through the Internet.

18
5-2 The Elements of Alliance Strategy

There are now plenty of books and reports to describe the keys to success in

strategic alliances. And there is no denying that many alliances stand or fall because of

how they are designed, how the partner is chosen, and other elements specific to the deal

itself. According to the studies, strategic alliance possesses four basic elements in its

foundation.[5]

A business strategy - sharing the information of individual alliances

Goals - building the steps and management skills of each alliance

A system - constructing coordination among alliances in order to increase flexibility

The supporting system from the internal structure - enhancing the value of external

collaboration, such as networking

Precisely because the business environment forces the transformation of a

company, it is essential for a company to think in advance about how alliances fit into the

business strategy and what goals have to be achieved. Supply alliances aim to take

advantage of economies of scale and specialization by having one partner supply the

other with products or services. Positioning alliances help partners enter new markets or

expand existing markets. Learning alliances develop new technologies through

collaborative research or transfer skills between partners. Many alliances exhibit

combinations of these goals. It is also crucial to know how the alliance fits into a business

strategy, and it is also important accurately to measure its performance once carried out.

[20]

19
The third element is the method that coordinates all the alliance partners to

increase flexibility. The number of deals in which a company is engaged certainly needs

to be managed. It will probably call for making tradeoffs among partners or even among

goals of different business units. Sometimes engaging in one alliance will foreclose the

option of doing another. This uncertainty is costly to the alliance strategy. Often it is only

after these costs emerge that the need for coordinating the alliance portfolio becomes

clear to all.

As the partners grow in numbers, the importance of a supportive internal

infrastructure will also become vital. Tending to alliances will soon begin to place

substantial demands on scarce resources not having the attention of top management.

When the organization is taxed, it will either resist change or find new ways to adjust and

support the alliance strategy. Only the latter can offer a hope of success. In the future, a

company will not survive if they try to do everything themselves, nor will they be saved

by a strategic alliance here or there. But having an alliance strategy implemented through

electronic networking will give them a fighting chance. The new book The International

Networking between European Logistical Operators fully studies network-based

conceptualizations of strategic alliances and shed light on the alliance system model. [13]

Taken together, these elements determine whether a company is successful in

using alliances. As a general matter, alliances themselves are neither good nor bad for a

company. It depends on how they are used and how they are connected in each step.

When managed well, they can create tremendous value; but wrongly used are costly

distractions. The success of an alliance can be simply described in a few words: have a

20
clear strategic purpose, find the right partners, ensure all partners do their part, have a

good vision of the alliance, share information, be flexible, and finally, be prepared. [6]

21
CHAPTER 6 IMPLEMENTATION

6-1 System Design And User Interface

There are many different technologies that can be used for building a web-based

system. In this chapter, an online shopping basket and an online inventory management

system will be integrated and new concepts will be applied to the system.

The online shopping basket here is a front office tool that provides online

customers with an informative and well-organized environment for online shopping. The

basket provides a menu function; customers can choose different products by categories.

The shopping basket also provides addition, viewing, and modification functions. After a

customer submits the order, the system will send email to confirm the order and the

details of payment and delivery method for the customer.

22
Figure 6-1 The Initial Web Page of Shopping Basket

Customers can choose the products through the menu on the left side of screen.

Figure 6-2 The Product Page of Shopping Basket

Customers can add products of different categories to the shopping basket.


23
Figure 6-3 The Different Category Product Web Page on the Shopping Basket

Customers can view the orders in the shopping basket.

Figure 6-4 The Whole Shopping Basket Web Page

24
Customers need to fill out the order form to complete the orders.

Figure 6-5 The Order Form Web Page of Shopping Basket

The second part of the study is an on line inventory management system. The

traditional inventory management system does not allow checking the inventory status

immediately. Moreover, it takes time to convert the data into useful information and

reports. With this web-based inventory management system, a manager can easily access

and manage the inventory data. First of all, the system allows the authorized user to

check and modify the product data in the database. Addition, modification, deletion, and

displaying are four functions in the system.

The addition function allows the user to add a new category or product to

database. The modification function allows the user to edit the data in the database. The

deletion function allows the user to erase any data in the database. The displaying

function allows the user to view the data in the database.

25
All product information is stored in a database. There are two entities in the

database. One is the category entity. The other is the product entity. The category entity

stores the detail information about the category such as category id, name,

descriptionetc. The product entity stores the detail information about the product such

as product id, name, price, stock quantityetc. Each entity is related to each other by a

primary key and foreign key in the table. Therefore, one category can have many

products and several products can belong to one category.

The whole system begins with a login web page. After the authorized user logs in

with a correct name and password, then the system will show the main inventory menu

page. In the system a server side program on the web server generates all client side

requests. According to the client side requests the server will send the result to the client.

The web server connects with the database by a JDBC connection.

26
The system flow is as in Figure 6-6.

Figure 6-6 The System Flow of Inventory Management System

In the system all the user interfaces are designed by web page. The login page is

the entry page in the system. The system requires the authorized user to log into the

system. After the user logs in with valid name and password, the main menu web page

will show on the screen. The system also allows the user to log out in any working web

page. Whenever the user submits a request, the system will generate the request by the

proper Java Servlet program and send the result to the client side web page.

27
Figure 6-7 The Login Web Page

Figure 6-8 The Main Menu Page of Inventory Management System

28
When a user wants to add a new category, one can click the add button then the

add category web page will appear on the screen.

Figure 6-9 The Add Category Web Page of Inventory Management System

After the user adds a new category, the system will add the data into the database

and show the result on the web page at the same time.

Figure 6-10 The Confirmed Web Page of Add Category

29
When a user clicks to delete a category, the deletion page will show on the screen.

Figure 6-11 The Deletion Web Page of Delete Category

After the user hits the submit button, the system will show the confirmation page.

Figure 6-12 The Confirmation Web Page of Delete Category

30
When a user wants to modify the data, the data can be searched by category id.

Figure 6-13 The Search Web Page of Modify Category

After the user hits the search button, the system will show the data on the screen.

Figure 6-14 The Modify Web Page of Modify Category

31
When a user clicks the view button, the system will display all data in the

database.

Figure 6-15 The Show Data Web Page of Display Category

After the user clicks the show all button, the system will display all data on the

screen.

Figure 6-16 The Display Web Page of Display Category


32
To add a new product, a user can click the add button then the add product web

page will show on the screen.

Figure 6-17 The Add Product Web Page of Inventory Management System

After the user adds a new product, the system will add the data into database and

show the result on the web page at the same time.

Figure 6-18 The Confirmed Web Page of Add Product


33
6-2 Detailed Descriptions

In this section, let us take a look at how the program works with some partial code

dissection. First of all, for the shopping basket part, the item addition is generated by a

buyItem function.

function buyItem(newItem, newPrice, newQuantity, newOption) {


if (newQuantity <= 0){
rc = alert('Antal varor felaktigt ifyllt');
}
else{
if (newQuantity >= 0) {
index = document.cookie.indexOf("TheBasket");
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1) {
countend = document.cookie.length;
top.frames[3].location = "../basket.html";
}
}

After adding an item to the basket, a customer can modify or view the basket. The

amendItem function and showItems function generate the requests respectively.

function amendItem(itemno, newquant) {


newItemList = null;
itemlist = 0;
for (var i = 0; i <= fulllist.length; i++){
if (fulllist.substring(i,i+1) == '[') {
thisitem = 1;
itemstart = i+1;
fullstart = i+1;
}else if (fulllist.substring(i,i+1) == ']'){
itemend = i;
itemlist=itemlist+1;
if (itemlist != itemno) {
newItemList = newItemList+'['+fulllist.substring(fullstart, itemend)+']';
} else {
newItemList=newItemList+'['+theitem+'|'+theprice+'|'+theoption+'|'
+newquant+']';
}
}else if (fulllist.substring(i,i+1) == '|') {
34
if (thisitem==1) theitem = fulllist.substring(itemstart, i);
if (thisitem==2) theprice = fulllist.substring(itemstart, i);
if (thisitem==3) theoption = fulllist.substring(itemstart, i);
thisitem++;
itemstart=i+1;
}
}
index = document.cookie.indexOf("TheBasket");
document.cookie="TheBasket="+newItemList;
self.location = "basket.html";
}

function showItems() {
index = document.cookie.indexOf("TheBasket");
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1) {
countend = document.cookie.length;
}
fulllist = document.cookie.substring(countbegin, countend);
subtotal = 0;

itemlist = 0;
for (var i = 0; i <= fulllist.length; i++) {
if (fulllist.substring(i,i+1) == '[') {
itemstart = i+1;
thisitem = 1;
}
else if (fulllist.substring(i,i+1) == ']') {
itemend = i;
thequantity = fulllist.substring(itemstart, itemend);
itemtotal = 0;
itemtotal = (eval(theprice*thequantity));
temptotal = itemtotal * 100;
subtotal = subtotal + itemtotal;
itemlist=itemlist+1;
document.write('<option>'+thequantity+' st '+theitem+'</option>');

}
else if (fulllist.substring(i,i+1) == '|') {
if (thisitem==1) theitem = fulllist.substring(itemstart, i);
if (thisitem==2) theprice = fulllist.substring(itemstart, i);
if (thisitem==3) theoption = fulllist.substring(itemstart, i);
thisitem++;
itemstart=i+1;
}
}

35
Secondly, for the inventory management system part, the system begins with a

login web page. The web page will pass two parameters to the Servlets, then the Servlets

will generate the request and send the result back to web page. The HTML code is as

below.

<FORM ACTION="Servlets/LoginServlets" METHOD="post">

<INPUT TYPE="text" NAME="name"></P>


<INPUT TYPE="password" NAME="passwd"></P>

<INPUT TYPE="submit" VALUE="Login" NAME="Login" >


<INPUT TYPE="reset" VALUE="Clear">

</FORM>

The Servlet code is as below.

public class LoginServlets extends HttpServlets{

public void doPost(HttpServletsRequest req, HttpServletsResponse res)


throws ServletsException, IOException {

String name = req.getParameter("name");
String passwd = req.getParameter("passwd");
if(name.equals("erin")&&passwd.equals("erin")){
res.sendRedirect("http://localhost:8080/test/inventorymenu.html");
}

}
}

When logging into the main menu web page, a user can access the database. For

instance, to add a category to database, through the web page the user can send the

request to Servlets. The HTML page for adding a category is as below.

<FORM ACTION="Servlets/AddCategory" METHOD="GET">

<INPUT TYPE="text" NAME="id" SIZE="10">


<INPUT TYPE="text" NAME="name" SIZE="20">
<INPUT TYPE="text" NAME="description_url" SIZE="35">

</FORM>

36
The Servlets code is as below.

public class AddCategory extends HttpServlets{


// Declare variables

public void doGet(HttpServletsRequest req, HttpServletsResponse res)
throws IOException, ServletsException{

c_id = req.getParameter("id");
name = req.getParameter("name");
desURL = req.getParameter("description_url");
des = req.getParameter("description");

// JDBC-ODBC Bridge Driver

// Open the database

static void open() throws SQLException{
// ODBC data source name
// Connect to the database
// Turn off autocommit
// Close database connection

// A SQL query for inserting data from database


static void insert(String cid, String cname, String dURL, String d)
throws SQLException{
Statement stmt;
String query = "insert into category values(" + "'" + cid +"','"+
cname +"','"+ dURL+"','"+ d + "')";
stmt = con.createStatement();
stmt.executeUpdate(query);
}
}

To delete a category from the database, through the web page the user can send

the request to Servlets. The HTML page for deleting a category is as below.

<FORM ACTION="Servlets/DelCategory" METHOD="GET">

<INPUT TYPE="text" NAME="id" SIZE="10"></H2></TD>

</FORM>

The Servlets code is as below.

public class DelCategory extends HttpServlets{


37
static String cid;
static Connection con;

public void doGet(HttpServletsRequest req, HttpServletsResponse res)


throws IOException, ServletsException{

cid = req.getParameter("id");
try{delete(cid);}catch(Exception e){};
}
static void delete(String id) throws SQLException{
Statement stmt;
String query = "DELETE FROM category WHERE cid=" + id;
stmt = con.createStatement();
stmt.executeUpdate(query);
con.commit();
stmt.close();
}

In general, HTML interacts with Java Servlets by using the FORM element of

HTML. Inside the FORM tag, HTML can pass the parameters and method attribute to

Servlets. Servlets are Java programs that run on the backend like CGI programs. The

Servlet engine passes two objects to either the doGet() or doPost() method by default.

The HttpServletRequest can be used to get information about the request such as the

names and values of the FORM. HttpServletResponse can be used to generate a response

back to the client.

A combination of technologies such as HTML, Java, JDBC and Javascript is very

helpful to create powerful Web applications.

38
CHAPTER 7 CONCLUSION

This study conveys the conceptual idea of supply chain management. In the real

world, the situation is more complicated. Usually, it may take couple of years to build an

integrated ERP system and E-SCM system. Information technology provides a more

efficient way to build the system. In general, different industries will adopt different

approaches. Therefore, the business cycle time reduction and improved efficiency in

supply chain management is more important than the technology.

Two additional concepts can be added to improve the system in this study. The

first one is system combination. For an integrated ERP system, the system should include

at least five subsystems: inventory management system, customer management system,

ordering management system, shipping management system, and human resource

management system. Based on a database-oriented system, all the systems have to be

connected together in order to build up a total electronic business environment.

The second one is the upstream and downstream linking. Currently, this study just

links with customers. In order to connect all the suppliers in the business chain, the

system should have the ability to link the supply chain together in the web environment.

This study was not intended to build up a huge management system, but to

illustrate how an ordering system can be easily connected with an inventory system in

order to create a user-friendly component. By simplifying the ordering procedures and

39
enforcing the existing functions, the system can be easily incorporated into a full-featured

electronic business system.

40
REFERENCES

[1] Bo-Christer Bjrk (June 2000). A Framework for Measuring IT Innovation Benefits.
http://itcon.org/2000/4/.

[2] Cisco Systems, Inc. (July 2000). Solutions Guide Building an ERP-ready Network.
http://www.erpassist.com/browse.asp?c=ERPPeerPublishing.

[3] Andrew Cox (1999). Power, Value and Supply Chain Management. Supply Chain
Management: An International Journal, Vol 4 pp. 192-198.

[4] Peter Fabris (June 1997). ERP & Extranet Application. CIO Journal. Vol 10 Issue 17
pp. 70-78.

[5] Benjamin Gomes-Casseres. (May 1996). The Alliance Rrevolution: the New Shape of
Business Rivalry. Cambridge, Mass: Harvard University Press. pp. 6-11.

[6] Benjamin Gomes-Casseres (August 1998). Strategy Before Structure. The Alliance
Analyst. http://www.allianceanalyst.com/Article1Aug15-98.html.

[7] Lisa H. Harrington. (April 1997). ERP & Supply Chain. Industry Week. Vol 246
Issue 7 pp. 97-100.

[8] Logicool. Enterprise Application Integration. http://www.logicool.com/eai.htm.

[9] Dan Kara. (March 1999). ERP Integration - vendors race to meet IT's growing need
for integral links to enterprise apps.
http://www.informationweek.com/724/24prerp.htm.

[10] Alexander Knaani. (November 2000). Framework for developing corporate


strategic alliances. http://www.cvn.columbia.edu.

[11] Christopher Koch, Derek Slater and E. Baatz (December 1999). The ABCs of ERP.
http://www.cio.com/research/erp/edit/122299_erp.html.

[12] Petra Lattmann (February 2001). Supply Chain Solutions Focus on Customers
Needs. id SYSTEMS. pp. 30-39.

41
REFERENCES
(Continued)

[13] Johanna Ludvigsen (2000). The International Networking between European


Logistical Operators. Economic Research Institute. Stockholm School of Economics.

[14] Marvin Manheim (April 1999). Integrating People and Technology for Supply
Chain Advantage. http://www.ascet.com/documents.asp?d_ID=236.

[15] Peter J. Metz (Winter 1998). Demystifying Supply Chain Management.


http://www.manufacturing.net/scl/scmr/archives/1998/04myst.htm.

[16] Deb Navas (February 2001). The Extended Electronic Supply Chain. id SYSTEMS.
pp.18-29.

[17] S. Benjamin Prasad and Richard B. Peterson, eds (1992).Technology Flows and
Global Competition: A Framework for Research and Management. Advances in
International Comparative Management. Vol 7. Greenwich, CT: JAI Press Inc.,
pp. 3-22.

[18] Charles C. Poirier, Michael J. Bauer (2001). E-supply Chain.


Emeryville,CA:Berrett-Koehler Pub. pp. 3-21.

[19] David Simchi-Levi, Philip Kaminsky, Edith Simchi-Levi (2000). Designing and
Managing the Supply Chain. Burr Ridge, IL:The McGraw-Hill Companies, Inc..
pp. 215-247.

[20] David B. Yoffie, ed. (1993). Computers: Alliances and Industry Evolution.
Beyond Free Trade: Firms, Governments, and Global Competition. Boston, MA:
Harvard Business School Press pp. 79-128.

42
APPENDIX A

Source Code List

Source Code of Login.. 44


Source Code of Add Category. 45
Source Code of Delete Category. 47
Source Code of Modify Category 49
Source Code of Display Category 52
Source Code of Add Product... 54
Source Code of Delete Product 57
Source Code of Modify Product.. 59
Source Code of Display Product.. 62
Source Code of Logout 65

43
/* Source Code of Login - LoginServlet.java*/

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class LoginServlet extends HttpServlet{


public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();

//Get the user's name and password


String name = req.getParameter("name");
String passwd = req.getParameter("passwd");

//Check the name and password for validity


if(name.equals("erin")&&passwd.equals("erin")){
res.sendRedirect("http://localhost:8080/test/inventorymenu.html");
}
else{
out.println("<HTML><HEAD><TITLE>Access Denied</TITLE></HEAD>");
out.println("<BODY><CENTER>Your login and password are invalid.<BR>");
out.println("Please <A HREF=http://localhost:8080/test/login.html>Try again!</A>");
out.println("</CENTER></BODY></HTML>");
}
}

public void doGet(HttpServletRequest req, HttpServletResponse res)


throws ServletException, IOException{
doPost(req, res);
}
}

44
/* Source Code of Add Category - AddCategory.java*/

import java.sql.*;
import java.text.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class AddCategory extends HttpServlet{

//declare variables
static String c_id;
static String name;
static String desURL;
static String des;
static Connection con;

public void doGet(HttpServletRequest req, HttpServletResponse res)


throws IOException, ServletException{

res.setContentType("text/html");
PrintWriter out = res.getWriter();
String menu = req.getParameter("menu");
if(menu!=null){res.sendRedirect("http://localhost:8080/test/inventorymenu.html");}
String logout = req.getParameter("logout");
if(logout!=null){res.sendRedirect("http://localhost:8080/test/login.html");}

//get parameters from html


c_id = req.getParameter("id");
name = req.getParameter("name");
desURL = req.getParameter("description_url");
des = req.getParameter("description");

out.println("<html>");
out.println("<body>");
out.println("<center>");
out.println("<h1><b>The data you add is as below:</b></h1>");
out.println("<table border=1 bordercolor=black><tr align=middle>");
out.println("<th>ID</th><th>NAME</th><th>DESCRIPTION_URL</th>
<th>DESCRIPTION</th></tr>");
out.println("<th>"+c_id+"</th>"+"<th>"+name+"</th>"+"<th>"+desURL
+ "</th>"+"<th>"+des+"</th></tr>");

// JDBC-ODBC Bridge Driver


try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch(Exception e){};

45
// Open the database
try{open();} catch(Exception e){};
try{insert(c_id, name, desURL, des);}catch(Exception e){};
try{close();}catch(Exception e){};
out.println("</table>");
out.println("<a href=http://localhost:8080/test/addcategory.html>Back</a>");
out.println("</center></body>");
out.println("</html>");
}

public void doPost(HttpServletRequest req, HttpServletResponse res)


throws IOException, ServletException{
doGet(req, res);
}

// Open a database connection


static void open() throws SQLException{

// ODBC data source name


String dsn = "jdbc:odbc:SCMDB";
String user = "";
String password = "";

// Connect to the database


con = DriverManager.getConnection(dsn, user, password);

// Turn off autocommit


con.setAutoCommit(false);
}

// Close database connection


static void close() throws SQLException{
con.commit();
con.close();
}

// A SQL query for inserting data from database


static void insert(String cid, String cname, String dURL, String d)
throws SQLException{
Statement stmt;
String query = "insert into category values(" + "'" + cid +"','"+ cname +"','"
+ dURL+"','"+ d + "')";
stmt = con.createStatement();
stmt.executeUpdate(query);
}
}

46
/* Source Code of Delete Category - DelCategory.java*/

import java.sql.*;
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class DelCategory extends HttpServlet{

static String cid;


static Connection con;

public void doGet(HttpServletRequest req, HttpServletResponse res)


throws IOException, ServletException{

res.setContentType("text/html");
PrintWriter out = res.getWriter();
cid = req.getParameter("id");
String menu = req.getParameter("menu");
if(menu!=null){res.sendRedirect("http://localhost:8080/test/inventorymenu.html");}
String logout = req.getParameter("logout");
if(logout!=null){res.sendRedirect("http://localhost:8080/test/login.html");}
out.println("<html>");
out.println("<body>");
out.println("<center>");
out.println("<h1><b>The data has been deleted successfully!</b></h1>");

// JDBC-ODBC Bridge Driver


try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(Exception e){};

// Open the database


try{open();}catch(Exception e){};
try{delete();}catch(Exception e){};
try{close();}catch(Exception e){};
out.println("</table>");
out.println("<a href=http://localhost:8080/test/delcategory.html>Back</a>");
out.println("</center></body>");
out.println("</html>");
}

public void doPost(HttpServletRequest req, HttpServletResponse res)


throws IOException, ServletException{
doGet(req, res);
}

47
// Open a database connection
static void open() throws SQLException{

// ODBC data source name


String dsn = "jdbc:odbc:SCMDB";
String user = "";
String password = "";

// Connect to the database


con = DriverManager.getConnection(dsn, user, password);
// Turn off autocommit
con.setAutoCommit(false);
}

// Close database connection


static void close() throws SQLException{
con.commit();
con.close();
}

// A SQL query for deleting data from database


static void delete() throws SQLException{
Statement stmt;
String query = "delete from category where cid=" + cid;
stmt = con.createStatement();
stmt.executeUpdate(query);
con.commit();
stmt.close();
}
}

48
/* Source Code of Modify Category - ModifyCategory.java*/

import java.sql.*;
import java.text.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ModifyCategory extends HttpServlet{

static String id;


static Connection con;
static String logout;

public void doGet(HttpServletRequest req, HttpServletResponse res)


throws IOException, ServletException{

res.setContentType("text/html");
PrintWriter out = res.getWriter();
id = req.getParameter("cid");
String q= " WHERE cid = " + id;
String action = "update";
out.println("<HTML>");
out.println("<TITLE>Modify Category Data</TITLE>");
out.println("<BODY><CENTER>Modify Category Data");

// JDBC-ODBC bridge driver


try{Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(Exception e){};

// Open the database and display all rows in a table


try{open();}catch(Exception e){};
try{select(out, q);}catch(Exception e){out.println(e);};
try{close();}catch(Exception e){};
out.println("<A HREF='ModifyCategory?action=update'>Submit</A><BR>");
out.println("<TR><TD ALIGN=LEFT>");
if(action.equalsIgnoreCase("update"))
try{update();}catch(Exception e){};

//out.println("<INPUT TYPE=submit VALUE=SUBMIT>");


out.println("</TD></TR>");
out.println("</FORM></CENTER></BODY></HTML>");
}
// Open a database connection
static void open() throws SQLException{

// ODBC data source name


String dsn = "jdbc:odbc:SCMDB";
49
String user = "";
String password = "";

// Connect to the database


con = DriverManager.getConnection(dsn, user, password);

// Turn off autocommit


con.setAutoCommit(false);
}

// Commit all pending transactions and close the database connection


static void close() throws SQLException{
con.commit();
con.close();
}

// a SQL query with a WHERE clause


static void select(PrintWriter out, String whereClause) throws SQLException{
Statement stmt; // SQL statement object
String query; // SQL select string
ResultSet rs; // SQL query results
boolean more;

query = "SELECT cid, cname, desurl, description FROM category" + whereClause;


stmt = con.createStatement();
rs = stmt.executeQuery(query);
more = rs.next();
if(!more){
System.out.println("No rows found.");
return;
}

// Loop through the rows retrieved from the query


while(more){
out.println("<TABLE><TR ALIGN=middle>");
out.println("<TR><TD>ID:<INPUT TYPE=text NAME=id SIZE=10
VALUE="+rs.getString("cid")+"></TD>");
out.println("<TR><TD>Name:<INPUT TYPE=text NAME=name SIZE=20
VALUE="+rs.getString("cname")+"></TD>");
out.println("<TR><TD>Description URL:<INPUT TYPE=text NAME=description_url
SIZE=35 VALUE="+rs.getString("desurl")+"></TD></TR>");
out.println("</TD></TR>");
out.println("<TR><TD COLSPAN=4>Description:<BR>");
out.println("<TEXTAREA NAME=description ROWS=8 COLS=50
VALUE="+rs.getString("description")+"></TEXTAREA></TD></TR>");
out.println("</TD></TR>");
out.println("</TABLE>");
more = rs.next();
}
rs.close();

50
stmt.close();
}

static void update() throws SQLException{


Statement stmt; // SQL statement object
String sql; // SQL select string
int rows;
ResultSet rs;
rs = stmt.executeQuery(query);
sql = "UPDATE category SET cname=" + rs.getString("cname") + ", desurl" +
rs.getString("desurl") + ", description" + rs.getString("description") +
" WHERE cid="+ id;
stmt = con.createStatement();
rows = stmt.executeUpdate(sql);
con.commit();
stmt.close();
}
}

51
/* Source Code of Display Category - DisplayCategory.java*/

import java.sql.*;
import java.text.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class DisplayCategory extends HttpServlet {

static String show;


static String whereClause;
static Connection con; //database connection object

public void doGet(HttpServletRequest req, HttpServletResponse res)


throws IOException, ServletException{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
String menu = req.getParameter("menu");
if(menu!=null){res.sendRedirect("http://localhost:8080/test/inventorymenu.html");}
String logout = req.getParameter("logout");
if(logout!=null){res.sendRedirect("http://localhost:8080/test/login.html");}
show = req.getParameter("showall");
out.println("<html>");
out.println("<body>");
out.println("<center>");
out.println("<table border=1><tr align=middle>");
out.println("<th>ID</th><th>NAME</th><th>DES_URL</th>
<th>DESCRIPTION</th><tr>");

// JDBC-ODBC bridge driver


try{
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(Exception e){};

// Open the database and display all rows in a table


try{open();}catch(Exception e){};
try{select(out, whereClause);}catch(Exception e){out.println(e);};
try{close();}catch(Exception e){};
out.println("</table>");
out.println("<a
href=http://localhost:8080/test/inventorymenu.html>Back</a>");
out.println("</center></body>");
out.println("</html>");
}

// Open a database connection


static void open() throws SQLException{
52
// ODBC data source name
String dsn = "jdbc:odbc:SCMDB";
String user = "";
String password = "";

// Connect to the database


con = DriverManager.getConnection(dsn, user, password);

// Turn off autocommit


con.setAutoCommit(false);
}

// Commit all pending transactions and close the database connection


static void close() throws SQLException
{
con.commit();
con.close();
}

// a SQL query with a WHERE clause


static void select(PrintWriter out, String whereClause) throws SQLException{
Statement stmt; // SQL statement object
String query; // SQL select string
ResultSet rs; // SQL query results
boolean more; // more rows found
query = "SELECT cid, cname, desurl, description " + "FROM category ";
stmt = con.createStatement();
rs = stmt.executeQuery(query);

// Check to see if any rows were read


more = rs.next();
if(!more){
System.out.println("No rows found!");
return;
}

// Loop through the rows retrieved from the query


while(more){
out.println("<html><body>");
out.println("<tr><td>" + rs.getString("cid") + "</td>");
out.println("<td>" + rs.getString("cname") + "</td>");
out.println("<td>" + rs.getString("desurl") + "</td>");
out.println("<td>" + rs.getString("description") + "</td></tr>");
out.println("</body></html>");
more = rs.next();
}
rs.close();
stmt.close();
}
}

53
/* Source Code of Add Product - AddProduct.java*/
import java.sql.*;
import java.text.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class AddProduct extends HttpServlet{

static String p_id;


static String c_id;
static String name;
static String price;
static String stockqty;
static String dangerlevel;
static String supplier;
static String contact;
static String desURL;
static String des;
static Connection con;

public void doGet(HttpServletRequest req, HttpServletResponse res)


throws IOException, ServletException{

res.setContentType("text/html");
PrintWriter out = res.getWriter();
String menu = req.getParameter("menu");
if(menu!=null){res.sendRedirect("http://localhost:8080/test/inventorymenu.html");}
String logout = req.getParameter("logout");
if(logout!=null){res.sendRedirect("http://localhost:8080/test/login.html");}
p_id = req.getParameter("pid");
c_id = req.getParameter("cid");
name = req.getParameter("name");
price = req.getParameter("price");
stockqty = req.getParameter("qty");
dangerlevel = req.getParameter("danger");
supplier = req.getParameter("supplier");
contact = req.getParameter("mail");
desURL = req.getParameter("description_url");
des = req.getParameter("description");

out.println("<html>");
out.println("<body>");
out.println("<center>");
out.println("<h1><b>The data you add is as below:</b></h1>");
out.println("<table border=1 bordercolor=black><tr align=middle>");
out.println("<th>PID</th><th>CID</th><th>NAME</th><th>PRICE</th>
<th>QUANTITY</th>"
54
+"<th>DANGERLEVEL</th><th>SUPPLIER</th><th>CONTACT</th>
<th>DES_URL</th><th>DESCRIPTION</th></tr>");
out.println("<th>"+p_id+"</th>"+"<th>"+c_id+"</th>"+"<th>"+name+"</th>"
+"<th>"+price+"</th>"+"<th>"+stockqty+"</th>"+"<th>"+dangerlevel+"</th>"
+"<th>"+supplier+"</th>"+"<th>"+contact+"</th>"+"<th>"+desURL+"</th>"
+"<th>"+des+"</th></tr>");

// JDBC-ODBC Bridge Driver


try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch(Exception e){};

// Open the database


try{open();} catch(Exception e){};
try{
insert(p_id, c_id, name, price, stockqty, dangerlevel, supplier,
contact, desURL, des);
}catch(Exception e){out.println(e);};

try{close();}catch(Exception e){};
out.println("</table>");
out.println("<a
href=http://localhost:8080/test/addproduct.html>Back</a>");
out.println("</center></body>");
out.println("</html>");
}

public void doPost(HttpServletRequest req, HttpServletResponse res)


throws IOException, ServletException{
doGet(req, res);
}

// Open a database connection


static void open() throws SQLException{

// ODBC data source name


String dsn = "jdbc:odbc:SCMDB";
String user = "";
String password = "";
// Connect to the database
con = DriverManager.getConnection(dsn, user, password);
// Turn off autocommit
con.setAutoCommit(false);
}

// Close database connection


static void close() throws SQLException{
con.commit();
con.close();
}

55
// A SQL query for inserting data from database
static void insert(String pid, String cid, String name, String price, String qty,
String dlevel, String supplier, String contact, String desURL, String des)
throws SQLException{
Statement stmt;
String query = "insert into product values(" + "'" + pid +"','"+ cid +"','"+ name +"','"
+ price + "','" + qty + "','" + dlevel + "','" + supplier + "','" + contact + "','" + desURL
+ "','" + des + "')";
stmt = con.createStatement();
stmt.executeUpdate(query);
}
}

56
/* Source Code of Delete Product - DelProduct.java*/

import java.sql.*;
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class DelProduct extends HttpServlet{

static String pid;


static Connection con;

public void doGet(HttpServletRequest req, HttpServletResponse res)


throws IOException, ServletException{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
String pid = req.getParameter("id");
String menu = req.getParameter("menu");
if(menu!=null){res.sendRedirect("http://localhost:8080/test/inventorymenu.html");}
String logout = req.getParameter("logout");
if(logout!=null){res.sendRedirect("http://localhost:8080/test/login.html");}
out.println("<html>");
out.println("<body>");
out.println("<center>");
out.println("<h1><b>The data has been deleted successfully!</b></h1>");

// JDBC-ODBC Bridge Driver


try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(Exception e){};

// Open the database


try{open();}catch(Exception e){};

try{delete();}catch(Exception e){};

try{close();}catch(Exception e){};
out.println("</table>");
out.println("<a href=http://localhost:8080/test/delcategory.html>Back</a>");
out.println("</center></body>");
out.println("</html>");
}

public void doPost(HttpServletRequest req, HttpServletResponse res)


throws IOException, ServletException{
doGet(req, res);
}

57
// Open a database connection
static void open() throws SQLException{

// ODBC data source name


String dsn = "jdbc:odbc:SCMDB";
String user = "";
String password = "";

// Connect to the database


con = DriverManager.getConnection(dsn, user, password);

// Turn off autocommit


con.setAutoCommit(false);
}

// Close database connection


static void close() throws SQLException{
con.commit();
con.close();
}

// A SQL query for deleting data from database


static void delete() throws SQLException{
Statement stmt;
String query = "DELETE FROM product WHERE pid="+ pid;
stmt = con.createStatement();
stmt.executeUpdate(query);
}
}

58
/* Source Code of Modify Product - ModifyProduct.java*/

import java.sql.*;
import java.text.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ModifyProduct extends HttpServlet{

static String id;


static Connection con;
static String logout;

public void doGet(HttpServletRequest req, HttpServletResponse res)


throws IOException, ServletException{

res.setContentType("text/html");
PrintWriter out = res.getWriter();
id = req.getParameter("pid");
String q= " WHERE pid = " + id;
String action = "update";
out.println("<HTML>");
out.println("<TITLE>Modify Product Data</TITLE>");
out.println("<BODY><CENTER>Modify Product Data");

// JDBC-ODBC bridge driver


try{Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(Exception e){};

// Open the database and display all rows in a table


try{open();}catch(Exception e){};
try{select(out, q);}catch(Exception e){out.println(e);};
try{close();}catch(Exception e){};
out.println("<A HREF='ModifyProduct?action=update'>Submit</A><BR>");
out.println("<TR><TD ALIGN=LEFT>");
if(action.equalsIgnoreCase("update"))
try{update();}catch(Exception e){};

//out.println("<INPUT TYPE=submit VALUE=SUBMIT>");


out.println("</TD></TR>");
out.println("</FORM></CENTER></BODY></HTML>");
}
// Open a database connection
static void open() throws SQLException{

// ODBC data source name


String dsn = "jdbc:odbc:SCMDB";
59
String user = "";
String password = "";

// Connect to the database


con = DriverManager.getConnection(dsn, user, password);

// Turn off autocommit


con.setAutoCommit(false);
}

// Commit all pending transactions and close the database connection


static void close() throws SQLException{
con.commit();
con.close();
}

// a SQL query with a WHERE clause


static void select(PrintWriter out, String whereClause) throws SQLException{
Statement stmt; // SQL statement object
String query; // SQL select string
ResultSet rs; // SQL query results
boolean more;

query = query = "SELECT pid, cid, pname, desurl, price, stockqty, dangerlevel,
description, supplier, contact_mail" + " FROM product " + whereClause;
stmt = con.createStatement();
rs = stmt.executeQuery(query);
more = rs.next();
if(!more){
System.out.println("No rows found.");
return;
}

// Loop through the rows retrieved from the query


while(more){
out.println("<TABLE><TR ALIGN=middle>");
out.println("<TR><TD>ID:<INPUT TYPE=text NAME=id SIZE=10
VALUE="+rs.getString("cid")+"></TD>");
out.println("<TR><TD>Name:<INPUT TYPE=text NAME=name SIZE=20
VALUE="+rs.getString("cname")+"></TD>");
out.println("<TR><TD>Description URL:<INPUT TYPE=text NAME=description_url
SIZE=35 VALUE="+rs.getString("desurl")+"></TD></TR>");
out.println("</TD></TR>");
out.println("<TR><TD COLSPAN=4>Description:<BR>");
out.println("<TEXTAREA NAME=description ROWS=8 COLS=50
VALUE="+rs.getString("description")+"></TEXTAREA></TD></TR>");
out.println("</TD></TR>");
out.println("</TABLE>");
more = rs.next();
}

60
rs.close();
stmt.close();
}

static void update() throws SQLException{


Statement stmt; // SQL statement object
String sql; // SQL select string
int rows;
ResultSet rs;
rs = stmt.executeQuery(query);
sql = "UPDATE product SET pname=" + rs.getString("cname") + ", desurl" +
rs.getString("desurl") + ", description" + rs.getString("description") +
" WHERE cid="+ id;
stmt = con.createStatement();
rows = stmt.executeUpdate(sql);
con.commit();
stmt.close();
}
}

61
/* Source Code of Display Product - DisplayProduct.java*/

import java.sql.*;
import java.text.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class DisplayProduct extends HttpServlet {

static String show;


static String whereClause;
static Connection con; //database connection object

public void doGet(HttpServletRequest req, HttpServletResponse res)


throws IOException, ServletException{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
String menu = req.getParameter("menu");
if(menu!=null){res.sendRedirect("http://localhost:8080/test/inventorymenu.html");}
String logout = req.getParameter("logout");
if(logout!=null){res.sendRedirect("http://localhost:8080/test/login.html");}
show = req.getParameter("showall");
out.println("<html>");
out.println("<body>");
out.println("<center>");
out.println("<table border=1><tr align=middle>");
out.println("<th>PID</th><th>CID</th><th>NAME</th><th>PRICE</th>
<th>QUANTITY</th>"+"<th>DANGERLEVEL</th><th>SUPPLIER</th>
<th>CONTACT</th><th>DES_URL</th><th>DESCRIPTION</th></tr>");

// JDBC-ODBC bridge driver


try{Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(Exception e){};

// Open the database and display all rows in a table


try{open();}catch(Exception e){};
try{select(out, whereClause);}catch(Exception e){out.println(e);};
try{close();}catch(Exception e){};
out.println("</table>");
out.println("<a href=http://localhost:8080/test/inventorymenu.html>Back</a>");
out.println("</center></body>");
out.println("</html>");
}

// Open a database connection


static void open() throws SQLException{

62
// ODBC data source name
String dsn = "jdbc:odbc:SCMDB";
String user = "";
String password = "";

// Connect to the database


con = DriverManager.getConnection(dsn, user, password);

// Turn off autocommit


con.setAutoCommit(false);
}

// Commit all pending transactions and close the database connection


static void close() throws SQLException
{
con.commit();
con.close();
}

// a SQL query with a WHERE clause


static void select(PrintWriter out, String whereClause) throws SQLException{
Statement stmt; // SQL statement object
String query; // SQL select string
ResultSet rs; // SQL query results
boolean more; // more rows found
query = "SELECT pid, cid, pname, desurl, price, stockqty, dangerlevel,
description, supplier, contact_mail" + " FROM product ";
stmt = con.createStatement();
rs = stmt.executeQuery(query);

// Check to see if any rows were read


more = rs.next();
if(!more){
System.out.println("No rows found!");
return;
}

// Loop through the rows retrieved from the query


while(more){
out.print("<tr>"+"<td>" + rs.getString("cid") + "</td>");
out.print("<td>" + rs.getString("pid") + "</td>");
out.print("<td>" + rs.getString("pname") + "</td>");
out.print("<td>" + rs.getString("desurl") + "</td>");
out.print("<td>" + rs.getString("price") + "</td>");
out.print("<td>" + rs.getString("stockqty") + "</td>");
out.print("<td>" + rs.getString("dangerlevel") + "</td>");
out.print("<td>" + rs.getString("description") + "</td>");
out.print("<td>" + rs.getString("supplier") + "</td>");
out.print("<td>" + rs.getString("contact_mail") + "</td></tr>\n");
more = rs.next();

63
}
rs.close();
stmt.close();
}
}

64
/* Source Code of Logout - LogoutServlet.java*/
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class LogoutServlet extends HttpServlet{

public void doPost(HttpServletRequest req, HttpServletResponse res)


throws ServletException, IOException{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
String logout = req.getParameter("logout");
if(logout != null){res.sendRedirect("http://localhost:8080/test/login.html");}
}

public void doGet(HttpServletRequest req,HttpServletResponse res)


throws ServletException, IOException{
doPost(req, res);
}
}

65
APPENDIX B
KSI Inventory Management System

The main purpose of this web-based inventory management system is to

implement a real world case. The system runs on KSI (Knowledge Systems Institute)

website. It is used for maintaining bookstores inventory in a database. The system is a

password-protected system that can be accessed only by users who have sufficient

privileges. It begins with an entry page, booklogin.html. When logging into the main

menu web page, a user can access the database. The system provides four functions to

users: adding, deleting, modifying, and displaying books.

Figure 1 The System Flow of KSI Inventory Management System


66
There are seven HTML files and eight JSP files in this system. The following

table contains the complete files list.

File Description

booklogin.html is an entry web page.


Login.jsp checks whether a user is authorized to access the system. If
so, logs into the system; otherwise, throws up an error page.
bookmain.html is a main menu web page.
addbook.html shows a form for user to fill in data.
AddBook.jsp stores data into books table in database and returns a
confirmation page to user.
delbook.html lets user deleting data by isbn.
DelBook.jsp deletes data from books table in database and returns a
confirmation page to user.
modifybook.html lets user selecting a certain data by isbn.
ModifyBook.jsp shows the selecting data by user.
UpdateBook.jsp takes parameters from modifybook to update the data in
database.
displaybook.html shows all data in database.
DisplayBook.jsp retrieves all data in database.
booklogout.html passes logout request to Logout.jsp.
Logout.jsp gets request from booklogout and redirects the system to
initial login web page.
ErrPage.jsp receives and shows any error messages from any jsp files.

Table Appendix.1 The File List of KSI Web-Based Inventory Management System

67
Figure 2 The Entry Page of KSI Inventory Management System

Figure 3 The Main Menu Page of KSI Inventory Management System

68
Figure 4 The Adding Data Page of KSI Inventory Management System

Figure 5 The Confirmation Page of Adding Data in KSI Inventory Management System

69
Figure 6 The Deleting Data Page of KSI Inventory Management System

Figure 7 The Confirmation Page of Deleting Data in KSI Inventory Management System

70
Figure 8 The Searching Data Page of KSI Inventory Management System

Figure 9 The Modifying Data Page of KSI Inventory Management System

71
Figure 10 The Showing Data Page of KSI Inventory Management System

Figure 11 The Displaying All Data Page of KSI Inventory Management System
72
Figure 12 The Log Out Page of KSI Inventory Management System

73

You might also like