81
CHAPTER 1 INTRODUCTION 1.1 Company Profile Sapient Corporation (Sapient), incorporated on September 18, 1991, is a global services company, which helps clients leverage marketing and technology to transform their businesses. The Company operates in three business units: Sapient Nitro Sapient Global Markets Sapient Government Services. Sapient Nitro provides integrated marketing and creative services, Web and interactive development, advertising, media planning and buying, strategic planning and marketing analytics, multi-channel commerce strategy and solutions, including a focus on mobile, and content and asset management strategies and solutions. Through this business unit, it combines multi-channel marketing and commerce. Sapient Global Markets provides integrated advisory, program management, analytics, technology and operations services to capital and commodity markets. Sapient Government Services provides consulting, technology, and marketing services to the United States government agencies and non-governmental organizations (NGOs). In January 2013, Sapient Nitro acquired 81% of iThink. 1

JAVA Training Report

Embed Size (px)

Citation preview

Page 1: JAVA Training Report

CHAPTER 1

INTRODUCTION

1.1 Company Profile

Sapient Corporation (Sapient), incorporated on September 18, 1991, is a global services company,

which helps clients leverage marketing and technology to transform their businesses. The

Company operates in three business units:

Sapient Nitro

Sapient Global Markets

Sapient Government Services.

Sapient Nitro provides integrated marketing and creative services, Web and interactive

development, advertising, media planning and buying, strategic planning and marketing analytics,

multi-channel commerce strategy and solutions, including a focus on mobile, and content and

asset management strategies and solutions. Through this business unit, it combines multi-channel

marketing and commerce. Sapient Global Markets provides integrated advisory, program

management, analytics, technology and operations services to capital and commodity markets.

Sapient Government Services provides consulting, technology, and marketing services to the

United States government agencies and non-governmental organizations (NGOs). In January

2013, Sapient Nitro acquired 81% of iThink.

1.1.1 About the agency

SapientNitro is a new breed of agency redefining storytelling for an always-on world – a world

where perpetual connection has transformed people's daily life and derailed traditional marketing

approaches.

It's because the silos that once divided creativity and technology, and any lines between the

physical and virtual, no longer exist in the real world that they don't exist in ours. Our people –

913 Idea Engineers in the UK and 7,000-plus in 31 offices worldwide – provide unrivalled

1

Page 2: JAVA Training Report

diversity and the capability to deliver the kind of connected thinking that helps clients present their

customers' complete brand and buying experience as a single landscape.

SapientNitro was ranked no. 1 in Marketing Magazine's Digital League Table in 2012, was named

Digital Agency of the Year 2012 at the DADI Awards and remains the UK's largest independent

agency.

1.1.2 Agency philosophy

Time was the domain of the brand agency, engagement the domain of the digital agency, and

transaction the domain of the technology company – but the omnipresence of technology has

changed everything. The consumer is increasingly connected and mobile, with no lines between

channels or device, no demarcation between the physical and virtual or the browsing and buying.

A single, seamless view of the connected consumer is critical.

SapientNitro is a new breed of agency for an always-on world; one with a deep understanding of

the entire landscape across which consumers run free today with their connected devices and how

they interact in each moment. We begin in a different place and so our client's stories find

themselves connecting in different ways, at different times and in different spaces too.

We call this unique approach 'storyscaping'. At its heart sits a central thought that helps organise

how a brand's story may play out at any moment in time across the physical, virtual and emotional

spaces that consumers occupy.

1.2 Core agency skills

WE DEFINE STRATEGIES

Brand strategy

Experience strategy

Customer platform strategy

Business strategy

Marketing mix modeling

Research, insights & data science

2

Page 3: JAVA Training Report

 WE CREATE EXPERIENCES

Omni-Channel experience design

Immersive digital environments & events

Mobile, retail & emerging experiences

 WE BUILD BRANDS

Creative development

Brand planning

Brand communications

Media & connections planning

Branded content

Digital, mobile & social marketing

Loyalty & direct response marketing

1.3 Client Success Model

Define the Company by what the company needs

Sapient co-founders Greenberg and Moore believed that most consulting companies wrongly

defined their business by what the company provided rather than by what the customer wanted.

The distinction might appear abstract to some, but Greenberg and Moore believed it was crucial to

creating a successful business. For example,

Sports Illustrated may have missed becoming ESPN because they thought they were in the

magazine business and not the sports entertainment, information, and inspiration business.

A key insight that helped save Cadillac in the 1930’s was that they were in the prestige

business, not the car business. They understood that they competed with diamonds and furs

and began to market themselves differently.

Hanna-Barbara and Disney both started out making cartoons. Hanna-Barbara stayed in the

cartoon business, but Disney defined itself to be in the entertainment business and created

movies, theme parks, cruises, and TV networks.

3

Page 4: JAVA Training Report

One of the attractions of Nordstrom’s is that its salespeople really seem to think of their

job as “making customers look good” and not just selling them clothes.

In Greenberg and Moore’s view, customers spent money not for a product or service but for

something that the product or service would help them get. Therefore, any business had to be clear

on what customers ultimately wanted. A focus on customer wants created a much broader role for

a company and highlighted many new opportunities to create value.

When it came to their own business, Greenberg and Moore discovered that defining what success

meant to a client was a tricky challenge. Sapient only formalized a client success model in the

early 2000s after much experience with clients and engagements. Their experience told them that

there was no easy template; even companies within the same industry could have very different

needs. Consequently, the specifics of the client success model had to be delineated for each

engagement. “Our client should feel that we are more committed to their company and personal

success than anyone they will ever meet,” said Moore. “And it is their definition of success that

matters, not ours.”

1.4 Recent agency awards:

In 2012, SapientNitro won more than 30 international creative awards and 12 business

recognitions, including the following:

Andy Awards

Silver - Consumer Generated Content – Fashion Apparel & Accessories, 'Sneakerpedia'

Foot Locker Europe

Art Director's Club - New York

Silver - Social: Social Network Platform, 'Sneakerpedia' Foot Locker Europe

British Interactive Media Association (BIMA) Awards

Premium Award for Innovation, 'Get Cash' for RBS App

Clio Awards

Gold - Interactive – Websites / Microsites

'Sneakerpedia' Foot Locker Europe

4

Page 5: JAVA Training Report

Communication Arts Typography Annual

Typography, 'Sno' Volvo Book

Creative Review - The Annual Awards

Interactive and Digital Media, 'Sneakerpedia' Foot Locker Europe

DADI Awards

Digital Agency of the Year

Marketing Magazine

Ranked no. 1 in Digital Agency League Table

New Media Age

Ranked no. 1 in Top 100 Interactive Agencies League Table, Ranked no. 1 in Top 50

Marketing Agencies League Table

One Show Interactive

Gold - Social Networks / Community, 'Sneakerpedia' Foot Locker Europe

One Show Awards

Silver - Brand Transformation, 'Sneakerpedia' Foot Locker Europe

Revolution Awards

Best use of consumer engagement, 'Sneakerpedia' Foot Locker Europe

The Drum Magazine

London Digital Agency of the Year

1.5 Contact Details

Sapient Nitro

Unitech Infospace Limited,Ground Floor, Tower A,Building 2, Sector 21,Old Delhi - Gurgaon

Road

Dundahera, Gurgaon 122016

Haryana

Tel: +91 (124) 672 4000

Fax: +91 (124) 499 6001

5

Page 6: JAVA Training Report

CHAPTER 2

TECHNOLOGIES USED

2.1 Front End

