1. write a calculator Servlet that adds, subtract, multiples and divides. Create
ID: 3556306 • Letter: 1
Question
1. write a calculator Servlet that adds, subtract, multiples and divides. Create the html form and call the servlet to print out the answer
i have the html code,, i need the servlet please
then after you write the servlet,,, rewrite it using JSP
two step one then two please use this html for writting the servlet
<!--<html>
<head>
<title>Calculator</title>
</head>
<body>
<h3>Calculator</h3>
<form action="GetParameters"
method ="get">
<p><label>Number 1: </label>
<input type="text" name ="Number1" size ="10" />
<label>Number 2: </label>
<input type="text" name ="Number2" size ="10" />
<label>Result: </label>
<input type="text" name ="Result" size ="10" />
</p>
<p><input type ="button" value="Add" />
<input type ="button" value ="Subract"/>
<input type ="button" value ="Multiply"/>
<input type ="button" value ="Divide"/>
</form>
</body>
</html>
Explanation / Answer
Index.jsp takes two input number and after submit the request go to Operation.java. It has a radio button to select Operation. Both inputs and radio button are submitted to Operation.java.
Operation.java(Servlet) takes value from input button and do calculation based on the radio button click. It will calculate the result.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.