TPT Mens Club.docx - Home

moodusroundoSoftware and s/w Development

Aug 15, 2012 (4 years and 11 months ago)

386 views


Software Project Documents

TPT Men’s Club (Online Men’s Readymade Shopping)


Batch


: 2010
-
2013



Class


: II MCA

Course Code

: MCA414J



Course

: SOFTWARE PROJECT II


Team Members

P. Joe Nishant
h

(BM10518
)

T. Palanivel (BM10527
)

P. Santhosh Rao
(BM10545)



Department Of Computer Applications
,

Sacred Heart College (Autonomous),
Tirupattur
.



TABLE OF CONTENTS


S. No

C
ontents

Page No


1




2




3




4







5




6





Introduction

1.1

Abstract

1.2

Project Overview


System Analysis


2.1 System

Study


2.2 Feasibility

Study


System configuration


3.1
System Requirement Specification


3.
2

Hardware
&
Software Requirement Specification


System Design


4.1
Use Case Design



4.2
Architectural Diagram



4.3 Class

Diagram


4.4
Table Design


4.5
Component Diagram


System Implementation
and

Deployment


5.1 Implementation Report


5.2 Deployment Report


Software Testing


6.1
Software Testing


6.2 Test Cases

Design



3

3



3

5


6




10



11

12

12

15

15


16

17


19

19


7




8


9


10




Future Scope & Conclusion


7.1 Future Scope


7.2 Conclusion


Screenshots


Sample Source Code


Bibliography



21

21


24



24


42
















1.

Introduction

1.1.


Abstract


The Project entitled
as
"
TPT Men’s Club (
ONLINE
SHOPPING SYSTEM
)
" is
a
web
-
based application . The main aim of this

project "ONLINE SHOPPING SYSTEM"
is to improve the services of Customers. It maintains the information’s of customers and
products in detail, and updat
ing, deletion for the same. The

order

will be delivered to the
corresponding shipping address of the customer within 7 working days after the order
has been made. The primary features of the project entitled "ONLINE SHOPPING
SYSTEM" are high accuracy, design flexibility and easy availability
of products ordered
by the customer.

1.2.

Project Overview


An online representation of the products that are sold in the physical store.
Shopping cart functionality, which includes the ability to add items to a virtual shopping
cart, remove items from the shop
ping cart, update item quantities in the shopping cart,
view a summary of all items and quantities in the shopping cart, place an order and make
payment through a secure checkout process. An administration console, enabling staff to
view customer orders.

S
ecurity, in the form of protecting sensitive customer data while it
is transferred over the Internet, and preventing unauthorized access to the administration
console.

2.

System Analysis

2.1.

System Study


ONLINE SHOPPING SYSTEM


is an online shopping application, which
provides the online shopping facility available for everyone. Any type of the product
will be available for the customer, and it can be easily purchased faster when compair
with ebay. Shop online application concen
trates more on user friendly interfaces and
promotes users to purchase faster and easier. There is a facility available to do online
purchase. Shop online have registration facility. This will enable the new user to sign in
and use the product much effecti
vely. The registration process is faster and easier
compaired to any existing application.


In the User interface of Shop online there will be accomplished with options to
find new products available and most purchased and customer satisfied products.
Cus
tomer can avail this facility and buy the product faster. All products in the website
will be highlighted with the image of the product. By click on the image it will take you
directly to the buy page, from where customer can purchase easily.


Shop online

is provided with customer support page. Using this page any
customer can get the assistance from the available customer support executive online.
There we have Support over phone, email and chat. Customer can use this facility any
time.


As security issu
e pays major importance today, extra attention towards security is
done in Shop online application. We incorporate digital signature technique to ensure
much effective security for the customer. Digital signature will provide the secure data
transactions a
nd also during money transaction for purchase.

2.2.

Feasibility Study


Feasibility study is conducted once the problem is clearly understood. Feasibility
study is a high level capsule version of the entire system analysis and design process.
The objective is to