For software applications, front-end is the same as user interface.

Compilers, the programs that translate source code into object code, are often

composed of two parts: a front - end and a back - end. The Front - end is responsible for

checking syntax and detecting errors, whereas the back-end performs the actual translation

into object code.

2.2 Back-End

Front – end and back–end are terms used to characterize program interfaces and services relative

to the initial user of these interfaces and services.(The "user" may be a human being or a

program.)A "front-end" application is one that application users interact with directly. A "back-

end" application or program serves indirectly in support of the front-end services, usually by being

closer to the required resource or having the capability to communicate with the required resource.

The back-end application may interact directly with the front-end or, perhaps more typically, is a

program called from an intermediate program that mediates front-end and back-end activities. For

example, the (TAPI) is sometimes referred to as a front-end interface for telephone services. A

program's TAPI requests are mapped by Microsoft's TAPI Dynamic Link Library programs (an

intermediate set of programs) to a "back-end" program or driver that makes the more detailed

series of requests to the telephone hardware in the computer.

As another example, a front-end application might interface directly with users and forward

requests to a remotely-located back-end program in another computer to get requested data or

perform a requested service. Relative to the client/server computing model, a front-end is likely to

be a client and a back-end to be a server.

6

Page 7: JAVA Training Report

2.3 Struts and MVC framework

When Java servlets were first invented, many programmers quickly realized that they were a Good

Thing. They were faster and more powerful that standard CGI, portable, and infinitely extensible.

But writing HTML to send to the browser in endless println() statements was tiresome and

problematic. The answer to that was JavaServer Pages, which turned Servlet writing inside-out.

Now developers could easily mix HTML with Java code, and have all the advantages of servlets.

The sky was the limit!

Java web applications quickly became "JSP-centric". This in-and-of itself was not a Bad Thing,

but it did little to resolve flow control issues and other problems endemic to web applications.

Clearly, another paradigm was needed.

Many clever developers realized that Java Server Pages AND servlets could be used together to

deploy web applications. The servlets could help with the control-flow, and the JSPs could focus

on the nasty business of writing HTML. In due course, using JSPs and servlets together became

known as Model 2 (meaning, presumably, that using JSPs alone was Model 1).

Of course, there is nothing new under the Sun ... and many have been quick to point out that JSP's

Model 2 follows the classic Model-View-Controller design pattern abstracted from the venerable

Smalltalk MVC framework. Java Web developers now tend to use the terms Model 2 and MVC

interchangeably. In this guide, we use the MVC paradigm to describe the framework architecture,

which might be best termed a Model 2/MVC design.

The Apache Struts Project was launched in May 2000 by Craig R. McClanahan to provide a

standard MVC framework to the Java community. In July 2001, version 1.0 was released, and

IOHO, Java Model 2 development has never been quite the same.

2.3.1 The MVC design pattern

The term "MVC" originated with the Small Talk Model-View-Controller framework. Under

MVC, an application is seen as having three distinct parts. The problem domain is represented by

the Model. The output to the user is represented by the View. And, the input from the user is

represented by Controller.

7

Page 8: JAVA Training Report

2.3.1.1 The Model: System state and Business logic

The Model portion of an MVC-based system can be often divided into two major subsystems --

The Internal state of the system and The Actions that can be taken to change that state.

In grammatical terms, we might think about state information as nouns (things) and actions as

verbs (changes to the state of those things).

Many applications represent the internal state of the system as a set of one or more JavaBeans. The

bean properties represent the details of the system' state. Depending on your application's

complexity, these beans may be self-contained (and know how to persist their own state), or they

may be facades that know how to retrieve the system's state from another component. This

component may be a database, a search engine, an Entity Enterprise JavaBean, a LDAP server, or

something else entirely.

Large-scale applications will often represent the set of possible business operations as methods

that can be called on the bean or beans maintaining the state information. For example, you might

have a shopping cart bean, stored in session scope for each current user, with properties that

represent the current set of items that the user has decided to purchase. This bean might also have

a checkOut() method that authorizes the user's credit card and sends the order to the warehouse to

be picked and shipped. Other systems will represent the available operations separately, perhaps as

Session Enterprise JavaBeans (Session EJBs).

In a smaller scale application, on the other hand, the available operations might be embedded

within the Action classes that are part of the framework control layer. This can be useful when the

logic is very simple or where reuse of the business logic in other environments is not

contemplated.

2.3.1.2 The View: JSP pages and Presentation components

The View portion of a Struts-based application is most often constructed using JavaServer Pages

(JSP) technology. JSP pages can contain static HTML (or XML) text called "template text", plus

the ability to insert dynamic content based on the interpretation (at page request time) of special

action tags. The JSP environment includes a set of standard action tags, such as <jsp:useBean>

whose purpose is described in the JavaServer Pages Specification. In addition to the built-in

8

Page 9: JAVA Training Report

actions, there is a standard facility to define your own tags, which are organized into "custom tag

libraries."

The framework includes a set of custom tag libraries that facilitate creating user interfaces that are

fully internationalized and interact gracefully with ActionForm beans. ActionForms capture and

validate whatever input is required by the application.

For more about the Struts taglibs and using presentation pages with the framework, see the

Building View Components section. Additional documentation regarding the taglibs is also

available in the Taglibs subproject.

2.3.1.3 The Controller: Action servlet and Action Mapping

Struts provides the Controller portion of the application. The Controller is focused on receiving

requests from the client (typically a user running a web browser), deciding what business logic

function is to be performed, and then delegating responsibility for producing the next phase of the

user interface to an appropriate View component. The primary component of the Controller in the

framework is a servlet of class ActionServlet. This servlet is configured by defining a set of

ActionMappings. An ActionMapping defines a path that is matched against the request URI of the

incoming request and usually specifies the fully qualified class name of an Action class. All

Actions are subclassed from [org.apache.struts.action.Action]. Actions encapsulate calls to

business logic classes, interpret the outcome, and ultimately dispatch control to the appropriate

View component to create the response. While the framework dispatches to a View, actually

rendering the View is outside its scope.

The framework also supports the ability to use ActionMapping classes that have additional

properties beyond the standard ones required to operate the controller. This allows you to store

additional information specific to your application and still utilize the remaining features of the

framework. In addition, the framework lets you define logical "names" to which control should be

forwarded so that an action method can ask for the "Main Menu" page (for example), without

knowing the location of the corresponding JSP page. These features greatly assist you in

