JavaEcommerceAppTutorial

Tutorial Outline on Building an Ecommerce Application using Java-Based Technologies


Contents


Tutorial Description

Purpose

The purpose of the tutorial is to demonstrate how to make best use of the NetBeans IDE for the development stages of a B2C (business to customer) e-commerce application, while providing a moderate to low-level explanation of the technologies being used. In doing this, two goals are served:

  1. IDE Adoption: The exercises provided do not simply show how to 'create x using technology y' in the IDE - they highlight the IDE's features within the development context in order to show how the IDE is a tool that provides for easier, quicker, more efficient, less error-prone development. Features include:
  • Editor support (syntax highlighting, code completion, refactoring, keyboard shortcuts and taskbar buttons, code templates, etc.)
  • Window system (Navigator, Javadoc window, Debugging windows, HTTP Monitor, Palette, etc.)
  • Comprehensive development environment (automatic deployment, server + database connectivity, Javadoc generation and analysis, JUnit testing and profiling)
  • Content will be drawn from (but not limited to) the DZone Refcard on NetBeans IDE Java Editor authored by Geertjan Wielenga and Patrick Keegan
  1. Technology Adoption: Most of the technologies employed are either Java-derived (e.g., Servlet and JSP technologies, JSF) or work in direct correlation to Java (e.g., Ant). All of the tools (NetBeans, GlassFish, MySQL) and technologies used in this project are either sponsored and promoted by Sun, or are technologies which Sun has a vetted interest in, due to their relation to Java.


Target Audience

The target audience for this courseware will be people who are unfamiliar with the technologies employed and/or newcomers to an IDE (i.e., students). As such, it would be a good candidate for edu.netbeans.org. There are four demographics for this tutorial:

  1. Java developers interested in expanding their skillset to include Java EE technologies
  2. Newcomers to the NetBeans IDE wanting to try out its development environment
  3. Web developers wanting to see how Java compares to other web-based technologies
  4. Students wanting to understand the nuts and bolts a simple ecommerce application


Features

The tutorial will cover the following features:

  • Use of the Servlet and JSP technologies
  • MVC architecture
  • Session Management (cookies and URL-rewriting)
  • JavaBeans technology
  • Use of MySQL Database
  • Database connectivity using JDBC
  • Database conectivity using JPA with a persistence provider (EclipseLink)
  • Localization (Language drop-down menu for English/Czech)
  • Security: Private access to admin console
  • Security: Use of SSL with checkout action
  • Client and Server-side validation (checkout form)


Limitations

The tutorial focuses primarily on the design and implementation phases of the development cycle. Although suggestions will be made on how to perform testing, and what third-party tools to use (e.g., HttpUnit), it does not provide instruction on how to implement testing. It also does not bring into consideration issues surrounding deployment to a hosting service. However, this could potentially be realized in a follow-up tutorial (e.g., deployment to the 'cloud') provided functionality becomes available in the IDE, and a public service is realized.


Resources

  • Books


  • People
  • Ed Burns, Senior Staff Engineer (co-specification lead)


  • Online Resources


Tutorial Units

The tutorial is comprised of 8 units.

Unit 1: Introduction

http://testwww.netbeans.org/kb/docs/javaee/ecommerce/intro.html

  • Who this Tutorial is For
  • What is an Ecommerce Application?
  • What is Java?
  • What is the Java EE Platform?
  • Why use an IDE?
  • Why use NetBeans?


Note: The final application demo could be hosted, so that users can experiment with it and gain better insight into what it is they'll be creating. A possibility would be to host it on Sun's Web Developer Resource Center.


Unit 2: Designing the Application

http://testwww.netbeans.org/kb/docs/javaee/ecommerce/design.html

  • The Scenario
  • The Requirements
  • Define customer specification
  • The Business Process Flow
  • Preparing Mockups
  • Determining the Architecture
  • Define the MVC architecture and discuss advantages
  • Planning the Project


Unit 3: Preparing Views for the Presentation Layer