determine quickly at a minimum expense how to solve a problem.
The purpose of feasibility is not to solve the problem but to determine if the problem is
worth solving. The system has been tested for feasibility in the following points
.


2.2.1

Technical Fe
asibility
:

The project entitles "Project Monitoring System" is
technically feasibility because of the below mentioned feature. The project was
developed in Java which Graphical User Interface It provides the high level of
reliability, availability and comp
atibility. All these make Java an appropriate language
for this project. Thus the existing software Java is a powerful language.

2.2.2

Economical Feasibility
:

The computerized system will help in automate the
selection leading the profits and details of th
e organization. With this software, the
machine and manpower utilization are expected to go up by 80
-
90% approximately. The
costs incurred of not creating the system are set to be great, because precious time can be
wanted by manually.

2.2.3
. Operational F
easib
ility:

In this project, the management will know the details of
each project where he may be presented and the data will be maintained as decentralized
and if any inquires for that particular contract can be known as per their requirements
and necessa
ries.


3.

System configuration

3.1.

System Requirement Specification

3.1.1 Purpose


The Online Shopping web application is intended to provide solutions for
customers through a single get way using the internet as the sole medium. It will enable
vendors to setup
online shops, customer to browse through the shop and purchase them
online without having to visit the shop physically.

3.1.2 Scope

Initial functional requirements will be:
-




Secure Transaction facilities for Customers




Creating an Online Cart Shopping so that customers can shop ‘n’ no. of items
and checkout finally with the entire shopping




Maintaining database.




Shop employees are responsible for internal affairs like processing orders,
assure home delivery, gettin
g customer's delivery
-
time feedback, updating order's status
and answering client's queries online.




Feedback mechanism, so that customers can give feedback for the product or
service which they have purchased. Also facility rating of
individual products

by
relevant
customers

through phone
.

Initial non functional requirements will be:
-




Secure access of confidential data (user’s details).




24 X 7 availability




Better component design to get better performance at peak time




Advertisement space wh
ere it will effectively catch the customer’s attention and
as a source of revenue.


3.1.3 Definitions, Acronyms and Abbreviations

EJB
:

Enterprise Java Beans.



OS
:


Online Shopping

JAVA EE:

Java Enterprise Edition 5 is a programming platform


part of the Ja
va
Platform
-
for developing and running distributed multi
-
tier architecture Java
applications, based largely on modular software components running on an application
server.

HTTP
:
Hypertext Transfer Protocol is a transaction oriented client/server protocol
between a web browser & a Web Server.

HTTPS:

Secure Hypertext Transfer Protocol is a HTTP over SSL (secure socket layer).



TCP/IP:

Transmission Control Protocol/Internet Protocol, the suite of
communication protocols used to connect hosts on the Internet.
TCP/IP uses
several protocols, the two main ones being TCP and IP.

3.1.4 Technologies to be used

Programming languages:

JAVA EE: Java Enterprise Edition is a programming platform


part of the Java
Platform
-
for developing and running distributed multi
-
tier

architecture Java
applications, based largely on modular software components running on an application
server.

HTML, XML: Hyper Text Markup Language and Extensible markup Language are the
predominant markup languages for web pages. It provides a means to
describe the
structure of text
-
based information in a document and to supplement that text with
interactive forms
, embedded
images
, and other objects.

Tools & Development Environment

Glassfish
Server

3
:
Glassfish

is a Servlets container developed by the
Ne
tbeans Software
Foundation (N
SF). Tomcat implements the Java Servlet and the JavaServer Pages (JSP)
specifications from Sun Microsystems, and provides a "pure Java" HTTP web server
environment for Java code to run.



NET BEAN’S J2EE: Netbeans
is a toolkit wh
ich is designed for the creation of
complex projects, providing fully dynamic web application utilizing EJB’s. This
consist of EJB tools , CMP ,data mapping tools & a universal test client that is
designed to aid testing of EJB’s.

3.1.5 Overview


