Shopping Cart
Shopping Cart
Shopping Cart
Session 2016-17
Project on
SHOPPING CART
Submitt
ed By
Syed Kumail Abbas
MCA 6th Sem
1
Shopping Cart
ACKNOWLEDGEMENT
Thank you lord for everything. With every passing day we feel more
and more of your presence, your protection and your love.
We never have words to say to you what we want to say. But thank
you very much.
Developed By: -
2
Shopping Cart
Chapter -1
3
Shopping Cart
Abstract
Shopping has evolved with the growth of technology. In recent years online shopping has
become popular and one who has a computer with Internet and a bank account can shop
from their home. Shopping online offers lots of benefits that one cannot find shopping in
a store or by mail. The Internet is always open seven days a week, 24 hours a day.
With a click of a mouse, one can buy an airline ticket, book a hotel, send flowers to a
friend, or purchase your favorite fashions.
A shopping cart is a software application that typically runs the Web server, and allows
customers to do things such as searching for a product in a store catalog, adding a
selected product to a basket, and placing an order for it. Once a particular product has
been found on the web site of the seller, most online retailers use shopping cart software
to allow the consumer to accumulate multiple items and to adjust quantities, just like
filling a physical shopping cart or basket in a conventional store.
Features:
User-friendly interface
Effective Product Search
Billing Report
Functionalities:
Store Front Module
Administration Module
Product Search Module
Billing Module
4
Shopping Cart
INTRODUCTION
INTRODUCTION
1.1 Purpose
The Shopping Cart application allows visitors to shop on-line to collect items in a virtual
shopping cart. They may view the contents of their shopping cart at any time. The
program automatically calculates the grand total. When a visitor decides to check-out,
5
Shopping Cart
the order information including the buyer's name, address and billing instruction is
recorded.
1.2 Scope
The scope of the project is very vast, as it targets large no of people residing over
the world. Anyone having the access to the internet can shop for their desired items. It
gained maximum users over the world.
Shopping has evolved with the growth of technology. In recent years online shopping
has become popular and one who has a computer with Internet and a bank account can
shop from their home. Shopping online offers lots of benefits that one cannot find
shopping in a store or by mail. The Internet is always open seven days a week, 24
hours a day. With a click of a mouse, one can buy an airline ticket, book a hotel, send
flowers to a friend, or purchase your favorite fashions.
A shopping cart is a software application that typically runs the Web server, and
allows customers to do things such as searching for a product in a store catalog, adding
a selected product to a basket, and placing an order for it. Once a particular product has
been found on the web site of the seller, most online retailers use shopping cart software
to allow the consumer to accumulate multiple items and to adjust quantities, just like
filling a physical shopping cart or basket in a conventional store.
The Shopping Cart application allows visitors to shop on-line to collect items in a
virtual shopping cart. They may view the contents of their shopping cart at any time. The
program automatically calculates the grand total. When a visitor decides to check-out,
the order information including the buyer's name, address and billing instruction is
recorded.
6
Shopping Cart
Our Shopping Cart application allows visitors to shop on-line to collect items in a
virtual shopping cart over multiple product web pages without losing the items ordered.
Our cart keeps track of what the shopper has ordered with a UID (User I.D). There are
no cookies used, so our software will work through a firewall and with older browsers.
In order for a shopping cart is to be useful, customers need to be able to add items
to their shopping carts as they browse web site. Shopping cart need to have a link next to
each product you sell that allows customers to add that particular product to their
shopping carts.
If any of the above-specified functions fail the corresponding error message will be
displayed which makes the project friendlier to the user. The application software is
developed with MySql database and GUI based front- end tool J2EE. The information
about the users is stored in the database in the related tables. All designing of pages are
done with JSPs and Java. Using Java Technologies makes our project more robust and
importantly portability over different systems. Java Server Pages have both HTML and
Java Code Technologies included and can use both of it.
Chapter -2
7
Shopping Cart
System Analysis
PROBLEM DEFINITION
8
Shopping Cart
The first step of preliminary study in the system analysis process involves the
identification of needs for computerization. The motivation behind this project is to
overcome all the defects in the existing system.
Cart application allows visitors to shop on-line to collect items. Shoppers may view the
contents of their shopping cart at any time. The program automatically calculates the
subtotal and grand total. When a visitor decides to checkout, the order information
including the buyer's name, address and billing instruction is recorded in the system for
future references.
9
Shopping Cart
10
Shopping Cart
In this module the store administrator will add new products to the site. Here the
products will be grouped into various categories. Administrator will enter all the
information about product including its brand, price, discount, manufacture date and its
category. The admin can update already added products.
In this module products are grouped into various categories. Products from a particular
category will be displayed when the user clicks a particular category. Here this
categorization is made at the time of product entry by admin. He will insert a product
into its category. The result of this search is the list of products from a selected category.
Billing Module:
This is the cart module where it contains all the products which the user has shopped. As
the customer browse through the products he can add products to the cart. The cart
contains product information and its billing information along with discount. And these
11
Shopping Cart
details will be present to the user for check out. The cart contents will be saved into the
database once the user checks out.
12
Shopping Cart
Chapter 3
FEASIBILITY STUDY
13
Shopping Cart
3. FEASIBILITY STUDY:
The next step in analysis is to verify the feasibility of the proposed system. All
projects are feasible given unlimited resources and infinite time. But in reality both
resources and time are scarce. Project should confirm to time bounce and should be
optimal in there consumption of resources. This place a constant is approval of any
project.
Technical feasibility
Operational feasibility
Economical feasibility
To determine whether the proposed system is technically feasible, we should take into
consideration the technical issues involved behind the system.
Shopping Cart uses the web technologies, which is rampantly employed these
days worldwide. The world without the web is incomprehensible today. That goes to
proposed system is technically feasible.
14
Shopping Cart
15
Shopping Cart
SYSTEM DESIGN
System design is transition from a user oriented document to programmers or
data base personnel. The design is a solution, how to approach to the creation of a new
system. This is composed of several steps. It provides the understanding and procedural
details necessary for implementing the system recommended in the feasibility study.
Designing goes through logical and physical stages of development, logical design
reviews the present physical system, prepare input and output specification, details of
implementation plan and prepare a logical design walkthrough.
SOFTWARE DESIGN
1. Modularity and partitioning: software is designed such that, each system should
4. Shared use: avoid duplication by allowing a single module is called by other that need
16
Shopping Cart
Shopping
Customer
Cart
Shopping
Manager Cart
17
Shopping Cart
Edit
product Product db
View
Sales db
sales
report
18
Shopping Cart
Customer:
View
products Product DB
cu
st Add
Cart db
o product
m to cart
er
View Cart db
cart
Check
out Sales db
19
Shopping Cart
Use Case:
20
Shopping Cart
reguster
login
add products
view products
customer
manager
edit products
add product to cart
checkout
21
Shopping Cart
Login Sequence:
User
login()
forwardPage() response()
viewpage()
22
Shopping Cart
Manager
addProduct()
forwardPage() response()
viewpage()
23
Shopping Cart
View Products:
Customer
viewProducts()
sendRequest() fetchData()
forwardDetails() response()
viewProducts()
24
Shopping Cart
Cart:
Customer
addtoCart()
insertintocart() insertData()
forwardDetails() response()
viewpage()
checkout()
sendCartDetails()
insertCartDetails()
25
Shopping Cart
Activity Diagram:
26
Shopping Cart
Login
if admin
if customer
Manager
Customer
manage products
view products
checkout
logout
Class Diagram:
27
Shopping Cart
Cart Customer
cartid:int cid:int
subtotal:float cname:String
total:float address:String
phno:String
paymenttype:String
addItem() login()
checkout() viewProducts()
addtoCart()
checkout()
logout()
Sales
pid:int
uid:int
pname:String
price:String
Product total:float
pid:int add()
pname:String view()
mrp: float
discount:String Manager
mdate:date
uid:int
username:String
add() password:String
delete()
addProduct()
editProduct()
deleteProduct()
28
Shopping Cart
TABLE: USERS
TABLE: CATEGORIES
TABLE: PRODUCTS
29
Shopping Cart
TABLE: CART
TABLE: SALES_REPORT
4.4 ER Diagram
30
Shopping Cart
uid lnam
e
fnam cid cname
Uname
e
contai imagenam
pid uid
ns mfd brand e
cart pname
total price
qty
addedt
o
pid qty
Salesreport
total
uid pname
31
Shopping Cart
5 INPUT/OUTPUT DESIGN
Input design: considering the requirements, procedures to collect the necessary input
data in most efficiently designed. The input design has been done keeping in view that,
the interaction of the user with the system being the most effective and simplified way.
Output design: All the screens of the system are designed with a view to provide the
user with easy operations in simpler and efficient way, minimum key strokes possible.
Instructions and important information is emphasized on the screen. Almost every screen
is provided with no error and important messages and option selection facilitates.
Emphasis is given for speedy processing and speedy transaction between the screens.
Each screen assigned to make it as much user friendly as possible by using interactive
procedures. So to say user can operate the system without much help from the operating
manual.
32
Shopping Cart
Chapter -6
IMPLEMENTATION
33
Shopping Cart
Html is a language which is used to create web pages with html marking up a page to
indicate its format, telling the web browser where you want a new line to begin or how
you want text or images aligned and more are possible.
TABLE:
Tables are so popular with web page authors is that they let you arrange the elements of a
web page in such a way that the browser wont rearrange them web page authors
frequently use tables to structure web pages.
<TR>:
<TR> is used to create a row in a table encloses <TH> and
<TD> elements. <TR> contain many attributes. Some of them are,
ALIGN: specifies the horizontal alignment of the text in the
table row.
BGCOLOR: Specifies the background color for the row.
BORDERCOLOR: Sets the external border color for the row.
VALIGN: Sets the vertical alignment of the data in this row.
<TH>:
<TH> is used to create table heading.
ALIGN: Sets the horizontal alignment of the content in the table
cell. Sets LEFT, RIGHT, CENTER.
BACKGROUND: Species the back ground image for the table
cell.
BGCOLOR: Specifies the background color of the table cell
34
Shopping Cart
FRAMES:
Frames are used for either run off the page or display only small
slices of what are supposed to be shown and to configure the frame we can use
<FRAMESET>there are two important points to consider when working with
<FRAMESET>.
<FRAMESET> element actually takes the place of the <BODY> element
in a document.
Specifying actual pixel dimensions for frames.
35
Shopping Cart
ATTRIBUTES:
ACTION: Gives the URL that will handle the form data.
CONTROLS IN HTML
36
Shopping Cart
<INPUT TYPE=RADIO>:
Creates a radio button in a form.
ATTRIBUTE:
NAME: Gives the element a name. Set to alphanumeric character.
VALUE: Sets the default content of the element.
<INPUT TYPE=SUBMIT>:
Creates a submit button that the user can click to send data in the form back to the
web server.
ATTRIBUTES:
NAME: Gives the element a name. Set to alphanumeric characters.
VALUE: Gives this button another label besides the default, Submit Query. Set to
alphanumeric characters.
<INPUT TYPE=TEXT>:
Creates a text field that the user can enter or edit text in.
ATTRIBUTES:
NAME: Gives the element a name. Set to alphanumeric characters.
VALUE: Holds the initial text in the text field. Set to alphanumeric characters.
37
Shopping Cart
JAVASCRIPT METHODS:
Writeln:
Document.writeln() is a method, which is used to
write some text to the current web page.
onClick:
Occurs when an element is clicked.
onLoad:
Occurs when the page loads.
onMouseDown:
Occurs when a mouse button goes down.
onMouseMove:
Occurs when the mouse moves.
onUnload:
Occurs when a page is unloaded.
38
Shopping Cart
6.3 MySQL
The database has become an integral part of almost every human's life. Without
it, many things we do would become very tedious, perhaps impossible tasks. Banks,
universities, and libraries are three examples of organizations that depend heavily on
some sort of database system. On the Internet, search engines, online shopping , and
even the website naming convention (http://www...) would be impossible without the use
of a database. A database that is implemented and interfaced on a computer is often
termed a database server.
One of the fastest SQL (Structured Query Language) database servers currently on the
market is the MySQL server.MySQL, available for download, offers the database
programmer with an array of options and capabilities rarely seen in other database
servers. What's more, MySQL is free of charge for those wishing to use it for private and
commercial use. Those wishing to develop applications specifically using MySQL should
consult MySQL's licensing section, as there is a charge for licensing the product.
These records, in turn, are made up of the smallest object that can be manipulated by the
user, known as the data type. Together, one or more of these data types form a record. A
39
Shopping Cart
table holds the collection of records that make up part of the database. We can consider
the hierarchy of a database to be that of the following:
Datatypes come in several forms and sizes, allowing the programmer to create tables
suited for the scope of the project. The decisions made in choosing proper datatypes
greatly influence the performance of a database, so it is wise to have a detailed
understanding of these concepts.
MySQL Datatypes
MySQL is capable of many of the datatypes that even the novice programmer has
probably already been exposed to. Some of the more commonly used include:
CHAR(M)
CHAR's are used to represent fixed length strings. A CHAR string can range from 1-255
characters. In later table creation, an example CHAR datatype would be declared as
follows:
ex.
car_modelCHAR(10);
VARCHAR(M)
VARCHAR is a more flexible form of the CHAR data type. It also represents data of type
String, yet stores this data in variable length format. Again, VARCHAR can hold 1-255
characters. VARCHAR is usually a wiser choice than CHAR, due to it's variable length
format characteristic. Although, keep in mind that CHAR is much faster than
VARCHAR, sometimes up to 50%.
(A CHAR stores the whole length of the declared variable, regardless of the size of the
data contained within, whereas a VARCHAR only stores the length of the data, thus
reducing size of the database file.)
ex.
car_modelVARCHAR(10);
40
Shopping Cart
INT(M)[Unsigned]
The INT datatype stores integers ranging from -2147483648 to 2147483647. An optional
"unsigned" can be denoted with the declaration, modifying the range to be 0 to
4294967295
ex.
light_yearsINT;
Valid integer: '-24567'. Invalid integer: '3000000000'.
ex.
light_yearsINTunsigned;
Valid integer: '3000000000'. Invalid integer: '-24567'.
FLOAT[(M,D)]
A FLOAT represents small decimal numbers, used when a somewhat more precise
representation of a number is required.
ex.
rainfallFLOAT(4,2);
This could be used to represent rainfall average in centimeters per year, which could be a
decimal value. More specifically, FLOAT (4,2) states the fact that rainfall can hold up to
four characters and two decimal places. Thus,
Note: Due to the fact that FLOAT is rounded, those wishing to represent money values
would find it wise to use DECIMAL, a datatype found within MySQL that does not round
values. Consult the documentation for a complete explanation.
DATE
Stores date related information. The default format is 'YYYY-MM-DD', and ranges from
'0000-00-00' to '9999-12-31'. MySQL provides a powerful set of date formatting and
41
Shopping Cart
manipulation commands, too numerous to be covered within this article. However, one
can find these functions covered in detail within the MySQL documentation.
the_dateDATE;
TEXT/BLOB
The text and blob datatypes are used when a string of 255 - 65535 characters is required
to be stored. This is useful when one would need to store an article such as the one you
are reading. However, there is no end space truncation as with VARCHAR AND CHAR.
The only difference between BLOB and TEXT is that TEXT is compared case
insensitively, while BLOB is compared case sensitively.
SET
A datatype of type string that allows one to choose from a designated set of values, be it
one value or several values. One can designate up to 64 values.
ex.
transportSET("truck","wagon")NOTNULL;
From the above declaration, the following values can be held by transport:
""
"truck"
"wagon"
"truck,wagon"
ENUM
A datatype of type string that has the same characteristics as the SET datatype, but only
one set of allowed values may be chosen. Usually only takes up one byte of space, thus
saving time and space within a table.
ex.
transportENUM("truck","wagon")NOTNULL;
From the above declaration, the following values can be held by transport:
42
Shopping Cart
""
"truck"
"wagon"
Records
Together, a group of declared datatypes form what is known as a record. A record can be
as small as one data variable, or as many as deemed needed. One or more records form
the structure of a table.
Before we can execute commands on the database, we must first create a table in which
data can be stored. This is accomplished in the following manner:
mysql>CREATETABLEtest(
>nameVARCHAR(15),
>emailVARCHAR(25),
>phone_numberINT,
>IDINTNOTNULLAUTO_INCREMENT,
>PRIMARYKEY(ID));
Ensuing output:
QueryOK,0rowsaffected(0.10sec)
mysql>
The first table in your database has now been created. Note: no two tables can have the
same name.
Note(2): Each dataspace is more often referred to as a column.
Column Characteristics:
43
Shopping Cart
The following options can be placed after any datatype, adding other characteristics and
capabilities to them.
Primary Key. Used to differentiate one record from another. No two records can
have the same primary key. This is obviously useful when it is imperative that no
two records are mistaken to be the other.
Auto_Increment. A column with this function is automatically incremented one
value (previous + 1) when an insertion is made into the record. The datatype is
automatically incremented when 'NULL' is inserted into the column.
NOT NULL. Signifies that the column can never be assigned a NULL value.
ex.
soc_sec_numberINTPRIMARYKEY;
ID_NUMBERINTAUTO_INCREMENT;
Insertion of records
Note: The originally created table, test, created in the last section will be used to illustrate
the examples in this section. Here it is again, for quick reference:
Insertion of data into the table is accomplished, logically enough, using the INSERT
command.
44
Shopping Cart
Selection
A database would not be much use if one was not able to search and extract data from it.
In MySql terms, this is accomplished through the SELECT statement.
Result:
name email phone ID
BugsBunny [email protected] 5554321 1
Let's assume we have inserted four differing records, all bearing the same name of "Bugs
Bunny", yet having different email addresses and phone numbers. The table test, would
look somewhat like the following:
Deletion
One can also delete records inserted into the table. This is accomplished through the
DELETE command.
45
Shopping Cart
Result:
This would result in the deletion of all records within the table test containing name
"Bugs Bunny".
Another example:
Modification
MySQL also has the capability of modifying data already entered into the table. This is
accomplished through the UPDATE command.
This section, we covered the core MySQL database manipulation functions, basic
insertion, deletion, modification, and search. The next section will elaborate on these
capabilities, providing extended functioning and flexibility when manipulating the
database.
What we have covered so far is but a small part of what MySQL is capable of. Let's delve
a little deeper into the language, exploring some of the more advanced commands of the
language.
46
Shopping Cart
Logical Operations
AND (&&)
Result:
All records containing the name "Bugs Bunny" AND the phone number '5554321' will be
displayed to the screen.
OR ( || )
Result:
All records containing the name "Bugs Bunny" OR the phone number '5554321' will be
displayed to the screen.
NOT ( ! )
Result:
All records NOT containing the name "Bugs Bunny" will be displayed to the screen.
Order By
47
Shopping Cart
Result:
All records containing the name "Bugs Bunny" will be displayed to the screen, ordered in
respect to the phone_number.
Search functions
MySQL offers the user the ability to perform both general and specific searches on data.
Result:
All records containing the partial string "gs Bunny" will be displayed to the screen. This
would include such names as: "Bugs Bunny", "ags Bunny", "gs Bunny", and "234rtgs
Bunny".
Notice that "LIKE" has been used instead of the equals sign (=). "LIKE" signifies that
one is searching for an estimate of the data requested, and not necessarily an exact copy.
The '%' sign could be placed anywhere within the string. The method in which the server
searches for a string is dependent upon where one places the '%' sign.
Result:
All records containing the partial string "Bugs Bunny" will be displayed to the screen.
This would include such names as: "Bugs Bunnys", "Bugs Bunnyyyy453", "Bugs
Bunnytrtrtrtrtr", but not "gs Bunny".
One can also perform searches and display only certain columns.
Result:
48
Shopping Cart
name
BugsBunny
Alter table
Another very important function of MySQL is the ability to modify previously created
tables. This is accomplished via the ALTER statement. This function allows one to add,
modify, and delete columns, as well as rename the table, among other functions.
Executing the above four functions would modify test, creating the following table:
49
Shopping Cart
JAVA.SQL.DRIVERMANAGER:
The primary task of the class driver manager is to manage the various
JDBC drivers register. It also provides methods for:
50
Shopping Cart
MANAGING DRIVERS:
JDBC clients specify the JDBC URL when they request a
connection. The driver manager can find a driver that matches the request URL from the
list of register drivers and delegate the connection request to that driver if it finds a match
JDBC URLs normally take the following format:
<protocol>:<sub-protocol>:<resource>
The protocol is always jdbc and the sub-protocol and resource depend on the type of
resource manager. The URL for postgreSQL is in the format:
Jdbc: postgres ://< host> :< port>/<database>
Here host is the host address on which post master is running and database is the name of
the database to which the client wishes to connect.
MANAGING CONNECTION:
DriverManager class is responsible for managing connections to the databases:
public static Connection getConnection (String url,Properties info) throws
SQLException
This method gets a connection to the database by the specified JDBC URL
using the specified username and password. This method throws an instance of
SQLException if a database access error occurs.
CONNECTIONS:
The interface java.sql.Connection defines the methods required for a persistent
51
Shopping Cart
connection to the database. The JDBC driver vendor implements this interface. A
database vendor-neutral client never uses the implementation class and will always use
only the interface. This interface defines methods for the following tasks:
Statements, prepared statements, and callable statements are the different
types of statements for issuing sql statements to the database by the JDBC
clients.
For getting and setting auto-commit mode.
Getting meta information about the database.
Committing and rolling back transactions.
CREATING STATEMENTS:
The interface java.sql.Connection defines a set of methods for
creating database statements. Database statements are used for sending SQL statements to
the database:
Public Statement createStatement () throws SQLException
This method is used for creating instances of the interface java.sql.Statement. This
interface can be used for sending SQL statements to the database. The interface
java.sql.Statement is normally used for sending SQL statements that dont take any
arguments. This method throws an instance of SQLException if a database access error
occur:
Public Statement createStatement (int resType, int resConcurrency) throws
SQLException
JDBC RESULTSETS:
A JDBC resultset represents a two dimentional array of data
produced as a result of executing SQL SELECT statements against databases using JDBC
statements. JDBC resultsets are represented by the interface java.sql.ResultSet. The
JDBC vendor provider provides the implementation class for this interface.
SCROLLING RESULTSETS:
52
Shopping Cart
public String getString (int I) Gets the data in the specied column as
a string.
STATEMENT:
The interface java.sql.Stament is normally used for sending SQL statements that do
not have IN or OUT parameters. The JDBC driver vendor provides the implementation
class for this interface. The common methods required by the different JDBC statements
are defined in this interface. The methods defined by java.sql. Statement can be broadly
categorized as follows:
53
Shopping Cart
DriverManager
Driver Driver
Layer
Application
Layer Connection
54
Shopping Cart
BENEFITS OF JSP:
A large percentage of our JSP document consists of static text known as template text.
In almost all respects, this HTML looks just likes normal HTML follows all the same
syntax rules, and simply passed through to that client by the servlet created to
55
Shopping Cart
handle the page. Not only does the HTML look normal, it can be created by whatever
tools you already are using for building Web pages.
There are two minor exceptions to the template text passed through
rule. First, if you want to have <% 0r %> in the out port, you need to put <\% or %\>
in the template text. Second, if you want a common to appear in the JSP page but not
in the resultant document,
JSP scripting elements allow you to insert Java code into the servlet that will be
generated from the JSP page. There are three forms:
1. Expressions of the form <%=Java Expression %>, which are evaluated and
inserted into the servlets output.
2. Sciptlets of the form <%Java code %>, which are inserted into the
servlets_jspService method (called by service).
3. Declarations of the form<%! Field/Method Declaration %>, which are
inserted into the body of the servlet class, outside any existing methods.
A JSP element is used to insert values directly into the output. It has the following form:
<%= Java Expression %>
The expression is evaluated, converted to a string, and inserted in the page. This
evaluation is performed at runtime (when the page is requested) and thus has full access
56
Shopping Cart
to the information about the request. For example, the following shows the date/time that
the page was requested.
Current time: <%=new java.util.Date () %>
PREDEFINED VARIABLES:
JSP works best when the structure of the HTML page is fixed but the values at various
places need to be computed dynamically. If the structure of the page is dynamic, JSP is
less beneficial. Some times servlets are better in such a case. If the page consists of
binary data or has little static content, servlets are clearly superior. Sometimes the answer
is neither servlets nor JSP alone, but rather a combination of both.
57
Shopping Cart
WRITING SCRIPTLETS
If you want to do something more complex than output the value of a simple
expression .JSP scriptlets let you insert arbitrary code into the servlets _jspService
method. Scriptlets have the following form:
<% Java code %>
Scriptlets have access to the same automatically defined variables as do expressions
(request, response, session, out , etc ) .So for example you want to explicitly send output
of the resultant page , you could use the out variable , as in the following example:
<%
String queryData = request.getQueryString ();
out.println (Attached GET data: + queryData);
%>
SCRIPTLET EXAMPLE:
As an example of code that is too complex for a JSP expression alone, a JSP page that
uses the bgColor request parameter to set the background color of the page .Simply using
<BODY BGCOLOR=<%= request.getParameter (bgcolor) %> >
would violate the cardinal rule of reading form data.
USING DECLARATIONS
A JSP declaration lets you define methods or fields that get inserted into the main body of
the servlet class .A declaration has the following form:
<%! Field or Method Definition %>
Since declarations do not generate output, they are normally used in conjunction with JSP
expressions or scriptlets. In principle, JSP declarations can contain field (instance
variable) definitions, method definitions, inner class definitions, or even static initializer
blocks: anything that is legal to put inside a class definition but outside any existing
methods. In practice declarations almost always contain field or method definitions.
58
Shopping Cart
We should not use JSP declarations to override the standard servlet life cycle methods.
The servlet into which the JSP page gets translated already makes use of these methods.
There is no need for declarations to gain access to service, doget, or dopost, since calls to
service are automatically dispatched to _jspService , which is where code resulting from
expressions and scriptlets is put. However for initialization and cleanup, we can use
jspInit and jspDestroy- the standard init and destroy methods are guaranteed to call these
methods in the servlets that come from JSP.
Tomcat is the Servlet/JSP container. Tomcat implements the Servlet 2.4 and
JavaServer Pages 2.0 specification. It also includes many additional features that make
it a useful platform for developing and deploying web applications and web services.
TERMINOLOGY:
/conf Configuration files and related DTDs. The most important file in here is
server.xml. It is the main configuration file for the container.
59
Shopping Cart
Tomcat will operate under any Java Development Kit (JDK) environment that
provides a JDK 1.2 (also known as Java2 Standard Edition, or J2SE) or later
platform. JDK is needed so that servlets, other classes, and JSP pages can be
compiled.
Main Location
$CATALINA_HOME/webapps/ROOT
Corresponding URLs.
http://host/SomeFile.html
http://host/SomeFile.jsp
Corresponding URLs
http://host/SomeDirectory/SomeFile.html
http://host/SomeDirectory/SomeFile.jsp
60
Shopping Cart
Location
$CATALINA_HOME/webapps/ROOT/WEB-INF/lib
61
Shopping Cart
Chapter -7
62
Shopping Cart
TESTING
7 .SOFTWARE TESTING
Testing
Software testing is a critical element of software quality assurance and
represents the ultimate review of specification, design and code generation.
63
Shopping Cart
The software developed has been tested successfully using the following testing
strategies and any errors that are encountered are corrected and again the part of the
program or the procedure or function is put to testing until all the errors are removed. A
successful test is one that uncovers an as yet undiscovered error.
Note that the result of the system testing will prove that the system is working
correctly. It will give confidence to system designer, users of the system, prevent
frustration during implementation process etc.,
White box testing is a testing case design method that uses the control structure of
the procedure design to derive test cases. All independents path in a module are exercised
at least once, all logical decisions are exercised at once, execute all loops at boundaries
and within their operational bounds exercise internal data structure to ensure their
validity. Here the customer is given three chances to enter a valid choice out of the given
menu. After which the control exits the current menu.
Unit Testing:
64
Shopping Cart
Unit testing is essentially for the verification of the code produced during
the coding phase and the goal is test the internal logic of the module/program. In the
Generic code project, the unit testing is done during coding phase of data entry
forms whether the functions are working properly or not. In this phase all the
drivers are tested they are rightly connected or not.
Integration Testing:
All the tested modules are combined into sub systems, which are then tested.
The goal is to see if the modules are properly integrated, and the emphasis being on
the testing interfaces between the modules. In the generic code integration testing is
done mainly on table creation module and insertion module.
Validation Testing
This testing is a series of different tests whose primary is to fully exercise the
computer-based system. This involves:
Implementing the system in a simulated production environment and testing it.
Introducing errors and testing for error handling.
TEST CASES
TEST CASE 1:
65
Shopping Cart
TEST CASE 2:
When a user enters user id to register and ID already exists, then this result in displaying
error message USER ID ALREADY EXISTS.
TEST CASE 3:
When a customer views an empty cart it displays Cart is empty message. When a user
wants to add a product to cart without logging into the system a message Please login to
purchase will be displayed.
TEST CASE 4:
Validation cases:
If any data field which accept the data from the user are not filled then the
corresponding error messages are generated.
66
Shopping Cart
Chapter -8
67
Shopping Cart
OUTPUT SCREENS
8. OUTPUT SCREENS
HOME PAGE:
68
Shopping Cart
69
Shopping Cart
About Us
70
Shopping Cart
Contact Us
71
Shopping Cart
Registration
72
Shopping Cart
Registration Validation
73
Shopping Cart
LOGIN PAGE:
74
Shopping Cart
Login Validation
75
Shopping Cart
76
Shopping Cart
77
Shopping Cart
78
Shopping Cart
79
Shopping Cart
Browsing Products
80
Shopping Cart
81
Shopping Cart
Cart View:
82
Shopping Cart
83
Shopping Cart
9. CONCLUSION
The Shopping Cart project has been successfully completed. The goal
of the system is achieved and the problems are solved. This project is developed in this
manner that is user friendly and required help is provided at different levels.
The primary objective is to provide the interactive service to all the
Users. Different types of services are provided to both the admin and users. User can
avail this service any time.
84
Shopping Cart
APPENDIX
ABBREVATIONS:
Client side java script is interpreted only with in the browser that support it, and
the code is visible to the user. Server side java script is stored in a pre-compiled state on
the server, so it is browser independent, and only the results of the java script programs
are passed to the browser, so that code is never revealed.
In general, the <script> container tags may appear any where with in the html
document. It is more viable to have the tags placed with in the <head> container.
85
Shopping Cart
BIBLIOGRAPHY
Websites
www.eci.gov.in
www.google.com
www.apeci.com
www.askjeeves.com
86