Question
Your assignment is to implement a simple web service that lets users convert an amount from one currency to another, for example from USD to
Your assignment is to implement a simple web service that lets users convert an amount from one currency to another, for example from USD to EUR. The interface should consist of two text fields, “Amount” and “Rate,” and a submit button, “Convert!” If you want to convert an amount from one currency to another, we input the amount in the “Amount” text field and presses the “Convert!” button. The service should reply with a new web page that displays the result of the conversion. The service should remember which exchange rate is being used for conversion, initially 1.0. If the user wants to change the exchange rate he inputs a new rate in the “Rate” text field and the amount to be converted in the “Amount” field. The new rate should be remembered for future conversion when the “Rate” field is left empty.
Write your servlet in a file named Converter.java.
You should implement one doGet method and one doPost method.
In the doGet method, write code that produces an HTML page. Let the “action” attribute of the
In the doPost method, write code that retrieves the values entered into the text fields of the HTML form. Process the information accordingly and produce a suitable HTML page as a reply.
Use an attribute in the Converter class to store the current exchange rate.
Compile your servlet.
Test your servlet on your web browser. Remember to start the Tomcat server first!
Step by Step Solution
3.31 Rating (163 Votes )
There are 3 Steps involved in it
Step: 1
Converterhtml Currency Converter Amount Rate Converterjava impo...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