It gives
what level of proficiency is expected of the user, some general constraints
while making the software and some assumptions and dependencies that are assumed
Overall Description

3.1.6 Product perspective


OS is aimed towards the vendors who want to reach ou
t to the maximum cross
-
section of customer and common people who can be potential customer. This project
envisages bridging the gap between the seller, the retailer and the customer. OS should
be user
-
friendly, ‘quick to learn’ and reliable software for th
e above purpose. OS is
intended to be a stand
-
alone product and should not depend on the availability of other
software. It should run on both UNIX and Windows based platform.

3.1.7 Product functions


User: OS

Administrator



Functions: The OS Administrato
r is the super user and has complete
control over all the activities that can be performed. The application notifies the
administrator of all shop creation requests, and the administrator can then approve or
reject them. The administrator also manages the
list of available product categories. The
administrator can also view and delete entries in the guestbook.


User: Shop Owner



Functions: Any user can submit a shop creation request through the
application. When the
request is approved by the
Administrator, the requester is notified,
and from there on is given the role of Shop Owner. The Shop Owner is responsible for
setting up the shop and maintaining it. The job involves managing the sub
-
categories of
the items in the shop. Also, the shop own
er can add or remove items from his shop. The
Shop Owner can view different reports that give details of the sales and orders specific
to his shop. The Shop Owner can also decide to close shop and remove it from the mall.


User: OS Customer/Guests



Functi
ons: An OS Customer can browse through the shops and choose
products to place in a virtual shopping cart. The shopping cart details can be viewed and
items can be removed from the cart. To proceed with the purchase, the customer is
prompted to login. Also,

the customer can modify personal profile information (such as
phone number and shipping address) stored by the application. The customer can also
view the status of any previous orders, and cancel any order that has not been shipped
yet.


User: Employees

Functions: Purchase department under a Purchase manager to overlook purchasing
activities if warehousing needs arise.

Functions: Sales department under a Sales manager who will look after the sale of
products and services, the most important activity.

Func
tions: Accounts department under an Accounts manager to look after the
accounting activities of the enterprise

3.1.8 User characteristics

The user should be familiar with the OS related terminology like online Shopping .The
user should be familiar with the

Internet.

3.1.9 Constraints

There is no maintainability of back up so availability will get affected.

Limited to HTTP/HTTPS.

Administrator:



Database Management:

Control the database and keep track of all records of
customers and employee details.



View all details:
View the details of all employees and control the whole site.



Advertising the Site:

Responsible for making advertisements for the site.

Customers:



View Item
Details:

Can view/edit his personal details, payment details, and

details about
services provided.



Purchasing:

Can purchase any product through valid credit card.



Giving Feedback to Customer Care:

Can give feedback to the 24X7 Customer Care
Service center about their impression for the site and services

through phone
.

Shop Owner:



Taki
ng Permission from Administrator:
Vendors must take permission from the
Administrator for selling their products under the site. Administrator will test product’s
quality according to its market price to permit vendor for selling purpose.



Consulting with A
dministrator:

Can consult with the Administrator regarding
product’s quality and advertisements.



Advertising Vendor’s Own Products:

Responsible for making advertisements of his
products, but the site will not be responsible for any kind of advertisements a
bout
products.

Sales Manager:



View customer details:
View the personal details of the customer.



Managing Sales to Customers:
Responsible for properly allocating the selected product
according to the customer’s choice and delivering product to the customer.



View Product Stocks:
Keep track of each product item’s stocks for selling purpose.



Contacting with Administrator:
Responsible for informing administrator when any
product item’s stock goes under the minimum level.

Customer Care:



Getting Feedback from the
Customers:
Responsible for receiving complaints,
queries and feedback from the customers

through phone only
.



Providing Solutions to Customers:
Provide feasible solutions to the customers on
their complaints and queries

through phone only
.

3.2.

Hardware &
Software Requirement Specification

Minimum Hardware
Requirements:

i)

Microsoft Windows XP Professional SP3:



Processor: 800MHz Intel Pentium III or equivalent



Memory: 512 MB



Disk space: 750 MB of free disk space

ii)

Microsoft Windows Vista:



Processor: 8
00MHz Intel Pentium III or equivalent



Memory: 512 MB



Disk space: 750 MB of free disk space

Software Requirement Specification
:



NetBeans

IDE

6.9



GlassFish

3.0
, a Java EE application server





MySQL, a relational database management server (RDBMS)



MySQL WorkBench

5.2
, a visual database design tool

4.

System Design

4.1.

Use Case Diagram







4.2.

Architectural Diagram




Client Middle level Online Database

4.3.

Class Diagram

















4.4.

Table Design


4.5.

Component Diagram



5.

System Implementation and Deployment

5.1.

Implementation Report

5.1.1
Purpose


The purpose of the document is explained in the following sections, to view the
details of the cases development environment, implementation and execution are
discussed in detail. Accessing and processing of data are implemented in a GUI
environment using

JSP,

EJB, which provides greater flexibility and user friendliness
during execution. The web pages are implemented in system section and managed by the
systems engineer. Proper privileges to access the web pages are set by the systems
engineer based on th
e user ID.

5.1.2
Development Environment


The development environment is crucial for the development of any software tool.

Suitable selection of hardware and software not only reduces development time but also

ensures product success.


The hardware and software used for
SMP

development are discussed in length below
.


Hardware Requirement
:



Intel
Processor: 800MHz Intel Pentium III or equivalent




512 MB

Ram



750 MB of free disk space



Other standard desktop PC components.

Software Requiremen
t
:



TPT Mens Club

was developed using the
EJB
.



JDK 1.6 and EJB
: Used to run application programs.



Glassfish 3.0
: Web server used to store resource files.



Visual Paradigm 3.4
: UML modeling(
Used to Draw Activity diagram, C
omponent
diagram, Use Case diagram,
Deployment diagram
, Class design, Sequence diagram,
Data Flow Diagram
)



My SQL: U
sed to store the details of the data.



Integrated Development Environment: Net beans IDE

6.9

5.1.3
Implementation


Implementation of
TPT Men’s Club

was done using the Java language. Different
classes were written to handle different functionalities.

Each and every module can be
run independently and also in a sequence starting from the first module until the last.
The same system can be viewed and ac
cessed at the same time on different machines
completely in the network. Once installed, applications are often used for many years
without any problems. However, both the company and the users will change, and the
environment will be different over months

and years. Therefore the application will
undoable have to be maintained. Modifications and changes will be made to software
files or procedures to meet emerging user requirements.

5.1.4
Summary


This System implementation, listed in detail on the hardware, software
requirement and during development. Other than that, it more importantly touched on
the implementation of
TPT Men’s Club.

5.2.

Deployment Report

5.2.1
Introduction


Software deployment is al
l of the activities that make a software system available
for use. The general Deployment process consists of several interrelated activities with
possible transitions between them. These activities can occur at the producer site or at
the consumer site

or

both. "Deployment" should be interpreted as a
general process
that
has to be customized according to specific requirements or characteristics.

5.2.2
Deployment Activities


The developed system is exported as executable web archive file (called WAR)

from
the Integrated Development Environment Net beans. Now the WAR file can be

executed with the help of any web Server supports java execution.




Install and Activate
:


In our case, I took apache tomcat web server for installing the application judicial

bio
graphy. There are
,


1. Place the WAR file in to the webapps in the
glassfish

directory. i.e.
glassfish
/webapps directory.


2. Start the tomcat by activating the file in the
glassfish
/bin directory.


3. Go to web browser and type the hostname, port and WAR
file name.



i.e. http://localhost:8080/
tptmensclub
/


4. The index

page will be displayed to the above URL as in the
browser.

Activate
:



Start the admin server for web logic server domain

(EJB Server)
.



The Start the
Glassfish 3.0
.



