Question: Write a web application to function as a simple hand calculator that also keeps a paper trail of all your previous work. Details: Your program

Write a web application to function as a simple hand calculator that also keeps a paper trail of all your previous work.

Details:

Your program should consist of the following components:

An HTML page

This page is dynamically generated by JSP. It contains a trail of all the work you have done previously, for example something like this:

0.0 + 2.5 = 2.5 + 5.0 = 7.5 * 3.55 = 26.625 / -3.0 = -8.875 etc.

In addition, it should have the following HTML form elements: a text field in which you can enter numbers; add, subtract, multiply, and divide buttons; a clear button, to reset the current value to zero; and a clear all button, to reset the current value to zero and erase the paper trail (for when your page is getting too long and you want to start over).

Since the user should enter only numbers into the text field, use JavaScript to validate the numbers before you submit the form. (Hint: Google on JavaScript validate input field.)

A servlet

The servlet should handle getting the request, calling some other class to do the work, and forwarding the result to JSP for formatting.

Along the way, the servlet should do session tracking, that is, it needs to keep track of the paper trail and the current value. I strongly recommend using the servlet tracking API, javax.servlet.http.HttpSession, as being the simplest and easiest way to do this.

A class to do the computations

Are you familiar with Model-View-Controller? The servlet itself is acting as the controller, that is, it shouldnt have to do any computations (it delegates that work to some model class) or display any results (it delegates that work to the JSP).

A JSP page

The JSP page should create the HTML page from the information computed by the model class and forwarded to it by the servlet. Remember, Tomcat translates your JSP into ordinary Java.

A deployment descriptor

This is going to be required for the functionality to actually work.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!