Question
Java In this project, you will practice some basic features of the servlet technology. Since this is the first project of this semester, we use
Java
In this project, you will practice some basic features of the servlet 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:
a)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.
b)In the servlet, you can use Java's BigInteger class to do operations for big integers. The output should be in the standard form of prime factorization (i.e. product of powers of distinct primes in the ascending order of the primes).
c)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.
d)Clock the execution time as the basis for price calculation. The more execution time for the factorization, the higher the price of the product. Specifically, you charge $1 for time 0 to 1 second, $2 for 1 to 2 second, etc., until you reach $10 for the highest price.
e) Put a time limit 10 seconds on each computing task. If after 10 seconds the factorization has not been completed, stop the execution and tell the user that the current technology cannot handle this job.
6-(Display Result) After you complete the factorization before the 10 second limit, 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started