Imports jar Files (i.e.
dist
, tools, test, etc).

Set the index page.



Compile the web application.



Http://hostname:port number/
tptmensclub

(i.e. http://localhost/metadata/).



Login /Logout.

Deactivate:

Stop the web logic server domain and tomcat file in the apache
-
tomcat/bin direc
tory.

Uninstall:


By removing the application WAR file and its extracted directory means that the
application is uninstalled from the server.

5.2.3

Summary


The deployment
of the TPT Men’s Club

is dealt in this document with set of
activities such as Relea
se, Install and Activate, Deactivate and Uninstall
.

5.2.4

Deployment Diagram


6.

Software Testing

6.1.

Software Testing


The first includes unit testing, where in each module is tested to provide its
Correctness, validity and also determine any missing operations

and to verify whether
the objectives have been met. Errors are noted down and corrected immediately. Unit
testing is the important and major part of the project. So errors are rectified easily in
particular module and program clarity is increased. In this

project entire system is
divided into several modules and is developed individually. So unit testing is conducted
to individual modules.



The second step includes Integration testing. It need not be the case, the software
whose modules when run individua
lly and showing perfect results, will also show
perfect results when run as a whole. The individual modules are clipped under this major
module and tested again and verified the results. This is due to poor interfacing, which
may results in data being lost

across an interface. A module can have inadvertent,
adverse effect on any other or on the global data structures, causing serious problems.


The final step involves validation and testing which determines which the
software functions as the user expected.

Here also some modifications were. In the
completion of the project it is satisfied fully by the end user

6.2.

Test Case Design

Test Case Number:

1

Test Case Name:

Unit test

Project:

TPT Men’s Club

Module:

Cart



Test Case Author:

Nishant

Tester:

Nishant

Test Case Setup

Enter the username, password
.

Test Step

Anticipated Result

Pass/Fail


Test whether the system accepts
the entered input details.

It must accept the input details.

P
ass

Test Case Number:

2

Test Case Name:

Unit test

Project:

TPT Men’s
C汵l

䵯摵je:

Ca瑥tory

呥獴⁃a獥⁁畴桯 :

ma污湩癥l

呥獴敲:

ma污湩癥l

Test Case Setup

Enter
the required inputs to create an account in the system.

Test Step

Anticipated Result

Pass/Fail


Test whether the system accepts
the entered input details.

It
must accept the input details.

P
ass

Test Case Number:

3

Test Case Name:

Unit test

Project:

TPT Men’s Club

䵯摵je:

䅤浩湩獴牡瑯t

呥獴⁃a獥⁁畴桯 :

pa湴桯n栠hao

呥獴敲:

pa湴桯n栠hao

Test Case Setup



7.

Future Scope & Conclusion

7.1.


Future Scope

Online payment module will be
added, New

technology or framework will ne
incorporated with this system.

7.2.

Conclusion


This project helps in understanding the creation of an interactive web page and
the technologies used to implement it. The building of the project has given me a precise
knowledge about how Glassfish Server application is used to develop a webs
ite, how it
connects to the database to access the data and how the data and web pages are modified
to provide the user with a shopping cart application.





8.

Screenshots

1.

Home Page

Browse the files in the specific folder.

Test Step

Anticipated Result

Pass/Fail


Test whether the system
accept
specific file.

I
t must accept the file.

P
ass


2.

Category Page


3.

Cart Page


4.

Checkout Page



5.

Confirmation Page



9.

Sample
Source Code

I)

Index.jsp


<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>


<%
--



Document : index


Created on : Apr 2, 2012, 5:57:08 PM

--
%>


<%@page contentType="text/htm
l" pageEncoding="UTF
-
8"%>

<!DOCTYPE HTML PUBLIC "
-
//W3C//DTD HTML 4.01 Transitional//EN"


"http://www.w3.org/TR/html4/loose.dtd">

<html>


<head>


<meta http
-
equiv="Content
-
Type" content="text/html; charset=UTF
-
8">


