Project 1. Provide a Computing Service Solution

$35.00 $29.00

In this project, you will practice some basic features of the servlet technology and the JSP technology. Since this is the first project of this semester, we use a simple structure for this web application. The structure of the web application is as follows: A JSP page is used for the user’s interface (two versions:…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

In this project, you will practice some basic features of the servlet technology and the JSP technology. Since this is the first project of this semester, we use a simple structure for this web application. The structure of the web application is as follows:

  • A JSP page is used for the user’s interface (two versions: Windows and Mac).

  • A servlet is used to provide the core computing service.

  • Another JSP page is used to display the computation result.

  • A preparation servlet may be needed to retrieve some initial data from the web.xml, so that the first JSP page can display it as a UI component.

The web application is used to run a business to sell a product in several cities. So the city information including the tax rates will be used to calculate the final prices of the product. The city information can be configured in an XML file, so that a non-Java programmer can change it easily.

Requirements

  1. When the web application starts, the welcome file redirects the request to a servlet to prepare for the initial data.

  2. In the preparation servlet, you retrieve the user’s operating system information from the request headers. Based on that information, you redirect the request to either Windows’ version or Mac version of the input page.

  3. You also need to retrieve the initial parameters from the web.xml for the city data and the tax rate data, so as to calculate the product price later. The city data is stored in a string array, and put in the request scope.

  4. The user’s input page will display the city options as a dropdown list, so that the user can select the suitable city for the product.

  5. (Product Simulation) In order to practice data processing in a servlet, we use a computation task which has its own value to simulate the product. The computation task is to factorize a big integer as the product of its prime factors with the following details:

    • The user can enter a big integer in the input page to request the decomposition service. After the user clicks the submit button, it is sent to our data processing servlet for decomposition.

    • You need to validate your data. If the string is not formed by digits, an error message is displayed on the page. Only when the data is valid, you do the following data processing.

    • In the servlet, you can use Java’s BigInteger class to do operations for big integers. (An example for calculating Java BigIntegers is included with this project.) The output is one of the two cases:

      1. If the input number is a prime, just output a message showing that it is a prime;

      2. If the input number is not a prime and it is an odd integer, write it as a product of two smaller odd integers;

      3. If the input number is not a prime and it is an even integer, first extract the largest power of 2, then for the remaining odd number, try to factorize it if you can. For your output, you give the power of 2 as one number and one more factor if this factor is a prime, or two more factors if you can still factorize the odd number after extracting the power of 2.

    • If you can find any efficient prime factorization algorithm, you can use it. The performance of your algorithm will not be used as a factor in grading.

    • Now we need to simulate the service cost. We simply take the last two digits of the largest factor in your factorization as the service cost, and the service charge (before adding the tax) is just that two-digit number of dollars.

  6. (Display Result) You forward the page to another JSP to display the factorization result with the decomposition stored in the request scope.

  7. (Display Invoice) Below the computation result, you also display the invoice of this computing task by adding the state tax on top of the service charge. (Note here we use the service to simulate the product.)

  8. Put a Home link on the result page for the user to go back to the input page to purchase another product.

Project 1. Provide a Computing Service Solution
$35.00 $29.00