+ All Categories
Home > Documents > Shashi Bala

Shashi Bala

Date post: 07-Apr-2018
Category:
Upload: suraj-singh
View: 239 times
Download: 0 times
Share this document with a friend

of 89

Transcript
  • 8/4/2019 Shashi Bala

    1/89

    PROJECT REPORT ON

    PROJECT / DISERTATION WORK REPORT ON

    Submitted In partial fulfillment of The

    Requirement For Qualifying BCA

    Submitted By :

    NAME : SHASHI BALA

    REG. NO : 105013080337

    STUDY CENTRE : KANWAR INFOTECH EDUCATIONSOCIETY (HP014)

    ADDRESS : V.P.O.& TEHSIL INDORA, NEAR K.C.C

    BANK, DISTT. KANGRA, (HP). PIN 176401.

    1

  • 8/4/2019 Shashi Bala

    2/89

    PROJECT CERTIFICATE

    This is to certify that the project/dissertation entitled, SHOPPING CART

    APPLICATIONis a bonafide work done by SHASHI BALA in partial fulfillment

    of BCA examination and has been carried out under my direct supervision and

    guidance. This report or a similar report on the topic has not been submitted for

    any other examination and does not form a part of any other course undergone by

    the candidate.

    Name : SHIV KUMAR

    Place : Indora.

    Signature of Center Coordinator

    Kanwar Infotech Educational Society(HP014)

    V.P.O. & Tehsil - Indora, Near K.C.C. Bank,

    Distt. - Kangra (H.P). PIN - 176401.

    2

  • 8/4/2019 Shashi Bala

    3/89

    ACKNOWLEDGEMENT

    A formal statement of acknowledgement is hardly sufficient to express my

    gratitude towards the personalities who have helped me undertake this project. I

    hereby convey my thankfulness and obligation to all those who have rendered

    their valuable help, support and guidance to meet this end.

    I would like to thank Mr. SHIV KUMAR for spending his precious time for

    completion of this project and providing their valuable comments, practical and

    theoretical guidance and constant encouragement that have been a source of

    inspiration to this entire project.

    I am very thankful to staff member of Library with our project at their concern.

    I would also like to thank all my friends who had directly or indirectly helped me in

    my project work.

    SHASHI BALA

    3

  • 8/4/2019 Shashi Bala

    4/89

    INDEX

    TITLE PAGE---------------------------------------------------------------------- 1

    ACKNOWLEDGEMENT------------------------------------------------------ 2

    HARDWARE AND SOFTWARE REQUIREMENTS------------------- 4

    SHOPPING CART APPLICATION ---------------------------------------- 5

    ARCHITECTURE OF THE S.C.A.------------------------------------------ 6

    ARCHITECTURE OF ONLINE SHOPPING MODULE--------------- 7

    ARCHITECTURE OF THE ADMINISTRATION MODULE--------- 10

    DESIGNING ONLINE DATABASE----------------------------------------- 13

    BOOK DETAILS TABLE ----------------------------------------------------- 14

    CATAGORY DETAILS TABLE -------------------------------------------- 16

    ORDER DETAILS TABLE --------------------------------------------------- 17

    TEMP DETAIL TABLE ------------------------------------------------------- 18

    USER AUTH. TABLE --------------------------------------------------------- 20

    USER PROFILE TABLE------------------------------------------------------- 21

    MAIN SCREEN ------------------------------------------------------------------ 24

    SOURCE CODE ----------------------------------------------------------------- 30

    4

  • 8/4/2019 Shashi Bala

    5/89

    HARDWARE AND SOFTWARE REQUIREMENTS

    Hardware Requirements:

    10 GB or higher Hard Disk

    256 MB RAM.(Recommended)

    CD ROM.

    Scroll Mouse

    Laser or Inkjet printer.

    Keyboard.

    Color Monitor

    Software Requirements:

    Windows XP Professional or Windows 2000 or higher Operating System.

    Java

    Notepad

    5

  • 8/4/2019 Shashi Bala

    6/89

    SHOPPING CART APPLICATION

    The Shopping Cart application enables an end user to search a specific book in an

    online database, place an order for it and also purchase it online. The application

    also enables you to manage the data stored in a database for the online displayed

    books, such as adding a book, adding a book category and modifying the book

    information.

    This chapter shows how to create the Shopping Cart application, using JSP (Java

    Server Pages) as the server side scripting language, JavaScript for client side data

    validations, HTML (Hyper Text Markup Language) for data display and Oracle as

    the database to store the various information, such as books information, customer

    information, order placed information.

    6

  • 8/4/2019 Shashi Bala

    7/89

    ARCHITECTURE OF THE SHOPPING CART

    APPLICATION

    The shopping Cart application consists of various HTML and JSP pages such as

    Login.htm of Validate.jsp. Figure shows the architecture of Shopping Cart

    application.

    The login.htm page is displayed first when the end user executes the Shopping

    Cart application. The Login.htm page displays a login from to allow registered

    user to logon and a hyperlink for the unregistered users to register first a new end

    user clicks the New User? Register hyperlink to open the NewUser.htm page. The

    Sign.jsp page in the new user registration from validates the values entered by the

    end user and saves the information about the new user in the User_Profile tables

    and the user name and password in User_Auth table.

    The Validat.jsp page is called when the end user enters the username and

    password in the login form and clicks the Login button of Login.htm page. The

    Validate.jsp page verifies username and password are entered of no. the

    InvalidUser.htm page is displayed if login fails. The Admin.htm page opens if

    login succeeds and the end user is the administrator else the SearchCriteria.jsp

    page opens.

    7

  • 8/4/2019 Shashi Bala

    8/89

    ARCHITECTURE OF THE ONLINE SHOPPING

    MODULE

    The Shopping Cart application has two modules online shopping module and

    administration module. The online shopping module consists of HTML and JSP

    pages that enables and en user to login and logout as a registered user and to shop

    search for a book from the online database. Figure shows architecture of the online

    shopping module of Shopping Cart application.

    The SearchCriteria.jsp page in the architecture of the online shipping module

    enables the end user to select criteria for searching books, such as book title and

    book author. It also allows the end user to enter a value in a text box to search for

    selected criteria.

    The Search.jsp page is called on clicking the Search button of the Search.jsp page.

    The search.jsp page allows the end user to select books from the search result and

    add them to the cart. A cart is a shopping basket that stores the books selected by

    an end user. It also allows the end user to search for more books.

    The Inter_Cart.jsp page is called on clicking the Add to Cart button one the

    Search.jsp page. The Inter_Cart.jsp page creates the session variables and calls the

    Cart.jsp page. The session variables are the variables that store information about

    an end user for a particular session, such as user name and password.

    8

  • 8/4/2019 Shashi Bala

    9/89

    The Cart.jsp page displays the data stored in the cart of an end user and allows end

    user to search for more books.

    The NewSearch.jsp page is called on clicking the Search button of the Cart.jsp

    page. The NewSearch.jsp page allows the end user to select books form the search

    results and add books to the cart. It also allows the end user to search for more

    books.

    The NewInter_cart.jsp page is called the Add to Cart button to the NewSearch.jsp

    page. The NewInter_Cart.jsp page creates the session variables and calles the

    Cart.jsp page. The session variables in the NewInter_cart stores the updated

    information of books selected by an end user. The Cart_quantity.jsp page is called

    the place Order button of Cart.jsp page.

    The Cart_quantity page enables the end user to enter the number of copies of each

    book present in the end users cart and displays the total bill for the end user.

    The Shop.jsp page is called on clicking the place Order button of the

    Cart_quantity.jsp page. The Shop.jsp page enables the end user to enter his credit

    card number and its expiry date.

    The Final.jsp page is called on clicking the Submit button of Shop.jsp page. The

    Final.jsp page displays the order number, date of order and the total bill for the

    books selected by the end user.

    9

  • 8/4/2019 Shashi Bala

    10/89

    All the pages of the online shipping module duisplay a Click here to Logout

    hyperlink for the end user to logout. The Logout.jsp page is called on clicking the

    logout hyperlink provided on each page. The Unauthorised.htm page is displayed

    when an end user tries to open some page of Shopping Cart application by simply

    specifying the URL (Universal Resource Locator)

    10

  • 8/4/2019 Shashi Bala

    11/89

    ARCHITECTURE OF THE ADMINISTRATION

    MODULE

    The Shopping Cart application enables the end user to administer the information

    about the books available for shopping. Figure 7-3 show architecture of the

    administration module of Shopping Cart application.

    The Admin.htm page of the Shopping cart application contains hyperlinks for

    adding a book, modifying the details of a book, adding a book category and

    modifying the name of a book category.

    The Insert.jsp page is called on clicking the Insert New Book Details hyperlink of

    the Admin.htm page. The Insert,jsp page displays the details of all the books

    available online and allows the end user to enter the details of the new book to be

    added to the online book database.

    The AddBook.jsp page is called on clicking the add button of the Insert.jsp page.

    The AddBoook.jsp page displays a message stating that the new book details have

    been added successfully and contains hyperlinks for going to Admin.htm page,

    Insert.jsp page or Logout.htm page.

    The Modify.jsp page is called on clicking the Modify Book details hyperlink of

    the Admin.htm page. The Modify.jsp page displays the details of all the books

    available and allows the end user to chose the book whose details are to be

    modified.

    11

  • 8/4/2019 Shashi Bala

    12/89

    The Modify_Book.jsp page is called on clicking the Modify button of the

    Modify.jsp page. The Modify_Book.jsp page allows the end user to make changes

    in the details of the selected book.

    The Final_Mod_Book.jsp page is called on clicking the Save Changes button of

    the Modify_Book.jsp page. The Final_Mod_Book.jsp page displays a message

    starting that the book details have been successfully modified and contains

    hyperlinks for going to Admin .htm page, Modify.jsp page of Logout.htm

    page.

    The Insert_Category.jsp page is called the Insert Book Category hyperlink of the

    Admin.htm page. The Insert_Category.jsp page displays the available book

    categories in a combo box component and allows the end user enter the name of

    the new book category to be added.

    The Add Category.jsp page is called on clicking the Add button of the

    Insert_Category page. The AddCategory.jsp page displays a message stating that

    the book category has been successfully added and contains three hyperlinks for

    going to Admin.htm page, Insert_Category.jsp page or Logout.htm page.

    The Update_category.jsp page is called on clicking the Modify Book Category

    hyperlink of the Admn.htm page. The Update_category.jsp page displays the

    available book categories in a combo boxs and allows the end user to select the

    name of the category to be modified from the combo box options. The name of the

    selected category is displayed in textbox and the end user is allowed to make

    changes in the category name.

    12

  • 8/4/2019 Shashi Bala

    13/89

    The Modify.Category.jsp page is displayed on clicking the Modify button of the

    Modify.jsp page. The ModifyCategory.jsp page displays a message stating that the

    book category has been successfully modified and contains three hyperlinks for

    going to Admin.htm page, Update_Category.jsp page of Logout.htm page.

    All the pages of the administration module display a hyperlink to allow the end

    user to logout. The Logout.jsp page is called on clicking the logout hyperlink

    provided on each page.

    13

  • 8/4/2019 Shashi Bala

    14/89

    DESIGNING ONLINE DATABASE

    The Shopping Cart application uses seven tables to store information about books

    and orders. The tables used in the Shopping Cart application are :

    Book_Details: Stores information about the books, such as book title,

    author and publisher of the book.

    Category_Details: Stores information about book about book categories,

    such as category ID and name of the category.

    Order_Details : Stores information about the order placed by an end user,

    such as ordered and bookID. It contains separate record fro each book

    purchased.

    Temp_Detail: Stores information about the books that have been searched

    by the end user.

    Temp_Detail: Stores information about the books that have been searched

    by the end user.

    User_Profile: Stores information about all registerd users, such as name

    address and phone number.

    Order_table: Stores information about the orders placed, such as ordered

    and userID. It contains separate record for each order placed by an end user.

    14

  • 8/4/2019 Shashi Bala

    15/89

    CREATING THE BOOK_DETAILS TABLE

    The Book_Details table contains various fields such as Book ID t stores

    information about the books. Table lists the structure of Book_Details table:

    Structure of Book_Details Table

    Field Name Date Type

    BookID Number(5), primary key

    CategoryID Number(5), foreign key

    Title Varchar2(50)

    Author Varchar2(30)

    Publisher Varchar2(30)

    Edition Varchar2(5)

    Price Number(7,2)

    Quantity Number(3)

    Description Varchar2(100)

    The Book_Details table stores information about the books available in the

    shopping cart Listing shows how to create the Book_Details table:

    Creating the book_Details Table

    Create table Boook_Details

    {

    BookID number(5) primary key,

    CategoryID number(5)

    Title varchar2(50),

    Author carchar2(30)

    15

  • 8/4/2019 Shashi Bala

    16/89

    Publisher varchar2(30),

    Edition varchar2(5),

    Price number(7 ,2)

    Quantity number(3)

    Description varchar2(100),

    Constraint cat_fk foreign key(categoryid)

    References category_details (categoryid)

    );

    16

  • 8/4/2019 Shashi Bala

    17/89

    CREATING THE CATEGORY_DETAILS TABLE

    The Category_Detaisl table contains two fields, such as category ID and

    Category_Name to store information about book categories. Tables lists the

    structure of the Ctegory_Details table:

    Structure of the Category_Details Talbe

    Field Name Data Type

    CategoryID Number(5), primary key

    CategoryName Varchar2(30)

    Listing shows how to create the Cagtegory_Details table

    Creating the Category_Details Table

    Create table Category_Details

    (

    categoryID number(5) primary key,

    CategoryName varchar2(30)

    );

    17

  • 8/4/2019 Shashi Bala

    18/89

    CREATING THE ORDER_DETAILS TABLE

    The Order_Detrails table contains various fields, such as OrderID to store

    information about individual order placed by an end user. It contains separate

    record for each book purchased . table lists the structure of the Order_Details

    table:

    Structure of the Order_Details table

    Field Name Date Type

    OrderID Number(5), foreign key

    BookID Number(5), foreign key

    quantity Number(3)

    Listing shows how to create the Order_Details table:

    Creating the Order_Details Talbe

    Create table order_Details

    (

    OrderID number(5)

    BookID number(5)

    Quantity number(3)

    Constraint order_fk foreign key(ordered)

    References order_table (ordered),

    Constraint book_fk foreign key (bookid)

    References book_details(bookid)

    18

  • 8/4/2019 Shashi Bala

    19/89

    );

    CREATING THE TEMP_DETAIL TABLE

    The Temp_Detail table contains various fields, such as BookID to store

    information about the books that have been searched by the end user. Table lists

    the structure o f the Temp_Detail table:

    Structure of the Temp_Details Table

    Field Name Data Type

    BookID Number(5)

    CategoryID Number(5)

    Title Varchar2(50)

    Author Varchar2(30)

    Publisher Varchar2(30)

    Edition Varchar2(5)

    Price Number(7,2)

    Quantity Number(3)

    Description Varchar2(100)

    Listing shows how to create the Temp_Detail table:

    Creating the Temp_Detail Table

    Create table Temp_Detail

    19

  • 8/4/2019 Shashi Bala

    20/89

    (

    BookID number(5),

    CategoryID number (5),

    Title varcher2(50)

    Author varchar2(30),

    Publisher varchar2(5),

    Edition varchar2(5),

    Price number(7,2)

    Quantity number(3),

    Description varchar2(100)

    );

    20

  • 8/4/2019 Shashi Bala

    21/89

    CREATING THE USER_AUTH TABLE

    The User_Auth table contains two fields, such as UserName and Password to store

    the username and password for various end users. Table lists the structure of the

    User_Auth table.

    Structure to the User_Auth Table

    Field Name Data Type

    UserName Varchar2(30),foreign key

    Password Varhcar2(15)

    Listing shows how to create the User_Auth table:

    Creating the User_Auth Table

    Creating the User_Auth

    (

    UserName varchar2(30),

    Password varchar2(15),

    Constraint uname_fk foreign key (username)

    References user_profile (username),

    );

    21

  • 8/4/2019 Shashi Bala

    22/89

    CREATING THE USER_PROFILE TABLE

    The User_Profile table contains various fields, such as FirstName to store

    information about all registered users. Table lists the structure of the User_Profile

    table:

    Structure of the User_Profile Table

    Field Name Data Type

    UserName Varchar2(30), primary keyPassword Varchar2(15), not null

    FirstName Varchar2(10), not null

    MiddleName Varchar2(10)

    LastName Varchar2(10), not null

    Address1 Varchar2(40), not null

    Address2 Varchar2(40)

    City Varchar2(20), not null

    State Varchar2(20), not null

    PinCode Varchar2(10), not null

    Email Varchar2(25), not null

    Phone Varchar(12), not null

    Listing shows how create the User_profile table:

    Creating the User_Profile Table

    CREATE TABLE User_Profile (

    Username varchar2 (30) primary key,

    Password Varchar2 (15) NOT NULL,

    22

  • 8/4/2019 Shashi Bala

    23/89

    FirstName Varchar2 (10) NOT NULL,

    MiddleName Varchar2 (10),

    LastName Varchar2 (10) NOT NULL,

    Address1 Varchar2 (40) NOT NULL,

    Address2 Varchar2 (40),

    City Varchar2 (20) NOT NULL,

    State Varchar2 (20) NOT NULL,

    PinCode Varchar2 (10),

    Email Varchar2 (25) NOT NULL,

    Phone varchar (12)

    )

    23

  • 8/4/2019 Shashi Bala

    24/89

    CREATING THE ORDER_TABLE TABLE

    The Order_Table table contains various fields, such as OrdreID to store

    information about all orders placed by an end user. It contains separate record for

    each order placed by an end user order. Table lists the structure of the

    Order_Table table:

    Structure of the Order_Table Table

    Field Name Data Type

    OrderID Number(5), primary key

    UserID Number(5)

    TotalAmount Number(12,2)

    OrderDate Varchar2 (8)

    24

  • 8/4/2019 Shashi Bala

    25/89

    25

  • 8/4/2019 Shashi Bala

    26/89

    26

  • 8/4/2019 Shashi Bala

    27/89

    27

  • 8/4/2019 Shashi Bala

    28/89

    28

  • 8/4/2019 Shashi Bala

    29/89

    29

  • 8/4/2019 Shashi Bala

    30/89

    30

  • 8/4/2019 Shashi Bala

    31/89

    31

  • 8/4/2019 Shashi Bala

    32/89

    Login

    Online Shopping Cart

    function validate()

    {

    if(document.frm.UserName.value==""||document.frm.Password.value=="")

    {

    alert("UserName or Password cannot be blank!!");return;

    }

    document.frm.action="Validate.jsp";document.frm.submit();

    }

    Login Form

    UserName:

    Password:

    New User?Register

    32

  • 8/4/2019 Shashi Bala

    33/89

    CREATING THE NEWUSER.HTM PAGE

    New User Registration

    Online Shopping Cart

    function validate()

    {if( document.form1.UserName.value=="")

    {

    alert("UserName cannot be blank");

    return;

    }

    if( document.form1.Password.value=="")

    {

    alert("Password cannot be blank");

    return;

    }

    if( document.form1.Password.value!= document.form1.Password2.value)

    {alert("The two passwords do not match");

    return;

    }

    if( document.form1.FirstName.value==""){

    alert("First Name cannot be blank");

    return;

    }

    if(document.form1.LastName.value=="")

    {

    alert("Last Name cannot be blank");

    return;}

    if( document.form1.Address1.value=="")

    {alert("Address cannot be blank");

    return;

    }

    if( document.form1.City.value=="")

    33

  • 8/4/2019 Shashi Bala

    34/89

    {

    alert("City cannot be blank");

    return;

    }

    if( document.form1.State.value=="Select State")

    {alert("You must select a state");

    return;

    }

    if( document.form1.PinCode.value=="")

    {

    alert("PinCode cannot be blank");

    return;

    }

    if( document.form1.Email.value=="")

    {

    alert("Email ID cannot be blank");

    return;}

    if( document.form1.Phone.value=="")

    {

    alert("Phone Number cannot be blank");

    return;

    }

    document.forms[0].action="Sign.jsp";

    document.forms[0].submit();

    }

    New User Registration

    ( Field marked * are

    necessary)&nbs

    p;

    &

    nbsp;

    User *:

    34

  • 8/4/2019 Shashi Bala

    35/89

    Password*:

    Confirm Password*:

    First Name*:

    Middle Name:

    Last Name*:

    Address1*:

    35

  • 8/4/2019 Shashi Bala

    36/89

  • 8/4/2019 Shashi Bala

    37/89

    CREATING THE INVALIDUSER.HTM PAGE

    Invalid User

    Online Shopping Cart


    The specified user does not exist.




    Create New Account

    Click

    here

    Login Again

    Click here

    37

  • 8/4/2019 Shashi Bala

    38/89

    CREATING THE UNAUTHORISED.HTM PAGE

    Invalid User


    Online Shopping Cart



    Your session is not valid. Please login again.



    Click here to Login

    CREATING THE SIGN.JSP PAGE

  • 8/4/2019 Shashi Bala

    39/89

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

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

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

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

    int flag=0;

    try

    {

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    conn =DriverManager.getConnection("jdbc:odbc:Data","scott","tiger");

    PreparedStatement stat= conn.prepareStatement("SELECT * FROM user_profile

    where username=?" );

    stat.setString(1,UserName);

    rs = stat.executeQuery();

    out.println("query executed");

    if(rs.next()){

    flag=1;

    %>

    alert("User name already exists");

    location.href="NewUser.htm";

  • 8/4/2019 Shashi Bala

    40/89

    stat.setString(4,MiddleName);

    stat.setString(5,LastName);

    stat.setString(6,Address1);

    stat.setString(7,Address2);

    stat.setString(8,City);

    stat.setString(9,State);stat.setString(10,PinCode);

    stat.setString(11,Email);

    stat.setString(12,Phone);

    stat.executeUpdate();

    stat1.executeUpdate();

    flag=0;

    response.sendRedirect("Login.htm");

    }

    catch(Exception E)

    {

    out.println("Error inserting value"+E);}

    finally

    {

    rs.close();

    conn.close();

    }

    }

    %>

    CREATING THE VALIDATE.JSP PAGE

  • 8/4/2019 Shashi Bala

    41/89

    stat.setString(2,strPass);

    rs = stat.executeQuery();

    if(rs.next())

    {

    String str1,str2;str1=rs.getString(1);

    str2=rs.getString(2);

    out.println(str1+str2);

    session.putValue("user",strName);

    if(str1.equals("Administrator"))

    {

    response.sendRedirect("Admin.htm");

    }

    else

    {

    out.println("Logged IN");

    response.sendRedirect("SearchCriteria.jsp");}

    }

    else

    {

    response.sendRedirect("InvalidUser.htm");

    }

    }

    catch(Exception E)

    {

    out.println("Error "+E);

    }

    finally{

    rs.close();

    conn.close();

    }

    %>

    CREATING THE SEARCHCRITERIA.JSP PAGE

    Search Items

    41

  • 8/4/2019 Shashi Bala

    42/89

    Online Shopping Cart

    function startSearch(){

    if(document.frm.R1[1].checked)

    {

    if(document.frm.BookTitle.value=="")

    {

    alert("You must enter a book title");

    return;

    }

    }

    if(document.frm.R1[2].checked)

    {if(document.frm.BookAuthor.value=="")

    {

    alert("You must enter an author name");

    return;

    }

    }

    if(document.frm.R1[3].checked)

    {

    if(document.frm.BookPublisher.value=="")

    {

    alert("You must enter a publisher name");return;

    }

    }

    document.frm.action="search.jsp";document.frm.submit();

    }

  • 8/4/2019 Shashi Bala

    43/89

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    con = DriverManager.getConnection("jdbc:odbc:Data","scott","tiger");

    stat = con.prepareStatement("select * from category_details");

    rs=stat.executeQuery();%>

    Search Books



    Search by Category

    Select Category

    Search by Book Title

    Search by Book Author

    Search by Book Publisher

    43

  • 8/4/2019 Shashi Bala

    44/89

    Click here to

    logout

    CREATING THE SEARCH.JSP PAGE

    Search Results

    Online Shopping Cart

    Search Results


    Click here to Logout

  • 8/4/2019 Shashi Bala

    45/89

    int chk_ctr=0;

    String str_colvar=null;

    String tab_var="";

    String user_src=(String)session.getValue("user");

    System.out.println("0");

    if (user_src!=null){

    String query=null;

    Connection conn;

    conn=null;

    ResultSet rs;

    rs=null;

    if(request.getParameter("R1").equals("Title"))

    {

    str_searchvar=request.getParameter("BookTitle");

    str_colvar="TITLE";

    }

    if(request.getParameter("R1").equals("Category")){

    chk_ctr=1;

    str_searchvar=request.getParameter("BookCategory");

    str_colvar="Categoryname";

    }

    if(request.getParameter("R1").equals("Publisher"))

    {

    str_searchvar=request.getParameter("BookPublisher");

    str_colvar="Publisher";

    }

    if(request.getParameter("R1").equals("Author"))

    { str_searchvar=request.getParameter("BookAuthor");

    str_colvar="Author";

    }

    if (request.getParameter("R2")==null)

    {tab_var="BOOK_DETAILS";

    }

    else

    {

    // to get the name of the table in which the search to be done-------

    if (request.getParameter("R2").equals("A"))

    { tab_var="TEMP_DETAIL";

    }

    else

    {

    tab_var="BOOK_DETAILS";

    }

    }

    45

  • 8/4/2019 Shashi Bala

    46/89

    System.out.println(str_searchvar);

    query = "select a.* from "+tab_var+" a, category_details b where a."+str_colvar+" = ?

    and a.CATEGORYID = b.CATEGORYID";

    System.out.println("1");

    try

    {Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    conn =DriverManager.getConnection("jdbc:odbc:Data","scott","tiger");

    int ctr=0;

    System.out.println("2");

    PreparedStatement stm = conn.prepareStatement(query);

    stm.setString(1,str_searchvar);

    rs = stm.executeQuery();

    %>

    S.No

    Select

    Book Name

    Author Name

    Publisher

    Edition

    Price (in Rs.)

    Quantity Available(Nos.)

    Description

  • 8/4/2019 Shashi Bala

    47/89

    String str_PUBLISHER=rs.getString(5);

    out.println("");

    out.println(str_PUBLISHER);

    out.println("");

    String str_EDITION=rs.getString(6);

    out.println("");

    out.println(str_EDITION);

    out.println("");

    int int_PRICE=rs.getInt(7);

    out.println("");

    out.println(int_PRICE);

    out.println("");

    int int_QUANTITY=rs.getInt(8);

    out.println("");

    out.println(int_QUANTITY);

    out.println("");

    String str_DESCRIPTION=rs.getString(9);

    out.println("");

    out.println(str_DESCRIPTION);

    out.println("");

    String ins_query ="INSERT INTO temp_detail VALUES (?,?,?,?,?,?,?,?,?)";

    PreparedStatement stat_ins= conn.prepareStatement(ins_query);

    stat_ins.setInt(1,int_BOOKID);

    stat_ins.setInt(2,int_CATEGORYID);

    stat_ins.setString(3,str_TITLE);

    stat_ins.setString(4,str_AUTHOR);stat_ins.setString(5,str_PUBLISHER);

    stat_ins.setString(6,str_EDITION);

    stat_ins.setInt(7,int_PRICE);

    stat_ins.setInt(8,int_QUANTITY);

    stat_ins.setString(9,str_DESCRIPTION);

    int x = stat_ins.executeUpdate();System.out.println(x);

    }

    String str_ctr=String.valueOf(ctr);

    session.putValue("ctr_val",str_ctr);

    %>

    47

  • 8/4/2019 Shashi Bala

    48/89


    CREATING THE LOGOUT.JSP PAGE

    Logged out

    Online Shopping Cart





    You have logged out successfully.

    Return to Shopping Cart? Click here

    48

  • 8/4/2019 Shashi Bala

    49/89

    CREATING THE INTER_CART.JSP PAGE

  • 8/4/2019 Shashi Bala

    50/89


    Click here to Logout

  • 8/4/2019 Shashi Bala

    51/89

    stat.setInt(1,bookid[j-1]);

    rs = stat.executeQuery();

    while (rs.next())

    {

    out.println("");out.println(rs.getString(1));

    out.println("");

    price=rs.getInt(2);

    out.println(price);

    }

    rs.close();

    bookprice=bookprice+price;

    session.putValue("bPrice",String.valueOf(bookprice));

    out.println("");

    }

    ResultSet rscombo=null;String query1="select * from category_details";

    PreparedStatement stat_combo = conn.prepareStatement(query1);

    rscombo=stat_combo.executeQuery();%>

    Total Cart Amount(in Rs.)=



    Search More

    Search based on Category

    Select Category

    51

  • 8/4/2019 Shashi Bala

    52/89

    Search by Book Title

    Search by Book Author

    Search by Book Publisher

    Advanced Search

    New

    Search

    CREATING THE NEWSEARCH.JSP PAGE

    Search Results

    Online Shopping Cart


    Click here to Logout

  • 8/4/2019 Shashi Bala

    53/89

    if (user_src!=null)

    {

    String str_searchvar=null;

    String str_colvar=null;

    String query="";

    String tab_var="";int total_sel=Integer.parseInt((String)session.getValue("TotalSel"));

    int[] old_bookid=new int[total_sel];

    Connection conn;

    conn=null;

    ResultSet rs;

    rs=null;

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    conn =DriverManager.getConnection("jdbc:odbc:Data","scott","tiger");

    PreparedStatement stat=null,stat_ins=null,stat_del=null;

    for (int i=1;i

    Your Cart Details are as follows:

    S.No

    Book Name

    Price (in Rs.)

  • 8/4/2019 Shashi Bala

    54/89

    rs.close();

    bookprice=bookprice+price;

    out.println("");

    }%>

    Total Cart Amount(in Rs.)=


  • 8/4/2019 Shashi Bala

    55/89

    {

    tab_var="temp_detail";

    }

    else

    {tab_var="book_details";

    }

    }

    //-------- whether search is by category or other criteria-----------

    if (chk_ctr==0)

    {

    query="select a.* from "+tab_var+" a, category_details b where a."+str_colvar+"

    = ? and a.CATEGORYID = b.CATEGORYID";}

    else

    {

    query="SELECT a.*,b.categoryname FROM "+tab_var+"

    a,CATEGORY_DETAILS b where b."+str_colvar+"=? and a.categoryid=b.categoryid";

    }

    try

    {

    stat=conn.prepareStatement(query);

    stat.setString(1,str_searchvar);

    rs = stat.executeQuery();

    int ctr=0;%>Search Results are as follows:

    S.No

    Select

    Book NameAuthor Name

    Publisher

    Edition

    Price (in Rs.)

    Quantity Available(Nos.)

    Description

  • 8/4/2019 Shashi Bala

    56/89

    stat_del= conn.prepareStatement(delete_query);

    String ins_query=null;

    int int_BOOKID,int_CATEGORYID,int_PRICE,int_QUANTITY;

    String

    str_TITLE,str_AUTHOR,str_PUBLISHER,str_EDITION,str_DESCRIPTION;

    int rs_del=stat_del.executeUpdate();

    while(rs.next())

    {

    ctr=ctr+1;

    out.println(""+ctr);

    int_BOOKID=rs.getInt(1);

    out.println("");

    int_CATEGORYID=rs.getInt(2);

    str_TITLE=rs.getString(3);out.println("");

    out.println(str_TITLE);

    str_AUTHOR=rs.getString(4);

    out.println("");

    out.println(str_AUTHOR);

    str_PUBLISHER=rs.getString(5);

    out.println("");

    out.println(str_PUBLISHER);

    str_EDITION=rs.getString(6);

    out.println("");

    out.println(str_EDITION);

    int_PRICE=rs.getInt(7);

    out.println("");

    out.println(int_PRICE);

    int_QUANTITY=rs.getInt(8);

    out.println("");

    out.println(int_QUANTITY);

    str_DESCRIPTION=rs.getString(9);

    out.println("");

    out.println(str_DESCRIPTION);

    out.println("");

    56

  • 8/4/2019 Shashi Bala

    57/89

    ins_query="INSERT INTO TEMP_DETAIL

    VALUES(?,?,?,?,?,?,?,?,?)";

    stat_ins=conn.prepareStatement(ins_query);

    stat_ins.setInt(1,int_BOOKID);

    stat_ins.setInt(2,int_CATEGORYID);

    stat_ins.setString(3,str_TITLE);stat_ins.setString(4,str_AUTHOR);

    stat_ins.setString(5,str_PUBLISHER);

    stat_ins.setString(6,str_EDITION);

    stat_ins.setInt(7,int_PRICE);

    stat_ins.setInt(8,int_QUANTITY);

    stat_ins.setString(9,str_DESCRIPTION);

    int rs_ins=stat_ins.executeUpdate();

    }

    String str_ctr=String.valueOf(ctr);session.putValue("ctr_val",str_ctr);

    %>


    Search Results are as follows:

    Search based on Category

    Select Category

    57

  • 8/4/2019 Shashi Bala

    58/89

    Search by Book Title

    Search by Book Author

    Search by Book Publisher

    Advanced Search

    New Search

    CREATING THE NEWINTER_CART.JSP PAGE

  • 8/4/2019 Shashi Bala

    59/89

    int i;

    String bookid=null;

    String user_src=null;

    user_src=(String)session.getValue("user");

    if (user_src!=null)

    {int counter=0;

    int total_sel=Integer.parseInt((String)session.getValue("TotalSel"));

    counter=Integer.parseInt((String)session.getValue("ctr_val"));

    int ctr=total_sel;

    for(i=1;i

    CREATING THE CART_QUANTITY.JSP PAGE

    Shopping Cart

    Online Shopping Cart


    Click here to Logout

  • 8/4/2019 Shashi Bala

    60/89

    {

    int counter=0;

    counter=Integer.parseInt((String)session.getValue("TotalSel"));%>

    function check_sum(){

    var cost=0;

    x_avlqty=new Array();

    y_orderqty=new Array();

    z_price=new Array();

    for (var i=0;i

  • 8/4/2019 Shashi Bala

    61/89

    if((String)session.getValue("chk_var"+i)!=null)

    {

    bookid[i-

    1]=Integer.parseInt((String)session.getValue("chk_var"+i));

    }

    }session.putValue("BookArr",bookid);

    %>

    Your Cart Details are as follows:

    S.No

    Book Name

    Price per unit (in Rs.)

    Quantity Available

    Quantity PurchasedAmount

    >

    61

  • 8/4/2019 Shashi Bala

    62/89

    Total Amount(in Rs.)



    CREATING THE SHOP.JSP PAGE

    Order Details

    Online Shopping Cart


    Click here to Logout

    function validate()

    {

    var r = document.form1;

    var creditcard=r.Card.value;

    var year = r.Year.value;

    var month = r.Month.value;

    62

  • 8/4/2019 Shashi Bala

    63/89

    var day = r.Day.value;

    if(creditcard.length!=16)

    {

    alert("Invalid Credit Card Number");

    r.Card.focus();return;

    }

    //-----------------------------------------------------------------------

    if(day=="Select Day")

    {

    alert("Please select the day");

    r.Day.focus();

    return;

    }

    //-----------------------------------------------------------------------

    if(month=="Select Month"){

    alert("Please select the month");

    r.Month.focus();

    return;

    }

    //-----------------------------------------------------------------------

    if(year.length==0)

    {

    alert("Please enter the year");

    r.Year.focus();

    }

    else if (year.length!=4){

    alert("Please enter the year in YYYY format");

    r.Year.focus();

    }

    //-----------------------------------------------------------------------if (( month == "3" || month == "5" || month == "8" || month == "10") && (day == "31"))

    {

    alert("Please enter a valid date");

    r.Day.focus();

    }

    if ((month == "1") && (day == "30" || day == "31"))

    { alert("Please enter a valid date");

    r.Day.focus();

    }

    //------- To check that card date is not less than current date----------

    var vr_day;

    var vr_month;

    var vr_year;

    var d=new Date();

    63

  • 8/4/2019 Shashi Bala

    64/89

    vr_year=d.getFullYear();

    vr_month=d.getMonth();

    vr_day=d.getDate();

    if(parseInt(vr_year)>parseInt(document.form1.Year.value))

    {alert("Year cannot be less than Current Year");

    return false;

    }

    else if(parseInt(vr_year)==parseInt(document.form1.Year.value))

    {

    if(parseInt(vr_month)>parseInt(document.form1.Month.value))

    {

    alert("Month cannot be less than Current Month");

    return false;

    }

    else if(parseInt(vr_month)==parseInt(document.form1.Month.value))

    {if(parseInt(vr_day)>parseInt(document.form1.Day.value))

    {

    alert("Day cannot be less than current Day");

    return false;

    }

    }

    }

    //------------------------------------------------------------------------

    document.form1.submit();

    document.forms[0].action="Final.jsp";

    }

  • 8/4/2019 Shashi Bala

    65/89

    if((String)session.getValue("chk_var"+i)!=null)

    {

    bookid[i-

    1]=Integer.parseInt((String)session.getValue("chk_var"+i));

    query="SELECT PRICE FROM BOOK_DETAILS WHEREBOOKID=?";

    stat=conn.prepareStatement(query);

    stat.setInt(1,bookid[i-1]);

    rs=stat.executeQuery();

    if(rs.next())

    {

    bk_price[i-1]=rs.getInt(1);

    }

    else

    {

    bk_price[i-1]=0;}

    }

    if(request.getParameter("qty"+i)!=null)

    {

    bk_quantity[i-

    1]=Integer.parseInt(request.getParameter("qty"+i));

    String sess_var=String.valueOf(bk_quantity[i-1]);

    session.putValue(sess_var,String.valueOf(bk_quantity[i-1]));

    }

    bookprice=bookprice+(bk_price[i-1]*bk_quantity[i-1]);

    i++;

    }

    session.putValue("bPrice",String.valueOf(bookprice));

    %>

    Total Amount (in Rs.) is :

    Credit Card Number:

    Expiry Date :

    65

  • 8/4/2019 Shashi Bala

    66/89

    Select Day

    1

    2

    3

    45

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    1617

    18

    19

    20

    21

    22

    23

    24

    25

    26

    27

    2829

    30

    31

    Select Month

    January

    February

    March

    AprilMay

    June

    July

    August

    September

    October

    November

    December

    66

  • 8/4/2019 Shashi Bala

    67/89

    CREATING THE FINAL.JSP PAGE

    Order placed

    Online Shopping Cart

    Order Details


    Click here to Logout

  • 8/4/2019 Shashi Bala

    68/89

    conn=null;

    ResultSet rs=null;

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    conn =DriverManager.getConnection("jdbc:odbc:Data","scott","tiger");

    PreparedStatement stat1=null,stat_sel=null,stat_ins=null;

    OrderID=(int)(10000*Math.random()+1);

    price=Integer.parseInt((String)session.getValue("bPrice"));

    int counter=0;

    counter=Integer.parseInt((String)session.getValue("TotalSel"));

    int[] bookid=new int[counter];

    int[] bk_quantity=new int[counter];

    int org_bkqty=0;

    int i=0;

    String ins_query="";

    String sel_qtyQuery="";

    String ins_qty="";

    for(i=1;i

  • 8/4/2019 Shashi Bala

    69/89

    stat_sel.setInt(1,bookid[i-1]);

    rs_sql=stat_sel.executeQuery();

    if(rs_sql.next())

    {

    org_bkqty=rs_sql.getInt(1);

    }rs_sql.close();

    String ns_qty="UPDATE BOOK_DETAILS SET QUANTITY=?

    WHERE BOOKID=?";

    stat_ins=conn.prepareStatement(ns_qty);

    stat_ins.setInt(1,org_bkqty-bk_quantity[i-1]);

    stat_ins.setInt(2,bookid[i-1]);

    rs_int=stat_ins.executeUpdate();

    }

    }catch(Exception e){}

    %>


    Your order has been successfully placed.



    Order Number is :



    Total Amount is :



    Date of Order is:



    Your Order will be delivered within next 48 working hours

  • 8/4/2019 Shashi Bala

    70/89

    stat.setString(2,user_src);

    stat.setInt(3,price);

    stat.setString(4,s1);

    int x = stat.executeUpdate();

    }catch(Exception e){out.println(e); }

    }

    else

    {

    response.sendRedirect("Unauthorised.htm");

    }

    %>

    CREATING THE ADMIN.HTM PAGE

    Administering Shopping Cart

    Administering Online Shopping Cart




    Welcome Administrator

    1

    Book

    Insert New Book Details

    70

  • 8/4/2019 Shashi Bala

    71/89

    Modify Book Details

    2

    Category

    Insert Book CategoryModify Book Category

    CREATING THE INSERT.JSP PAGE

    Insert New Book

    Administering Online Shopping Cart

    Add Book



    Click here to Logout

    function check()

    {

    var ctr=0;

    if(document.addbook.title.value=="")

    {

    alert("Please Enter Title");

    return;

    }

    if(document.addbook.author.value=="")

    {alert("Please Enter Author");

    return;}

    if(document.addbook.pub.value=="")

    {

    alert("Please Enter Publisher Name");

    return;

    }

    if(document.addbook.edition.value=="")

    71

  • 8/4/2019 Shashi Bala

    72/89

    {

    alert("Please Enter Edition");

    return;

    }

    if(document.addbook.price.value=="")

    {alert("Please Enter Price (in Rs.)");

    return;

    }

    if(document.addbook.qty.value=="")

    {

    alert("Please Enter Quantity");

    return;

    }

    if(document.addbook.desc.value=="")

    {

    alert("Please Enter Description");return;

    }

    if(isNaN(document.addbook.price.value))

    {

    alert("Please Enter a numeric value for Price (in Rs.)");

    ctr=1;

    }

    if(isNaN(document.addbook.qty.value))

    {

    alert("Please Enter a numeric value for Quantity");

    ctr=1;

    }if(ctr==0)

    {

    document.forms[0].action="AddBook.jsp";

    document.forms[0].submit();

    }else

    {

    return true;

    };

    }

  • 8/4/2019 Shashi Bala

    73/89

    PreparedStatement stat1 = null;

    ResultSet rs = null;

    ResultSet rs1 = null;

    String query=null;

    String query1=null;int ctr=0, flag=0;

    try

    {

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    con = DriverManager.getConnection("jdbc:odbc:Data","scott","tiger");

    query="Select a.*,b.categoryname from book_details a, category_details b where

    a.categoryid=b.categoryid";

    query1="select * from category_details";

    stat = con.prepareStatement(query);stat1 = con.prepareStatement(query1);

    rs=stat.executeQuery();

    rs1=stat1.executeQuery();

    %>


    List of Available Books:

    S.No

    Book IdBook Name

    Author Name

    Publisher

    Edition

    Price (in Rs.)Quantity Available(Nos.)

    Description

    Category

  • 8/4/2019 Shashi Bala

    74/89

    str_TITLE=rs.getString(3);

    out.println("");

    out.println(str_TITLE);

    str_AUTHOR=rs.getString(4);out.println("");

    out.println(str_AUTHOR);

    str_PUBLISHER=rs.getString(5);

    out.println("");

    out.println(str_PUBLISHER);

    str_EDITION=rs.getString(6);

    out.println("");

    out.println(str_EDITION);

    int_PRICE=rs.getInt(7);out.println("");

    out.println(int_PRICE);

    int_QUANTITY=rs.getInt(8);

    out.println("");

    out.println(int_QUANTITY);

    str_DESCRIPTION=rs.getString(9);

    out.println("");

    out.println(str_DESCRIPTION);

    out.println("");out.println(rs.getString(10));

    out.println("");

    }

    out.println("");%>

    Add New Book Details

    Book Title

    Author NamePublisher

    Edition

    Price (in Rs.)

    Quantity Available(Nos.)

    Description

    Category

    74

  • 8/4/2019 Shashi Bala

    75/89

    CREATING THE ADDBOOK.JSP PAGE

    Insert New Book

    Administering Online Shopping Cart

    Add Book


  • 8/4/2019 Shashi Bala

    76/89

    int rs;

    String query=null;

    String query1=null;

    String TITLE;

    TITLE=request.getParameter("title");

    query1="Select a.* from book_details a where a.title=?";PreparedStatement stat1= con.prepareStatement(query1);

    stat1.setString(1,TITLE);

    rs1=stat1.executeQuery();

    if(rs1.next())

    {

    %>

    alert("This book already exists.");

    location.href="Insert.jsp";

    76

  • 8/4/2019 Shashi Bala

    77/89


    Successfully inserted the data.


    Could not add the book


    Click here to logout



    Click here to go to administrator page



    Click here to add more books

    CREATING THE MODIFY.JSP PAGE

    Modify Book Details

    Administering Online Shopping Cart

    Modify Book Details




    Click here to Logout

  • 8/4/2019 Shashi Bala

    78/89

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    con = DriverManager.getConnection("jdbc:odbc:Data","scott","tiger");

    query="Select a.*,b.categoryname from book_details a, category_details b where

    a.categoryid=b.categoryid";stat = con.prepareStatement(query);

    rs=stat.executeQuery();

    %>


    List of Available Books:

    S.No

    Book Id

    Book Name

    Author NamePublisher

    Edition

    Price (in Rs.)

    Quantity Available(Nos.)

    Description

    Category

  • 8/4/2019 Shashi Bala

    79/89

    str_EDITION=rs.getString(6);

    out.println("");

    out.println(str_EDITION);

    int_PRICE=rs.getInt(7);

    out.println("");out.println(int_PRICE);

    int_QUANTITY=rs.getInt(8);

    out.println("");

    out.println(int_QUANTITY);

    str_DESCRIPTION=rs.getString(9);

    out.println("");

    out.println(str_DESCRIPTION);

    out.println("");

    out.println(rs.getString(10));

    out.println("");

    }

    %>

    CREATING THE MODIFY_BOOK.JSP PAGE

    Modify Book

    Administering Online Shopping Cart

    Modify Book Details

    79

  • 8/4/2019 Shashi Bala

    80/89



    Click here to Logout


    Details of Selected Book:

    Book Id

    Book Name>

    Author Name>

    Publisher>

    80

  • 8/4/2019 Shashi Bala

    81/89

    Edition>

    Price (in Rs.)>

    Quantity Available(Nos.)

    Description>

    Category>

    CREATING THE FINAL_MOD_BOOK.JSP PAGE

    Book Details Modified

    Administering Online Shopping Cart

    Book Details Modified




    81

  • 8/4/2019 Shashi Bala

    82/89

  • 8/4/2019 Shashi Bala

    83/89

    out.println("Book details for Book Id "+int_BOOKID+" successfully

    modified.");

    }

    else

    {

    out.println("Sorry Transaction not Completed");}

    %>



    Click here to logout



    Click here to go to administrator page



    Click here to modify more books

    CREATING THE INSERT_CATEGORY.JSP PAGE

    Insert New Category

    Administering Online Shopping Cart

    Add Category




    Click here to Logout

  • 8/4/2019 Shashi Bala

    84/89

    query="select * from category_details";

    stat = con.prepareStatement(query);

    rs=stat.executeQuery();%>


    Add New Category:

    Categories Available

    Category to be added

    CREATING THE ADDCATEGORY.JSP PAGE

    84

  • 8/4/2019 Shashi Bala

    85/89

    Insert New Category

    Administering Online Shopping Cart Add Category



    New Category Successfully AddedTransaction Not Allowed


    Click here to Logout



    85

  • 8/4/2019 Shashi Bala

    86/89

    Click here to go to administrator

    page



    Click here to add more

    categories



    CREATING THE UPDATE_CATEGORY.JSP PAGE

    Category Modified

    Administering Online Shopping Cart

    Category Modified



    Click here to Logout



    function sel_click()

    {

    var f = document.modcat;

    var i=f.cat.selectedIndex;

    var str=f.cat.options[i].text;

    document.modcat.vr_cat.value=str;

    document.modcat.cat_val.value=document.modcat.elements[0].value;

    }

  • 8/4/2019 Shashi Bala

    87/89

    {

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    con = DriverManager.getConnection("jdbc:odbc:Data","scott","tiger");

    query="select * from category_details";

    stat = con.prepareStatement(query);

    rs=stat.executeQuery();

    %>


    Modify Category:--

    Category

    CREATING THE MODIFYCATEGORY.JSP PAGE

    Modify Category

    87

  • 8/4/2019 Shashi Bala

    88/89

    Administering Online Shopping Cart




  • 8/4/2019 Shashi Bala

    89/89

    {

    out.print("Error = " + e + "");

    }

    finally

    {

    con.close();}

    %>



    Click here to logout



    Click here to go to administrator page



    Click here to modify more categories


Recommended