<title>TPT Mens Club<
/title>


<link href="css/tptmens.css" rel="stylesheet" type="text/css"


</head>


<body>


<div class="container">


<div class="top_div">


<div class="logo_div">


<a href="index.jsp"><img src="
img/logo.jpg" alt="" border="0" /></a>


</div><!
--

End of Logo Div
--
>


<div class="top_mid_div">


<span class="arial_16">Sales and Support&nbsp;&nbsp; <span
class="arial_22">04179
-
225566</span></span>



</div>


</div><!
--

End of Top div
--
>


<img src="img/header.jpg" alt="header" width="939" height="230"/>


<div class="gap"></div>


<div class="galler_div">


<div id="motioncontainer" sty
le="position: relative; overflow: hidden;
max
-
width: 1000px;">


<div id="motiongallery" style="position: absolute; left: 0.243301px; top:
0pt; white
-
space: nowrap;">


<nobr id="trueContainer">



<div id="updatecat">


<table id="dlistimage" style="width: 100%; border
-
collapse:
collapse;" border="0" cellspacing="0">


<tbody>


<tr>



<c:forEach var="category" items="${categories}">


<td>


<a href="category?${category.id}"><img
id="dlistimage_ctl03_imagec
at"
src="${initParam.categoryImagePath}${category.name}.jpg" style="height: 186px;
width: 155px; border
-
width: 0px;" alt="${category.name}"/></a>


</td>


</c:forEach>


</tr>


</tbody>


</table>


</div>


</nobr>


</div>


</div>


</div> <!
--

End of Gallery Div
--
>


<div class="content_div">


<div class="tellyourfrind_login_div">


<h1>Tptmensclub Online deals in world class online clothes shopping
portal</h1> <div class="gap">
</div>


<marquee behavior="scroll" direction="up" scrollamount="3"
height="125px" scrolldelay="302" onmouseover="this.stop();"
onmouseout="this.start();">



Tptmensclub.com is the biggest, fastest growing online
-
jeans store in the

world having proficiency in the jeans market. The store designs, manufactures and
delivers customized jeans and casual clothing across the globe. Tptmensclub.com is
the outstanding, booming and renowned online brand of jeans.


</marquee
>


</div><!
--

End of Tell ur frnd Div
--
>


</div> <!
--

End of Content div
--
>


<div class="gap">


</div>


<div id="footer">


Created & © by Joe Nishant(BM10518), Palanivel(BM10527) &

Santhosh
Rao(BM10545).


</div>


</div><!
--

End of container div
--
> </body></html>

II)

Shopping Cart

public class ShoppingCart {


List<ShoppingCartItem> items;


int numberOfItems;


double total;


public ShoppingCart() {



items = new ArrayList<ShoppingCartItem>();


numberOfItems = 0;


total = 0;


}


public synchronized void addItem(Product product) {



boolean newItem = true;



for (ShoppingCartItem scItem : items) {



if (
scItem.getProduct().getId() == product.getId()) {



newItem = false;


scItem.incrementQuantity();


}


}



if (newItem) {


ShoppingCartItem scItem = new ShoppingCartItem(product);



items.add(scItem);


}


}




public synchronized void update(Product product, String quantity) {



short qty =
-
1;



// cast quantity as short


qty = Short.parseShort(quantity);



if (qty >= 0) {



ShoppingCartItem item = null;



for (ShoppingCartItem scItem : items) {



if (scItem.getProduct().getId() == product.getId()) {



if (qty != 0) {


// set item quantity to new value



scItem.setQuantity(qty);


} else {


// if quantity equals 0, save item and break


item = scItem;


break;


}


}



}



if (item != null) {


// remove from cart


items.remove(item);


}


}


}




public synchronized List<ShoppingCartItem> getItems() {



return items;


}




public

synchronized int getNumberOfItems() {



numberOfItems = 0;



for (ShoppingCartItem scItem : items) {



numberOfItems += scItem.getQuantity();


}



return numberOfItems;


}




public synchronized double getSubto
tal() {



double amount = 0;



for (ShoppingCartItem scItem : items) {



Product product = (Product) scItem.getProduct();


amount += (scItem.getQuantity() * product.getPrice().doubleValue());


}



return

amount;


}



public synchronized void calculateTotal(String surcharge) {



double amount = 0;



// cast surcharge as double


double s = Double.parseDouble(surcharge);



amount = this.getSubtotal();


amount += s;




total = amount;


}



public synchronized double getTotal() {



return total;


}


public synchronized void clear() {


items.clear();


numberOfItems = 0;


total = 0;


}

}

