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

tag have the value “/converter/servlet/Converter”, pointing out the servlet you are implementing. Let the “method” attribute have the value “post”.


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

1 Expert Approved Answer
Step: 1 Unlock

There is an incomplete part in the question The question cuts off unexpectedly when describing the doGet method and its instructions related to the HT... View full answer

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 General Management Questions!