separating the control logic (what to do) with the view logic (how it's rendered).

9

Page 10: JAVA Training Report

CHAPTER 3

INTRODUCTION TO JAVA

3.1 Java Platform Overview

Java technology is used to develop applications for a wide range of environments, from consumer

devices to heterogeneous enterprise systems. In this section, get a high-level view of the Java

platform and its components.

3.1.1 The Java Language

Like any programming language, the Java language has its own structure, syntax rules, and

programming paradigm. The Java language's programming paradigm is based on the concept of

object-oriented programming (OOP), which the language's features support.

The Java language is a C-language derivative, so its syntax rules look much like C's: for example,

code blocks are modularized into methods and delimited by braces ({ and }), and variables are

declared before they are used.

Structurally, the Java language starts with packages. A package is the Java language's namespace

mechanism. Within packages are classes, and within classes are methods, variables, constants, and

so on. You'll learn about the parts of the Java language in this tutorial.

3.1.2 The Java Compiler

When you program for the Java platform, you write source code in .java files and then compile

them. The compiler checks your code against the language's syntax rules, then writes out

bytecodes in .class files. Bytecodes are standard instructions targeted to run on a Java virtual

Machine (JVM). In adding this level of abstraction, the Java compiler differs from other language

compilers, which write out instructions suitable for the CPU chipset the program will run on.

10

Page 11: JAVA Training Report

3.1.3 The JVM

At run time, the JVM reads and interprets .class files and executes the program's instructions on

the native hardware platform for which the JVM was written. The JVM interprets the bytecodes

just as a CPU would interpret assembly-language instructions. The difference is that the JVM is a

piece of software written specifically for a particular platform. The JVM is the heart of the Java

language's "write-once, run-anywhere" principle. Your code can run on any chipset for which a

suitable JVM implementation is available. JVMs are available for major platforms like Linux and

Windows, and subsets of the Java language have been implemented in JVMs for mobile phones

and hobbyist chips.

3.1.4 The Garbage Collector

Rather than forcing you to keep up with memory allocation (or use a third-party library to do this),

the Java platform provides memory management out of the box. When your Java application

creates an object instance at run time, the JVM automatically allocates memory space for that

object from the heap, which is a pool of memory set aside for your program to use. The Java

garbage collector runs in the background, keeping track of which objects the application no longer

needs and reclaiming memory from them. This approach to memory handling is called implicit

memory management because it doesn't require you to write any memory-handling code. Garbage

collection is one of the essential features of Java platform performance.

3.1.5 Java Development Toolkit

When you download a Java Development Kit (JDK), you get — in addition to the compiler and

other tools a complete class library of prebuilt utilities that help you accomplish just about any

task common to application development. The best way to get an idea of the scope of the JDK

packages and libraries is to check out the JDK API documentation

3.1.6 Java Runtime Environment

The Java Runtime Environment (JRE; also known as the Java runtime) includes the JVM, code

libraries, and components that are necessary for running programs written in the Java language. It

is available for multiple platforms. You can freely redistribute the JRE with your applications

according to the terms of the JRE license, to give the application's users a platform on which to

run your software. The JRE is included in the JDK.

11

Page 12: JAVA Training Report

3.2 Setting up your Java Development Environment

In this section, you'll get instructions for downloading and installing JDK 6 and the current release

of the Eclipse IDE, and for setting up your Eclipse development environment.

If you already have the JDK and Eclipse IDE installed, you may want to skip to the Getting started

with Eclipse section or to the one after that, Object-oriented programming concepts.

3.2.1 Your development Environment

The JDK includes a set of command-line tools for compiling and running your Java code,

including a complete copy of the JRE. Although you certainly can use these tools to develop your

applications, most developers appreciate the additional functionality, task management, and visual

interface of an IDE.

Eclipse is a popular open source IDE for Java development. It handles basic tasks, such as code

compilation and setting up a debugging environment, so that you can focus on writing and testing

code. In addition, you can use Eclipse to organize source code files into projects, compile and test

those projects, and store project files in any number of source repositories. You need an installed

JDK in order to use Eclipse for Java development.

3.2.2 Install JDK 6

Follow these steps to download and install JDK 6:

1. Browse to Java SE Downloads and click the Java Platform (JDK) box to display the

download page for the latest version of the JDK (JDK 6, update 21 at the time of this

writing).

2. Click the Download button.

3. Select the operating system platform you need.

4. You will be asked for your account username and password. Enter them if you have an

account, sign up if you don't, or you can click Continue to skip this step and proceed to the

download.

5. Save the file to your hard drive when prompted. When the download is complete, run the

install program. (The file you've just downloaded is a self-extracting ZIP file that is also

12

Page 13: JAVA Training Report

the install program.) Install the JDK to your hard drive in an easy-to-remember location

(such as C:\home\jdk1.6.0_20 on Windows or ~/jdk1.6.0_20 on Linux). It's a good idea to

encode the update number in the name of the install directory you choose.

You now have a Java environment on your machine. Next, you will install the Eclipse IDE.

3.2.3 Install Eclipse

To download and install Eclipse, follow these steps:

1. Browse to Eclipse Galileo Sr2 Packages.

2. Click on Eclipse IDE for Java Developers.

3. Under Download Links on the right-hand side, select your platform.

4. Select the mirror you want to download from, then save the file to your hard drive.

5. Extract the contents of the .zip file to a location on your hard drive that you'll be able to

remember easily (such as C:\home\eclipse on Windows or ~/eclipse on Linux).

3.2.4 Set up Eclipse

The Eclipse IDE sits atop the JDK as a useful abstraction, but it still needs to access the JDK and

its various tools. Before you can use Eclipse to write Java code, you have to tell it where the JDK

is located.

To set up your Eclipse development environment:

1. Launch Eclipse by double-clicking on eclipse.exe (or the equivalent executable for your

platform).

2. The Workspace Launcher will appear, allowing you to select a root folder for your Eclipse

projects. Choose a folder you will easily remember, such as C:\home\workspace on

Windows or ~/workspace on Linux.

3. Dismiss the Welcome to Eclipse screen.

4. Click Window > Preferences > Java > Installed JREs.

13

Page 14: JAVA Training Report

Fig.3.2.4.1 Configuring the JDK used by Eclipse

5. Eclipse will point to an installed JRE. You need to make sure you use the one you

downloaded with JDK 6. If Eclipse does not automatically detect the JDK you installed,

click Add... and in the next dialog Standard VM, then click Next.

6. Specify the JDK's home directory (such as C:\home\jdk1.6.0_20 on Windows), then click

Finish.

7. Confirm that the JDK you want to use is selected and click OK.

14

Page 15: JAVA Training Report

3.3 Getting started with Eclipse

Eclipse is not just an IDE, it is an entire development ecosystem. This section is a brief hands-on

introduction to using Eclipse for Java development.

3.3.1 The Eclipse development environment

The Eclipse development environment has four main components:

Workspace

Projects

Perspectives

Views

The primary unit of organization in Eclipse is the Workspace. A workspace contains all of your

Projects. A Perspective is a way of looking at each project (hence the name), and within a

perspective are one or more Views.

3.3.2 The Java perspective

Fig.3.3.2.1 Eclipse Java Perspective

15

Page 16: JAVA Training Report

Figure 2 shows the Java perspective, which is the default perspective for Eclipse. You should see

this perspective when you start up Eclipse. The Java perspective contains the tools you need to

begin writing Java applications. Each tab shown in Figure 2 is a view for the Java perspective.

Package Explorer and Outline are two particularly useful views.

The Eclipse environment is highly configurable. Each view is dockable, so you can move it

around in the Java perspective and place it where you want it. For now, though, stick with the

default perspective and view setup.

3.3.3 Create a Project

Follow these steps to create a new Java project:

1. Click on File > New > Java Project ...and you will see a dialog box open like the one

shown in Figure 3:

Fig.3.3.3.1 New Java Project

16

Page 17: JAVA Training Report

2. Enter Intro as the project name and click Finish.

3. If you want to modify the default project settings, click Next. (This is recommended only if

you have experience with the Eclipse IDE.)

4. Click Finish to accept the project setup and create the project.

You have now created a new Eclipse Java project and source folder. Your development

environment is ready for action. However, an understanding of the OOP paradigm is essential. If

you are familiar with OOP concepts and principles, you might want to skip to Getting started with

the Java language.

3.4 Object Oriented Programming Concepts

The Java language is (mostly) object-oriented. If you haven't used an object-oriented language

before, its concepts might seem strange at first. This section is a short introduction to OOP

language concepts, using structured programming as a point of contrast.

3.4.1 What is an object?

Structured programming languages like C and COBOL follow a very different programming

paradigm from object-oriented ones. The structured-programming paradigm is highly data-

oriented, which means that you have data structures on one hand, and then program instructions

that act on that data. Object-oriented languages like the Java language combine data and program

instructions into objects.

An object is a self-contained entity that contains attributes and behavior, and nothing more.

Rather than having a data structure with fields (attributes) and passing that structure around to all

of the program logic that acts on it (behavior), in an object-oriented language, data and program

logic are combined. This combination can occur at vastly different levels of granularity, from

fine-grained objects like a Number, to coarse-grained objects such as a Funds Transfer service in

a large banking application.

3.4.2 Parent and child objects

A parent object is one that serves as the structural basis for deriving more-complex child objects.

A child object looks like its parent but is more specialized. The object-oriented paradigm allows

17

Page 18: JAVA Training Report

you to reuse the common attributes and behavior of the parent object, adding to its child objects

attributes and behavior that differ.

3.4.3 Object Communication and Coordination

Objects talk to other objects by sending messages (method calls in the Java

language).Furthermore, in an object-oriented application, program code coordinates the activities

among objects to perform tasks within the context of the given application domain. (In the Model-

View-Controller paradigm, this coordinating program code is the Controller.)

3.4.4 Object Summary

A well-written object:

Has crisp boundaries

Does a finite set of activities

Knows only about its data and any other objects that it needs to accomplish its activities.

In essence, an object is a discrete entity that has only the necessary dependencies on other objects

to perform its tasks.

Now you'll see what an object looks like.

3.4.5 The Person Object

I'll start with an example that is based on a common application-development scenario: an

individual being represented by a Person object.

Going back to the definition of an object, you know that an object has two primary elements

Attributes and Behavior. You'll see how these apply to the Person object.

3.4.5.1 Attributes

What attributes can a person have? Some common ones include:

Name

Age

Height

Weight

Eye color18

Page 19: JAVA Training Report

Gender

You can probably think of more (and you can always add more attributes later), but this list is a

good start.

3.4.5.2 Behavior

An actual person can do all sorts of things, but object behaviors usually relate to some kind of

application context. In a business-application context, for instance, you might want to ask your

Person object, "What is your age?" In response, Person would tell you the value of its Age

attribute.

More-complex logic could be hidden inside of the Person object, but for now suppose that Person

has the behavior of answering these questions:

What is your name?

What is your age?

What is your height?

What is your weight?

What is your eye color?

What is your gender?

3.4.5.3 State and String

State is an important concept in OOP. An object's state is represented at any moment in time by

the value of its attributes. In the case of Person, its state is defined by attributes such as name, age,

height, and weight. If you wanted to present a list of several of those attributes, you might do so

using a String class, which I'll talk more about later in the tutorial.

Together, the concepts of state and string allow you to say to Person: tell me who you are by

giving me a listing (or String) of your attributes.

3.4.6 Principles of OOP

There are following main features of OOPS.

1. Encapsulation

2. Inheritance

19

Page 20: JAVA Training Report

3. Polymorphism

4. Abstraction

Let’s we discuss about the about features in details.

3.4.6.1 Encapsulation

Encapsulation means putting together all the variables (instance variables) and the methods into a

single unit called Class. It also means hiding data and methods within an Object. Encapsulation

provides the security that keeps data and methods safe from inadvertent changes. Programmers

sometimes refer to encapsulation as using a “black box,” or a device that you can use without

regard to the internal mechanisms. A programmer can access and use the methods and data

contained in the black box but cannot change them.

3.4.6.2 Inheritance

An important feature of object-oriented programs is inheritance—the ability to create classes that

share the attributes and methods of existing classes, but with more specific features. Inheritance is

mainly used for code reusability. So you are making use of already written class and further

extending on that. That why we discussed about the code reusability the concept. In general one

line definition we can tell that deriving a new class from existing class, it’s called as Inheritance.

3.4.6.3 Polymorphism

In Core Java Polymorphism is one of easy concept to understand. Polymorphism definition is that

Poly means many and morphs means forms. It describes the feature of languages that allows the

same word or symbol to be interpreted correctly in different situations based on the context. There

are two types of Polymorphism available in Java. For example, in English the verb “run” means

different things if you use it with “a footrace,” a “business,” or “a computer.” You understand the

meaning of “run” based on the other words used with it. Object-oriented programs are written so

that the methods having same name works differently in different context. Java provides two ways

to implement polymorphism.

3.4.6.3.1 Static Polymorphism (Compile time polymorphism/Method overloading)

20

Page 21: JAVA Training Report

The Ability to execute different method implementations by altering the argument used with the

method name is known as method overloading. When you properly overload a method, you can

call it providing different argument lists, and the appropriate version of the method executes.

3.4.6.3.2 Dynamic Polymorphism (Run time Polymorphism/Method overriding)

When you create a subclass by extending an existing class, the new subclass contains data and

methods that were defined in the original superclass. In other words, any child class object has all

the attributes of its parent. Sometimes, however, the superclass data fields and methods are not

entirely appropriate for the subclass objects; in these cases, you want to override the parent class

members. It is called Dynamic Polymorphism.

3.4.6.4 Abstraction

All programming languages provide abstractions. It can be argued that the complexity of the

problems you’re able to solve is directly related to the kind and quality of abstraction. An essential

element of object-oriented programming is abstraction. Humans manage complexity through

abstraction. When you drive your car you do not have to be concerned with the exact internal

working of your car(unless you are a mechanic). What you are concerned with is interacting with

your car via its interfaces like steering wheel, brake pedal, accelerator pedal etc. Various

manufacturers  of car has different implementation of car working but its basic interface has not

changed (i.e. you still use steering wheel, brake pedal, accelerator pedal etc to interact with your

car). Hence the knowledge you have of your car is abstract.

A powerful way to manage abstraction is through the use of hierarchical classifications. This

allows you to layer the semantics of complex systems, breaking them into more manageable

pieces. From the outside, the car is a single object. Once inside, you see that the car consists of

several subsystems: steering, brakes, sound system, seat belts, heating, cellular phone, and so on.

In turn, each of these subsystems is made up of more specialized units. For instance, the sound

system consists of a radio, a CD player, and/or a tape player. The point is that you manage the

complexity of the car (or any other complex system)through the use of hierarchical abstractions.

An abstract class is something which is incomplete and you can not create instance of abstract

class. If you want to use it you need to make it complete or concrete by extending it. A class is

called concrete if it does not contain any abstract method and implements all abstract method

21

Page 22: JAVA Training Report

inherited from abstract class or interface it has implemented or extended. By the way Java has

concept of abstract classes, abstract method but a variable can not be abstract in Java.

Let’s take an example of Java Abstract Class called Vehicle. When I am creating a class called

Vehicle, I know there should be methods like start() and Stop() but don't know start and stop

mechanism of every vehicle since they could have different start and stop mechanism e.g some

can be started by kick or some can be by pressing buttons.

Advantage of Abstraction is if there is new type of vehicle introduced we might just need to add

one class which extends Vehicle Abstract class and implement specific methods.  Interface of start

and stop method would be same.

3.5 Features of Java

3.5.1 Distributed

Java has an extensive library of routines for coping with TCP/IP protocols like HTTP and FTP

Java applications can open and access across the Net via URLs with the same ease as when

accessing local file system.

We have found the networking capabilities of Java to be both strong and easy to use. Anyone who

has tries to do Internet programming using another language will revel. How simple Java makes

onerous tasks will like opening a socket connection.

3.5.2 Robust

Java is intended for writing programs that must be readable in a Variety ways. Java puts a lot of

emphasis on early checking for possible problems, later dynamic checking, and eliminating

situations that are error prone... The single biggest difference between Java has a pointer model

that eliminates the possibility of overwriting memory and corrupting data.

The Java compiler detects many problems that in other languages would only show up at runtime.

As for the second point, anyone who has spent hours chasing a memory leak cost by a printer bug

will be very happy with this feature of Java.

Java gives you the best of both worlds. You need not pointers for everyday constructs like string

and arrays. You have the power of pointers if you need it, for example, for like lists. And you have

always-complete safety, 22

Page 23: JAVA Training Report

Since you can never access a bad pointer or make memory allocation errors.

3.5.3 Secure

Java is intended to be used in networked/distributed environment toward that end; a lot of

emphasis has been placed on security. Java enables the contraction of virus-free, temper-free

systems.

Here is a sample of what Java’s security features are supposed to keep a Java programming

from doing:

1. Overrunning the runtime stack.

2. Corrupting memory outside its own process space.

3. Reading or writing local files when invoked through a security-conscious class loader like

Web browser.

3.5.4 Architecture Neutral

The compiler generates an architecture neutral object file format- the compiled code is executable

on many processors, given the presence of Java runtime system...The Java compiler does this by

generating byte code instructions which have nothing to do with a particular computer

architecture. Rather they ere designed to be both easy to any machine and easily translated into

native machine code on the fly.

Twenty years ago, the UCSD Pascal system did the same thing in a commercial product and, even

before that, Nicholas Worth’s original implementation of Pascal used the same approach. By using

bytecodes, performance takes major hit. The designers of Java did an excellent job developing a

byte code instruction set those workers well on today’s most common computer architectures. And

the codes have been designed to translate easily into actual machine instructions.

3.5.5 Portable

Unlike C and C++, they are no "implementation dependent" aspects of the specifications. The

sizes of the primitive’s data types are specified, as is the behavior of arithmetic on them.

23

Page 24: JAVA Training Report

For example, an int in Java is always a 32-bit integer. In C/C++, int can mean a 16-bit integer, a

32-bit integer, or any size the compiler vendor likes. The only restriction is that it must have at

least as many bytes int and cannot have more bytes than a long int.

The libraries that are a part of the system define portable interfaces. For example, there is an

abstract window class and implementations of it UNIX, Windows, and the Macintosh.

3.5.6 Interpreted

The Java interpreters can execute Java byte codes directly on any machine to which the interpreter

has been ported. Since linking is a more incremental and lightweight process, the development

process can be much more rapid and explanatory.

One problem is that the JDK is fairly slow at compiling your source code to the bytecodes that

will, ultimately, be interpreted in the current version.

3.5.7 High Performance

While the performance of interpreted bytecodes is usually more than adequate, there are situations

higher performance is required. The bytecodes can be translated on fly into machine code for the

particular CPU the application is running on.

Native code compilers for Java are not yet generally available. Instead there are just-in-time (jit)

compilers. These work by compiling the byte codes

Into native code once, caching the results, and the calling them again, if needed. This speeds up

code once, catching the results, and calling them again, if needed. This speed up the loop

tremendously since once has to do the interpretation only once. Although still slightly slower than

a true native code compiler, just-in-time compilers can give you a 10-or even 20-fold speedup for

some programs and will almost always be significantly faster than the Java Interpreter.

3.5.8 Multithreaded

24

Page 25: JAVA Training Report

In a number of ways, Java is more dynamic language than C or C++. It was designed to adapt to

an evolving environment. Libraries can freely add new methods and instance variables without

any effect on their clients.In Java, finding out run time type information is straightforward.

This is an important feature in those situations where code needs to be added to a running

program. A prime example is code that is downloaded from the Internet to run in browser.

Why Software Developers Choose JAVA?

Java with its versatility, efficiency, and portability, has become invaluable to developers by

enabling:

Write software on one platform and run it on virtually any other platform

Create programs to run within a Web browser and Web services

Develop server-side applications for online forums, stores, polls, HTML forms processing,

and more

Combine applications or services using the Java language to create highly customized

applications.

Write powerful and efficient applications for mobile phones, remote processors, low-cost

consumer products, and practically any other device with a digital heartbeat.

Reserved words

Like any programming language, the Java language designates certain words that the compiler

recognizes as special, and as such you are not allowed to use them for naming your Java

constructs. The list of reserved words is surprisingly short:

Abstract assert

Boolean break

Byte case

Catch char

25

Page 26: JAVA Training Report

Class const

Continue default

Do double

Else enum

Extends final

Finally float

For goto

If implements

Import instanceof

Int interface

Long native

New package

Private protected

Public return

Short static

Strictfp super

Switch synchronized

This throw

Throws transient

Try void

Volatile while

Note that true, false, and null are technically not reserved words. Although they are literals, I

included them in this list because you can't use them to name Java constructs.

26

Page 27: JAVA Training Report

One advantage of programming with an IDE is that it can use syntax coloring for reserved words.

3.7 Architecture of Java

Java's architecture arises out of four distinct but interrelated technologies:

The Java programming language.

The Java class file format. 

The Java Application Programming Interface.

The Java Virtual Machine.

When you write and run a Java program, you are tapping the power of these four technologies.

You express the program in source files written in the Java programming language, compile the

source to Java class files, and run the class files on a Java virtual machine. When you write your

program, you access system resources (such as I/O, for example) by calling methods in the classes

that implement the Java Application Programming Interface, or Java API. As your program runs,

it fulfills your program's Java API calls by invoking methods in class files that implement the Java

API.

3.8 Java vs C++

The syntax of Java looks very much like C++. Compared to C++, Java used similar syntax for if

and loops structures. The notion of a constructor is all very similar to what C++ has.

The following are some of the differences of Java over C++. If you understand these differences

you will see why Java is such a beneficial programming language.

Compare to C++ Java runs 20 times slower because of platform independents.

Everything must be in a class. There are no global functions or global data. If you want

the equivalent of global, make static methods and static data within a class. There are no

structures or enumeration or unions.

The Char type uses the international 16-bit. Unicode character set, so it can automatically

represent most national characters.

27

Page 28: JAVA Training Report

All non-primitive types can only be created using new. All primitive types can only be

created directly, without new. There are wrapper classes for all primitive classes so you

can create equivalent heap-based objects with new

Java has no Preprocessors. If you want to use classes in another library, you say import

and the name of the library. There are no preprocessor-like macros.

There are no Java pointers in the sense of C and C++. When you create an object with

new, you get back a reference. For example

String s = new String ("peers");

Java has no templates or other implementation of parameterized types. There is a set of

containers : Vectors, stacks and Hash table that hold object references, and through which

you can satisfy your container needs, but these containers are not designed for efficiently

like the C++ standard template library(STL)

Java has built-in support for comment document action, so the source code file can also

contain its own documentation, which is stripped out and reformatted into HTML using an

apart program. This is boon for documentation maintenance and use.

Java has standard libraries for solving specific tasks. C++ relies on non-standard third-

party libraries. These tasks include

Networking

Database Connection (via JDBC)

Multithreading

Distributed Objects (via RMI and CORBA)

Compression

Commerce

3.9 Generics, Collection and Exception Handling

28

Page 29: JAVA Training Report

3.9.1 Generics

Generics are a facility of generic programming that were added to the Java programming language

in 2004 within J2SE 5.0. They allow "a type or method to operate on objects of various types

while providing compile-time type safety."[1] This feature specifies the type of objects stored in a

Java Collection. In the year 1998, Philip Wadler created Generic Java, an extension to the Java

language to support generic types.[2] Generic Java was incorporated, with the addition of

wildcards, into the official Java language version J2SE 5.0.

Hierarchy and Classification

According to Java Language Specification,

A type variable is an unqualified identifier. Type variables are introduced by generic class

declarations, generic interface declarations, generic method declarations, and by generic

constructor declarations.

A class is generic if it declares one or more type variables. These type variables are known

as the type parameters of the class. It defines one or more type variables that act as

parameters. A generic class declaration defines a set of parameterized types, one for each

possible invocation of the type parameter section. All of these parameterized types share

the same class at runtime.

An interface is generic if it declares one or more type variables. These type variables are

known as the type parameters of the interface. It defines one or more type variables that act

as parameters. A generic interface declaration defines a set of types, one for each possible

invocation of the type parameter section. All parameterized types share the same interface

at runtime.

A method is generic if it declares one or more type variables. These type variables are

known as the formal type parameters of the method. The form of the formal type parameter

list is identical to a type parameter list of a class or interface.

A constructor can be declared as generic, independently of whether the class that the

constructor is declared in is itself generic. A constructor is generic if it declares one or

more type variables. These type variables are known as the formal type parameters of the

29

Page 30: JAVA Training Report

constructor. The form of the formal type parameter list is identical to a type parameter list

of a generic class or interface.

3.9.2 Collection

A collection, sometimes called a container, is simply an object that groups multiple elements into

a single unit. Collections are used to store, retrieve, manipulate, and communicate aggregate data.

Typically, they represent data items that form a natural group, such as a poker hand (a collection

of cards), a mail folder (a collection of letters), or a telephone directory (a mapping of names to

phone numbers). If you have used the Java programming language, or just about any other

programming language, you are already familiar with collections.

A collections framework is a unified architecture for representing and manipulating collections.

All collections frameworks contain the following:

Interfaces: These are abstract data types that represent collections. Interfaces allow

collections to be manipulated independently of the details of their representation. In object-

oriented languages, interfaces generally form a hierarchy.

Implementations: These are the concrete implementations of the collection interfaces. In

essence, they are reusable data structures.

Algorithms: These are the methods that perform useful computations, such as searching

and sorting, on objects that implement collection interfaces. The algorithms are said to be

polymorphic: that is, the same method can be used on many different implementations of

the appropriate collection interface. In essence, algorithms are reusable functionality.

Apart from the Java Collections Framework, the best-known examples of collections frameworks

are the C++ Standard Template Library (STL) and Smalltalk's collection hierarchy. Historically,

collections frameworks have been quite complex, which gave them a reputation for having a steep

learning curve. We believe that the Java Collections Framework breaks with this tradition, as you

will learn for yourself in this chapter.

Benefits of collection framework

30

Page 31: JAVA Training Report

Reduces programming effort: By providing useful data structures and algorithms, the

Collections Framework frees you to concentrate on the important parts of your program

rather than on the low-level "plumbing" required to make it work. By facilitating

interoperability among unrelated APIs, the Java Collections Framework frees you from

writing adapter objects or conversion code to connect APIs.

Increases program speed and quality: This Collections Framework provides high-

performance, high-quality implementations of useful data structures and algorithms. The

various implementations of each interface are interchangeable, so programs can be easily

tuned by switching collection implementations. Because you're freed from the drudgery of

writing your own data structures, you'll have more time to devote to improving programs'

quality and performance.

Allows interoperability among unrelated APIs: The collection interfaces are the vernacular

by which APIs pass collections back and forth. If my network administration API furnishes

a collection of node names and if your GUI toolkit expects a collection of column

headings, our APIs will interoperate seamlessly, even though they were written

independently.

Reduces effort to learn and to use new APIs: Many APIs naturally take collections on input

and furnish them as output. In the past, each such API had a small sub-API devoted to

manipulating its collections. There was little consistency among these ad hoc collections

sub-APIs, so you had to learn each one from scratch, and it was easy to make mistakes

when using them. With the advent of standard collection interfaces, the problem went

away.

Reduces effort to design new APIs: This is the flip side of the previous advantage.

Designers and implementers don't have to reinvent the wheel each time they create an API

that relies on collections; instead, they can use standard collection interfaces.

Fosters software reuse: New data structures that conform to the standard collection

interfaces are by nature reusable. The same goes for new algorithms that operate on objects

that implement these interfaces.

3.9.3 Exception Handling

31

Page 32: JAVA Training Report

An exception is a problem that arises during the execution of a program. An exception can occur

for many different reasons, including the following:

A user has entered invalid data.

A file that needs to be opened cannot be found.

A network connection has been lost in the middle of communications or the JVM has run

out of memory.

Some of these exceptions are caused by user error, others by programmer error, and others by

physical resources that have failed in some manner.

To understand how exception handling works in Java, you need to understand the three categories

of exceptions:

Checked exceptions: A checked exception is an exception that is typically a user error or a

problem that cannot be foreseen by the programmer. For example, if a file is to be opened,

but the file cannot be found, an exception occurs. These exceptions cannot simply be

ignored at the time of compilation.

Runtime exceptions: A runtime exception is an exception that occurs that probably could

have been avoided by the programmer. As opposed to checked exceptions, runtime

exceptions are ignored at the time of compilation.

Errors: These are not exceptions at all, but problems that arise beyond the control of the

user or the programmer. Errors are typically ignored in your code because you can rarely

do anything about an error. For example, if a stack overflow occurs, an error will arise.

They are also ignored at the time of compilation.

Exception Hierarchy

All exception classes are subtypes of the java.lang.Exception class. The exception class is a

subclass of the Throwable class. Other than the exception class there is another subclass called

Error which is derived from the Throwable class.Errors are not normally trapped form the Java

programs. These conditions normally happen in case of severe failures, which are not handled by

32

Page 33: JAVA Training Report

the java programs. Errors are generated to indicate errors generated by the runtime environment.

Example : JVM is out of Memory. Normally programs cannot recover from errors.

The Exception class has two main subclasses: IOException class and RuntimeException Class.

Fig. 3.9.3 Exception Hierarchy

Catching Exceptions

A method catches an exception using a combination of the try and catch keywords. A try/catch

block is placed around the code that might generate an exception. Code within a try/catch block is

referred to as protected code.

A catch statement involves declaring the type of exception you are trying to catch. If an exception

occurs in protected code, the catch block (or blocks) that follows the try is checked. If the type of

exception that occurred is listed in a catch block, the exception is passed to the catch block much

as an argument is passed into a method parameter.

33

Page 34: JAVA Training Report

CHAPTER 4

DATABASE

MY SQL

This software and related documentation are provided under a license agreement containing

restrictions on use and disclosure and are protected by intel-lectual property laws. Except as

expressly permitted in your license agreement or allowed by law, you may not use, copy,

reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or

display any part, in any form, or by any means. Reverse engineering, disassembly, or

recompilation of this software, unless required by law for interoperability, is prohibited.

MySQL is an open source relational database management system (RDBMS). It is commonly used

for database services for other open source applications, such as Drupal and Wordpress.

Features:

1 gigabyte of storage space on the central MySQL database servers.

Daily Backups with two week retention.

Access to phpMyAdmin and the MySQL command line client for database management

and administration.

Ability to safely store Category-I data in databases.

Access to the ITS Systems MySQL team for advice and troubleshooting.

Access to commercial MySQL support via the ITS Systems MySQL team.

Fully Managed

In the Fully Managed infrastructure, ITS owns, manages, and supports the MySQL hardware and

software resources.Fully Managed MySQL is recommended for departments, colleges, or other

groups that require MySQL service but who do not have the appropriate hardware, software, or

staff resources to run it themselves. It is also recommended for those who will be using Category-I

data in their databases.

34

Page 35: JAVA Training Report

CHAPTER 5

INTRODUCTION TO JDBC

5.1 What is JDBC and Why JDBC?

JDBC (Java Database Connectivity) is a front-tool for connecting to a server and is similar to

ODBC in the respect. However, JDBC can connect only Java clients and uses ODBC for the

connectivity. JDBC is essentially a low-level Application, Programming Interface. It is called a

low-level API since any data manipulation, storage and retrieval has to be done by the program

itself. Some tools that provide a higher level abstraction are expected shortly.

5.2 JDBC Driver types: -

There are four types of JDBC drivers each having its own functionality. Please note that, they do

not substitute one another, each having their own suitability aspects. They are classified based on

how they access data from the database.

5.2.1 Native JDBC driver:

A JDBC driver, which is partly written in Java and most of each, implemented using native

methods to access the database. This is useful in case of Java application that can run only on

some specific platforms. Writing these type drivers is easier compare to writing other drivers

5.2.2 All Java JDBC Net Drivers:

A JDBC Net drivers which uses a common network protocol to connect to an intermediate server,

which is turn employees native calls to connect to the data base. This approach is used for applets

where the request must go through the intermediate server.

5.2.3 JDBC-ODBC bridge driver:

A bridge driver provided with JDBC can convert. The Jdbc calls in to equaling ODBC calls using

the native methods. Since ODBC provides for connection to any type of database that is ODBC

compliant, to connect a number of databases simultaneously, it is very simple matter. This

approach is a recommended once since using ODBC drivers, which are industry standard as of

now, would make an application truly portable across the databases.

35

Page 36: JAVA Training Report

5.2.4 Native Protocol All Java Drivers:

This type of JDBC driver is written completely in Java and can access the database by making use

of native protocols of the database. This method of data access is suitable in case of Intranets

were carry everything can run as an application instead of an applet.

5.3 JDBC Architecture

JDBC architecture is shown below. Components of JDBC are:

1. JDBC Driver Manager

2. JDBC Driver

3. JDB-ODBC Bridge

4. Applications.

Fig.5.3.1 JDBC Architecture

JDBC Driver Manager: - Function of the driver manager is to findout available drivers in the

system and connects the application to the appropriate database. Whenever a connection is

36

ODBC

Uses native calls to access the DB

Uses native net protocols

DATABASE

Uses special net protocols to access the DB

To access the DB

Page 37: JAVA Training Report

requested. However, to help the driver manager identify different types of drivers, each driver

should be registered with the driver Manager.

JDBC Driver: - Function of the JDBC Driver is to accept the SQL calls from the application and

convert them into native calls to the database. However, in this process it may take help some

other drivers or even servers, which depends on the type of Jdbc Driver we are using. Also, it is

possible that the total functionality of the database server could be built into the driver itself.

JDBC-ODBC Bridge: -

Sunsoft provides a special JDBC Driver called JDBC-ODBC bridge driver, which can be used to

connect to any existing database, that is ODBC complaint.

Application:- Application is a Java Program that needs the information to be modified in some

database or wants to retrieve the information.

CHAPTER 6

37

Page 38: JAVA Training Report

PROJECT

Online Shopping Website

6.1 Purpose

This project is a web-based online shopping application developed in Java Language using Java as

front end.

The main aim of “ONLINE SHOPPING” is to improve the services of Customers and vendors. It

maintains the details of customer payments, product receipts, addition of new customers, products

and also updating, deletion for the same. It also stores the details of invoices generated by

customer and payments made by them with all Payments details like credit card.

The primary features of the project entitled “ONLINE SHOPPING” are high accuracy, design

flexibility and easy availability. And also it uses database tables Representing entities and

relationships between entities.

6.2 Overview of Online Shopping

The central concept of the application is to allow the customer to shop virtually using the Internet

and allow customers to buy the items and articles of their desire from the store. The information

pertaining to the products are stores on an RDBMS at the server side (store). The Server process

the customers and the items are shipped to the address submitted by them.

The application was designed into two modules first is for the customers who wish to buy the

articles. Second is for the storekeepers who maintains and updates the information pertaining to

the articles and those of the customers.

The end user of this product is a departmental store where the application is hosted on the web and

the administrator maintains the database. The application which is deployed at the customer

database, the details of the items are brought forward from the database for the customer view

based on the selection through the menu and the database of all the products are updated at the end

of each transaction.

38

Page 39: JAVA Training Report

Data entry into the application can be done through various screens designed for various levels of

users. Once the authorized personnel feed the relevant data into the system, several reports could

be generated as per the security.

6.3 Functional Requirements

6.3.1 Product Catalogue

Requirements

User can see or can search for any product.

User can see the information of the product.

Administrator can add, delete or update the products.

Use cases

User can search for a particular product.

User can also go to any particular product though the categories of the

product.

If the user is the administrator and has login then he can add a new product,

delete a product or can update the information about any product.

If a product is not available which the user is looking for, then a “sold out”

or “unavailable” message will be displayed.

If an administrator want to update a product but that product is not available

then “no such product” message will be displayed.

Functional Requirements

While searching for a product a user can write the name of the product in

the search bar and then press the search button. After pressing the search

button the list of all the related products will be displayed. Out of the list

displayed the user can choose the desired product. If no such kind of

product is available which the user has typed then a “product not found”

message will be displayed.

39

Page 40: JAVA Training Report

User also has a categories or product to search for a particular product.

From the categories of product the user can navigate to the sub-category and

can look for a product.

If the administrator wants to add a new product, delete a product or update

an existing product then he can click on the login button and will fill his

administrator username and password to login as administrator.

While updating an existing product the name of the product entered by the

administrator will be checked in the data base and the information about the

product will be displayed. But if the product is no there in the data base then

a then “no such product” message will be displayed.

If a user searches for a product then that product will be searched in the data

base. If the product is not available or is not there in the data base then a

“sold out” or “unavailable” message will be displayed.

6.3.2 User Registration

Requirements

New user can sign up.

Already registered user can login.

Administrator can login.

Use cases

It’s the choice of the user to either get registered or not.

For a user to get registered he has to fill a sign up form and submit it and he

must remember his username and password for his next tm login.

If a user is already registered then he can direct login.

Administrator can also direct login.

Functional Requirements

40

Page 41: JAVA Training Report

To buy anything, its users choice to get registered or not. If the user

registers then his details will be saved and next time when he logins he will

not have to fill the information again.

If a user wants to register, then he has to click on the sign up button. After

clicking in the sign up button the sign up form will appear. In the sign up

form the user will be asked to fill his Name, Address, Pin code, Phone

number, E-mail, Username and Password. After filling all the fields user

will click on submit button and then the information will be saved.

If already registered user wants to login then he can click on the login

button, then a login form will appear there he will fill his username and

password and then click on the login. If the username and password entered

by the user is correct then a success page will open.

Administrator can also login directly by clicking on login button. In the

login form he will enter the administrator username and password and click

on login.

6.3.3 Cart Catalogue

Requirements

Cart Products:-The Amount of products and type of product present in the

cart is shown to the user when he/she clicks on a certain button. User will

be able to add or remove products from the cart.

Online/Offline Ordering:-Registered as well as unregistered users can order

products from the website.

Shipping address:-Customer will be able to fill the shipping address of the

order either at the time of registering on the website or on placing the order.

Order Tracking:-User will be able to check the status of his order by

entering the order ID.

Use cases

Cart Products

41

Page 42: JAVA Training Report

o When user will select a product using Add to cart button, it will be

added to his cart. If the product is not added, then an error message

will be displayed.

o During shopping, user will have an option of clicking on “Cart”

button. After that, Cart products will be displayed and “Delete” and

“Quantity” buttons will present with every product present in the

cart. ”Delete” button will delete the particular product from the cart

and “Quantity” button will show the Quantity of products. Quantity

of a product can be modified by specifying the number.

o The “Add” button will be displayed with each and every product

which is currently present on the page and which is available on the

website.

Online/Offline Ordering:-

o Order can be placed by registered user and unregistered users

without having registration from them. Unregister users will have to

enter the shipping address at the time of placing order.

Shipping address:-

o Shipping address is mandatory for every order that is to be

delivered.

o Sometimes it is possible that the address entered by the user is

unreachable or is not valid. To avoid that scenario, contact no. will

be taken from the user at the time of entering shipping address while

placing order.

o The User is required to enter the PIN code of his shipping area in a

separate text box and it will be checked as soon as the user enters it.

In case of invalid PIN code, the user will be alarmed after he enters

it

Order Tracking

42

Page 43: JAVA Training Report

o There will be a button on the every page of the website to track the

order.

o A unique Order ID will be created when any user will make a

purchase.

o Users can click on that button and a new window will be appeared to

track the order.

o Users have to enter the order ID to track it.

o If the Order ID entered by the user proved to be invalid, then an

error page will be displayed.

Functional Requirements

Cart Products:-

o When user clicks on cart button, the products he added in his cart

will be displayed. There will be two

Shipping address:-

o The shipping address entered by the user must be copied to the

required reports and invoices by firing the query to the DB.

Order Tracking:-

o The Order ID entered by the user will be checked from the list of

Order IDs of total products purchased.

o If any match found with that particular order ID, then that particular

Order’s status will be displayed and if no match found with that ID

then “Invalid Order ID” page will be displayed

6.3.4 Reports

Requirements

43

Page 44: JAVA Training Report

For Admin

o Products Inventory Report:-This report will contain the details

about all the products that are currently available. This report is

available to the Admin and not to the End-User.

o Summary of products purchased:-Summary of products purchased

in a day, week or month will be available on the admin page for any

validation or cross checking.

o Summary of Registered users:-A summary of registered users will

also be available on the admin page.

For End User

o Summary of products purchased:-The Registered users will be able

to see a report/summary of all products purchased by them.

o Invoice:-Every user who has ordered a product from the website

will be able to check the invoice of his shopping and he can also

download that invoice.

Use cases

For Admin

Whenever admin will log on the website, the page that is opened will

contain a button which is linked to the page of list of reports. It will contain

the following reports:-

o Products Inventory Report: - This report will show the list of

availability of products.

o Summary of products purchased: -

This report will show the list of products that are purchased

by users. Admin can sort the list by date or delete the old

report.

44

Page 45: JAVA Training Report

If there are no products that are purchased on the date

mentioned by admin, then the null report will be shown.

o Summary of Registered users: - This report will show the list of

registered users. In this report, combinations of username and

password will be displayed.

For End User

o Summary of products purchased:-

While placing order, a log button will be shown to

user to see the log of products purchased by him.

If user had never purchased any product from the

website, an empty log will be shown to the user if he

clicks on the log button.

o Invoice:-

The Invoice button will display the Bill of the total

purchases made by the user from the website.

Functional Requirements

For Admin

o Products Inventory:-This report will fetch the details of all the

products which are available in Database. There will be two

options- one for refreshing the report and another for deleting the

report. The Refresh button will refetch the report from the database

and Delete button will delete all details from the data base.

o Summary of products purchased:-This report will fetch the

information about the purchased products from the database. In this

report, Admin will have two options- one for fetching by date and

another for deleting the old reports.

45

Page 46: JAVA Training Report

o Summary of Registered users:-This report will fetch information

about all registered users and display it.

For End User

o Summary of products purchased:-

While placing order, a log button will be shown to

user to see the log of products purchased by him.

When user will click on the log button, a query will

be fired to the database to fetch the details of past

purchases by matching the username.

If user had never purchased any product from the

website, then the result of the query will point an

empty log/report and it will be displayed to the user.

o Invoice:-

The Invoice button will find the product prices from

the DB and adds them. Then this information will be

used by a class file to create the Bill which is further

displayed to the user on the front end.

6.4 Snapshots worth million words

6.4.1 Sign up/Login Page

46

Page 47: JAVA Training Report

Fig.6.4.1.1 Sign up/Login Page

6.4.2 Admin Page

47

Page 48: JAVA Training Report

Fig. 6.4.1.2 Admin Page

6.4.3 Homepage

48

Page 49: JAVA Training Report

Fig. 6.4.1.3 Homepage

6.4.4 Products Page

49

Page 50: JAVA Training Report

Fig. 6.4.1.4 Products Page

6.4.5 Product Detail Page

50

Page 51: JAVA Training Report

Fig. 6.4.1.5 Product Detail Page

6.4.6 Cart Products

51

Page 52: JAVA Training Report

Fig. 6.4.1.6 Cart Products

6.5 Designing52

Page 53: JAVA Training Report

6.5.1 ER Diagram

Fig.6.5.1.1 ER diagram

6.6 Data Tables

53

Page 54: JAVA Training Report

6.6.1 Orderdetail Table

6.6.2 Orderinfo Table

6.6.3 Pinfo Table

6.6.4 Pinventory Table

54

Page 55: JAVA Training Report

6.6.5 Userinfo Table

CHAPTER 755

Page 56: JAVA Training Report

APPENDICES

JVM:

Java code can run on any platform by using JVM. JVM normally reads and executes Java

statements one at a time.

JRE:

JRE provides run time environment, any program will not execute in java without JRE.

JDK:

Contains the software and tools needed to compile, debug and execute applets and applications.

MYSQL:

MYSQL is a database that is used to store all the internal data of the project, here

tables are created to store the collection or information about the project.

ER Dia.:

ER Diagrams are used to show the entities, attributes, relationship of the project. This shows how

1 entity is related to other entity and what are the relationship among these entities.

DFD:

Data Flow Diagram shows the complete running process of data, i.e. how data is transfer from

one stage to another, what is the process of flow of data, the initial stage the final stage all the

steps are shown by Data Flow Diagram.

Tables:

It stores all the collection of the data used in the project , different tables are created for the

collection of data, in tables there are two parts row and column, each new entity is add in row, and

attributes are added in the form of columns, these attributes are also termed as Tupples.

56

Page 57: JAVA Training Report

Tools:

JDK 1.6.

Eclipse Kepler version 1.0

Gif images.

Hardware-

Laptop or P.C. -Intel Core 2 duo, i3 or i5 processor

REFERENCES

Project Report:

“University of Cambridge” Computer Laboratory.

Article of Ross BainBridge

Books:

Complete Reference,

E.Balaguru Swami.

Black Book of JAVA.

Websites:

www.javaprogram.com

www.aptecheducation.com

www.flipkart.com

57