III)

Controller Servlet

package

controller;


import cart.ShoppingCart;

import entity.Category;

import entity.Product;

import java.io.IOException;

import java.util.Collection;

import java.util.Map;

import javax.ejb.EJB;

import javax.servlet.ServletConfig;

import javax.servlet.ServletExce
ption;

import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;

import javax.swing.JOptionPane;

im
port session.CategoryFacade;

import session.OrderManager;

import session.ProductFacade;

import validate.Validator;

@WebServlet(name = "ControllerServlet", loadOnStartup = 1, urlPatterns =
{"/category", "/addToCart", "/viewCart",


"/updateCart",


"/ch
eckout",


"/purchase"})

public class ControllerServlet extends HttpServlet {



private String surcharge;


@EJB


private CategoryFacade categoryFacade;


@EJB


private ProductFacade productFacade;


@EJB


private OrderManager
orderManager;



@Override


public void init(ServletConfig servletConfig) throws ServletException {



super.init(servletConfig);


surcharge =
servletConfig.getServletContext().getInitParameter("deliverySurcharge");



// store cate
gory list in servlet context


getServletContext().setAttribute("categories", categoryFacade.findAll());


}



// <editor
-
fold defaultstate="collapsed" desc="HttpServlet methods. Click on the +
sign on the left to edit the code.">


@Override


protected void doGet(HttpServletRequest request, HttpServletResponse response)


throws ServletException, IOException {



String userPath = request.getServletPath();


HttpSession session = request.getSession();


Category
selectedCategory;


Collection<Product> categoryProducts;



// if category page is requested


if (userPath.equals("/category")) {


// get categoryId from request


String categoryId = request.getQueryString();



if (categoryId != null) {


// get selected category


selectedCategory = categoryFacade.find(Short.parseShort(categoryId));



// place selected category in request scope


request.setAtt
ribute("selectedCategory", selectedCategory);



// get all products for selected category


categoryProducts = selectedCategory.getProductCollection();



// place category products in request scope



request.setAttribute("categoryProducts", categoryProducts);


}




} // if cart page is requested


else if (userPath.equals("/viewCart")) {


// TODO: Implement cart page request



String clear = request.getPa
rameter("clear");



if ((clear != null) && clear.equals("true")) {



ShoppingCart cart = (ShoppingCart) session.getAttribute("cart");


cart.clear();


}



userPath = "/cart";



// if checkout page is requested


}



else if (userPath.equals("/checkout"))


{




//userPath="/checkout";



String url = "/WEB
-
INF/view/checkout.jsp";


JOptionPane.showConfirmD
ialog(null, "After String URL Line
Declaration..");



try{



ShoppingCart cart = (ShoppingCart) session.getAttribute("cart");


// calculate total


cart.calculateTotal(surcharge);


// forward to checkou
t page and switch to a secure channel



request.getRequestDispatcher(url).forward(request, response);


}


catch(Exception e)


{


System.out.println(" An Expected Exception Occured..!");


}



}



// use RequestDispatcher to forward request internally


String url = "/WEB
-
INF/view" + userPath + ".jsp";



try {


request.getRequestDispatcher(url).forward(request, response);


} catch (Exc
eption ex) {


ex.printStackTrace();


}




}



@Override


protected void doPost(HttpServletRequest request, HttpServletResponse response)


throws ServletException, IOException {



String userPath = request.getSer
vletPath();



HttpSession session = request.getSession();


ShoppingCart cart = (ShoppingCart) session.getAttribute("cart");


Validator validator = new Validator();



// if addToCart action is called


if (userPath.equals
("/addToCart")) {


// if user is adding item to cart for first time


// create cart object and attach it to user session


if (cart == null) {


cart = new ShoppingCart();


session.setAttribute("
cart", cart);


}



// get user input from request


String productId = request.getParameter("productId");



if (!productId.isEmpty()) {



Product product = productFacade.find(Integer.parseInt(produc
tId));


cart.addItem(product);


}



userPath = "/category";



} else if (userPath.equals("/updateCart")) {



// get input from request


String productId = request.getParameter("productId");


String quantity = request.getParameter("quantity");



boolean invalidEntry = validator.validateQuantity(productId, quantity);



if (!invalidEntry) {



Product product = productFacade.find(Integer.parseInt(
productId));


cart.update(product, quantity);


}



userPath = "/cart";




} else if (userPath.equals("/purchase")) {


if (cart != null) {



// extract user data from request



String name = request.getParameter("name");


String email = request.getParameter("email");


String phone = request.getParameter("phone");


String address = request.getParameter("address");


St
ring cityRegion = request.getParameter("cityRegion");


String ccNumber = request.getParameter("creditcard");





// validate user data


boolean validationErrorFlag = false;


validationErrorFlag =
validator.validateForm(name, email, phone, address,
cityRegion, ccNumber, request);



// if validation error found, return user to checkout


if (validationErrorFlag == true) {


request.setAttribute("
validationErrorFlag", validationErrorFlag);


userPath = "/checkout";



// otherwise, save order to database


} else {


int orderId = orderManager.placeOrder(name, email, phone, address,
ci
tyRegion, ccNumber, cart);


if (orderId != 0) {



// dissociate shopping cart from session


cart = null;



// end session


session.invalidate();




// get order details


Map orderMap = orderManager.getOrderDetails(orderId);



// place order details in request scope


request.setAttribute("customer", orderMap.get("
customer"));


request.setAttribute("products", orderMap.get("products"));


request.setAttribute("orderRecord", orderMap.get("orderRecord"));


request.setAttribute("orderedProducts",
order
Map.get("orderedProducts"));



userPath = "/confirmation";



// otherwise, send back to checkout page and display error


} else {


userPath = "/checkout";


request.setAttribute("orderFailureFlag", true);


}


}


}



userPath = "/confirmation";


}



// use RequestDispatcher to forward request internally


String
url = "/WEB
-
INF/view" + userPath + ".jsp";



try {


request.getRequestDispatcher(url).forward(request, response);


} catch (Exception ex) {


ex.printStackTrace();


}


}


@Override


public String getServle
tInfo() {


return "Short description";


}// </editor
-
fold>

}

10.

Bibliography


Articles

1. Chen, L. (2000). Enticing Online Consumers: A Technology Acceptance

Perspective Research
-

in
-
Progress.
ACM Proceedings, SIGCPR
.

2. Diwakar, H., Marathe, M.
(2000). The architecture of a one
-
stop web
-
window

shop. December,
ACM SIGecom Exchanges
, Volume 2 Issue 1.

3. Morrison, M., Morrison, J., and Keys, A. (2002). Integrating Web Sites and

Databases
. Communications of the ACM
, September, Volume 45, Issue 9.

4.

Kubilus, N. J. (2000). Designing an e
-
commerce site for users. September 2000,

Crossroads
, Volume 7 Issue 1.

5. Norman, D.A. The Design of Everyday Things.
Doubleday
, New York, 1994.

6. Tilson, R., Dong, J., Martin, S., Kieke, E. (1998). A comparison of t
wo current
ecommerce sites. September,
Proceedings of the 16th annual international

conference on Computer documentation
.