You are to create an online ordering and stock control system for a mail order company. The system is to be operated by an employee of the company and is to be implemented in using a Web interface.
Each implementation is to provide the functionality listed below.
(i) Retrieval of an individual stock item's current level.
(ii) Calculation of the cost of a customer's order for one or more of a particular stock item.
(iii) Addition of a new item of stock.
(iv) Display of the full stock list.
The functionality for item (ii) above is to be provided by a JavaBean called *OrderCost*, whilst that for the other three items is to be provided by a second JavaBean called *StockAccess*.
This assignment will require the creation of 10 source files:
· 2 Java files (which are JavaBeans);
· 5 JSP files;
· 1 HTML file;
· 1 MS Access database (holding one small table).
**2. *OrderCost* JavaBean**
Initially, this piece of software should be created as an ordinary (non-GUI) application. The steps required to convert this into a JavaBean are very simple and can wait until JavaBeans have been covered in lectures.
The program should have variables to hold an item's stock code and its order quantity and should provide mutator ('set') methods that assign values to the stock code and associated quantity respectively for a particular order. (For simplicity's sake, each order is to involve only one stock code.) By employing JDBC to retrieve the price of the item from the *Stock* table, the program should also provide an accessor ('get') method to return the cost of the order. If an item is not found, then zero should be returned.
For initial testing purposes, it will be convenient to include a 'rough and ready' *main* method that accepts a stock code and quantity from the user and displays the cost that is returned by the accessor method (to **two decimal places**). However, *main* should be deleted when the program is converted into a JavaBean.
**3. *StockAccess* JavaBean**
As with the first bean, this should initially be created as an ordinary (non-GUI) application.
This program will use JDBC to provide the stock control functionality for the later application (in both the GUI implementation and the Web-based implementation). The features to be provided are listed below.
· Return the current stock level for an item with a specified stock code (or -1 for an invalid code).
· Insert a new item of stock (all 5 fields).
This functionality will be achieved via the appropriate accessor and mutator methods.
As with the first bean, it will be convenient for testing purposes to include a basic *main* method that allows the user to select the required SQL statement and to supply the appropriate field value(s). Once again. this method should be removed when the program is converted into a JavaBean.
These two beans will also be attached, but all everything is not working. Could you please correct them.
**4. Create the HTML page and the JSPs**
First create a Tomcat Web application to contain the Web pages you are going to create and the JavaBeans that you have already created. Add to this Web application an HTML page that allows the user to select, via radio buttons, and all the followings, should display the cost of any order (for specified stock code and quantity) that the user enters, by making use of the *OrderCost* bean. It should also allow the user to select either of the database operations specified in step 3 and have the *StockAccess* bean execute the appropriate method(s), displaying the result returned by the query and a message indicating success (or failure) for the insertion. If an invalid stock code is supplied for order entry or for (attempted) retrieval of the current stock level, then an appropriate error message is to be displayed.
Then add a JSP that receives the user's selection and either displays the full stock list (for the option added in step 5) or accepts a stock code from the user and then redirects execution to one of three further JSPs (that will also have to be created). Each of these three JSPs will provide the functionality required by one of the three remaining options. Two of the JSPs will make use of the *StockAccess* bean, of course, while the other one (to display the cost of an order) will make use of the *OrderCost* bean.
At the bottom of each JSP, provide a button that allows the user to return to the initial HTML page to make another selection. You should also include a JSP error page that simply displays the exception generated (for any of the options selected) and allows the user to retry the operation.
**5. Extend the *StockAccess* bean and the GUI**
Add to the *StockAccess* bean appropriate methods to allow the retrieval of the full stock list (all fields). After re-testing the bean (by temporarily re-inserting a basic *main* method), add an option to the GUI that displays the full stock list returned by the bean.
**Please make all the codes easy to understand. With quotes, so I know what’s happening through out the codes.**