Consider the following HTML page code:
<html>
<body>
<form name="data" action="/servlet/DataServlet" method="POST">
<input type="text" name="name">
<input type="submit" name="submit">
</form>
</body>
</html>
Identify the two methods that can be used to retrieve the value of the name parameter when the form is submitted.
a getParameter("name");
b getParameterValue("name");
c getParameterValues("name");
d getParameters("name");
e getValue("name");
f getName();
Answers: a and c
Your web application, named simpletax, depends on a third-party JAR file named taxpackage.jar. Where would you keep this file? (Select one)
a simpletax
b simpletax/WEB-INF
c simpletax/WEB-INF/classes
d simpletax/WEB-INF/lib
e simpletax/WEB-INF/jars
f simpletax/WEB-INF/thirdparty
Answer: d
Which deployment descriptor element is used to specify a ServletContext- Listener? (Select one)
a <context-listener>
b <listener>
c <servlet-context-listener>
d <servletcontextlistener>
e <servletcontext-listener>
Answer: b
Which of the following method calls will ensure that a session will never be expunged by the servlet container? (Select one)
a session.setTimeout(0);
b session.setTimeout(-1);
c session.setTimeout(Integer.MAX_VALUE);
d session.setTimeout(Integer.MIN_VALUE);
e None of these.
Answer: e
Which of the following deployment descriptor elements is used for specifying the authentication mechanism for a web application? (Select one)
a security-constraint
b auth-constraint
c login-config
d web-resource-collection
Answer: c
Which of the following correctly declares that the current page is an error page and also enables it to take part in a session? (Select one)
a <%@ page pageType="errorPage" session="required" %>
b <%@ page isErrorPage="true" session="mandatory" %>
c <%@ page errorPage="true" session="true" %>
d <%@ page isErrorPage="true" session="true" %>
e None of the above.
Answer: d