http://testwww.netbeans.org/kb/docs/javaee/ecommerce/prepare-views.html

  • Set up the Development Environment
  • Demonstrate IDE Features:
  • editor capabilities (JavaScript, JSP, HTML)
  • CSS preview and builder
  • Create Placeholders: Part 1
  • Create web project
  • Create stylesheet
  • Implement basic page layout

Image:step1_JavaEcommerceAppTutorial.png

  • Create Placeholders: Part 2
  • Create other page templates (catalog.jsp, cart.jsp)
  • Modify deployment descriptor to include header and footer JSP fragments
  • Create header and footer fragments, add to WEB-INF/jsp
  • Remove header and footer from templates
  • Create Placeholders: Part 3
  • Create and position all elements on page, based on mockups


index.png
Image:step3-index_JavaEcommerceAppTutorial.png



categories.png
Image:step3-categories_JavaEcommerceAppTutorial.png


Unit 4: Connecting the Application to the Database

http://testwww.netbeans.org/kb/docs/javaee/ecommerce/connect-db.html

  • Use of MySQL Database with JDBC

Note:

  • Create the database directly in the Services window; later in logic layer, create persistence unit which will generate JavaBeans for each entity automatically.
  • Use MySQL Workbench to create entity-relationship model.

Image:erdiagram_JavaEcommerceAppTutorial.png

This entity-relationship model is based on affablebean_JavaEcommerceAppTutorial.sql.


  • Discuss top-down vs. bottom-up approach
  • Discuss process-flow diagram:

Image:process-flow_JavaEcommerceAppTutorial.png


Unit 5: Applying a Persistence Provider

  • Persistence
  • JavaBeans
  • Use APIs with JavaDoc window

Unit 6: Developing the Business Logic

TODO


Unit 7: Managing Sessions

  • Discuss scopes
  • Implement shopping cart functionality
  • Mention that language chooser uses a session-scoped attribute


Unit 8: Securing the Application

  • Ensure that customer checkout enables data to be sent in a secure manner
  • Configure SSL on GlassFish
  • Access control for admin console - login requires authentication and authorization


Project Preparation

Version Control

The subversion repository for the application is https://jsf-extensions.dev.java.net/svn/jsf-extensions/branches/TROY_DEMO/code/AffableBean/.

Background

A small grocery store collaborates with several local farms to supply a community with organic produce. Due to a long-standing customer base and increasing affluence to the area, the store has decided to investigate the possibility of providing an online delivery service to customers. A recent survey has indicated that 90% of its regular clientele has continuous Internet access, and 65% percent would be interested in using this service.


Business name: The Affable Bean


Customer Requirements

Based on a series of meetings with the grocery store staff, the following requirements are to be met in the application:

  • A representation of the physical store. This includes a description of its background and outlook, policy, terms and conditions regarding purchase and delivery, and contact details.
  • A catalog of categories and products which online shoppers can browse. Details are provided for each product (i.e., image, description, price).
  • Shopping cart functionality, including the ability to add items to a personal cart, and to finalize one's order and make payment.
  • Security, in the form of protecting sensitive customer data as it is transferred to and maintained within the application.
  • A secure administration console, enabling staff to make updates and modifications to products; view customer orders, etc.


Store Categories

In order to maintain simplicity, the catalog will be limited to four categories, each containing four products:

dairy

  • milk
  • cheese
  • butter
  • free range eggs

meats

  • organic meat patties
  • parma ham
  • chicken leg
  • sausages

bakery

  • sunflower seed loaf
  • sesame seed bagel
  • pumpkin seed bun
  • chocolate cookie

fruit & veg

  • corn on the cob
  • red currants
  • broccoli
  • seedless watermelon


Mockups

index.jsp

Image:mockup-index_JavaEcommerceAppTutorial.png


products.jsp

Image:mockup-products_JavaEcommerceAppTutorial.png


Notes

  • Presuming that the grocery store already has software for maintaining its stock, the database created in the tutorial would need to be synchronized with it while not simultaneously presenting a security risk. This is a real-world constraint not covered in the tutorial.
  • Product images can be taken from Creative Commons.


Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo