JSP

There is webpage with a form including two text fields: x and y. You have to add dynamic behaviour using JSP technology, the task is to show the sum of the two numbers.

The program skeleton is done, please choose the correct answers! In some cases there are more working choises, mark all that apply!

<%
// 1
// 2
// 3
if (/* 4 */) {
// 5
// 6
// 7
} else {
%>
<form action=”?action=add” method=”post”>
<input type=”text” name=”x” />
<input type=”text” name=”y” />
<input type=”submit” value=”do” />
</form>
<% } %>

1.
a. var action, x, y;
b. Object action, x, y;
c. string action, x, y;
d. String action, x, y;

2.
a. var sum;
b. Object sum;
c. int sum;
d. integer sum;
e. Int sum;
f. Integer sum;

3.
a. action = request.action;
b. action = request[“action”];
c. action = request.getParameter(“action”);
d. action = request.postParameter(“action”);

4.
a. action = “add”
b. action == “add”
c. action.equals(“add”)
d. “add”.equals(action)

5.
a. x = request.x; y = request.y;
b. x = request[“x”]; y = request[“y”];
c. x = request.getParameter(“x”); y = request.getParameter(“y”);
d. x = request.postParameter(“x”); y = request.postParameter(“y”);

6.
a. sum = x+y;
b. sum = 1*x + 1*y;
c. sum = Int.parseInt(x+””) + Int.parseInt(y+””);
d. sum = Int.parseInteger(x+””) + Int.parseInteger(y+””);
e. sum = Integer.parseInt(x+””) + Integer.parseInt(y+””);
f. sum = Integer.parseInteger(x+””) + Integer.parseInteger(y+””);

7.
a. <%= sum %>
b. %><%= sum %><%
c. document.write(sum);
d. out.print(sum);