Midterm2 Review 1
SELECT THE BEST CHOICE (Write the answer to the left of the question)(63%)
1.When show_times.jsp is requested by the following statement, show_times.jsp
response.sendRedirect("/schedule/times/show_times.jsp");
a. / has access to the response objectb. / has access to the request object
c. / has access to the response and request objects
d. / doesn’t have access to either the response or the request object
2.Which of the following is not a benefit of using server-side data validation?
a. / you use Javab. / you can have custom error pages
c. / you use less code
d. / the client browsers don’t have to support JavaScript
3.If the following JSP tag is coded in a main JSP, what happens when the reports.jsp page is updated?
<jsp:include page="includes/reports.jsp" />
a. / the changes aren’t updated in the subsequent requests for the main JSPb. / the changes appear for subsequent requests for the main JSP
c. / a JSP error is thrown
4.The value of an initialization parameter is usually retrieved
a. / by code in a servlet / c. / from the server.xml fileb. / by the web.xml file / d. / from the request object
5.According to the following code from a web.xml file, the error.htm page is called when
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>error.htm</location>
</error-page>
a. / an HTML page can’t be found / c. / an uncaught exception is thrownb. / any HTTP or Java error occurs / d. / an HTTP status code error occurs
6.A session object is created
a. / every time a browser makes a request for a web pageb. / every time a browser requests a servlet
c. / every time a browser requests a jsp
d. / the first time a browser requests a servlet or JSP from a web site
7.The current session object is available
a. / only to JSPs / c. / to both servlets and JSPsb. / only to servlets
8.Which of the following statements is invalid?
a. / String name = session.getAttribute("fullName");b. / Book book = (Book) session.getAttribute("bookObj");
c. / session.setAttribute("fullName", "Ted Andrews");
d. / session.removeAttribute("fullName");
9.When you use URL encoding for session tracking, you must
a. / convert all HTML pages in the application to JSPsb. / use the encodeURL method to encode all URLs in the JSPs
c. / use the encodeURL method to encode all URLs in the servlets
d. / a and b above
e. / a, b, and c above
10.The following Anchor tag demonstrates how to use
<a href="/WorkServlet?shift=<%= shiftCode %>" >
View your schedule
</a>
a. / URL rewriting / c. / hidden fieldsb. / URL encoding / d. / cookies
11.When you use hidden fields to pass parameters to a servlet or JSP, all but one of the following is true. Which one is it?
a. / the parameters aren’t shown in the URLb. / the user can see the parameters by using the browser to look at the page’s source code
c. / you don’t have to store the parameters in the session object
d. / you can’t use URL encoding
12.If you use the MVC pattern with EL,
a. / the servlets create the JavaBeans and set the bean propertiesb. / the servlets create the JavaBeans and the JSPs set the bean properties
c. / the JSPs create the JavaBeans and set the bean properties
d. / the JSPs create the JavaBeans and the servlets set the bean properties
13.A digital secure certificate is provided
a. / for a fee from a certificate authority / c. / for a fee from a registration authorityb. / free from a certificate authority / d. / free from a registration authority
14.The maximum SSL strength for an application’s connections is determined by
a. / the SSL methods that you useb. / the certification authority
c. / the registration authority
d. / the digital secure certificate
15.Once you establish a secure connection, the application
a. / returns to a non-secure connection for subsequent requestsb. / uses absolute URLs to continue using the secure connection
c. / continues to use a secure connection until an absolute URL specifies a non-secure connection
d. / continues to use a secure connection until until a relative URL specifies a non-secure connection
16.In Tomcat, a security constraint is coded in
a. / the web.xml file / c. / the context.xml fileb. / the server.xml file / d. / the application
17.Which of the following is not included in a security constraint?
a. / the URL pattern for the restricted resourcesb. / the authorized roles for accessing the restricted resources
c. / the authorized usernames for accessing the restricted resources
18.The security realm provides the authorized
a. / usernames and passwords / c. / usernames, passwords, and rolesb. / usernames and roles / d. / passwords and roles
19 .By default, Tomcat uses a security realm that stores the user data in
a. / the web.xml file / c. / a databaseb. / the server.xml file / d. / the tomcat-users.xml file
20.When an application uses basic authentication,
a. / the username and password are encrypted before being sent to the serverb. / a dialog box automatically prompts the user for a username and password
c. / the usernames and passwords are stored in the tomcat-users.xml file
d. / the web.xml file provides the path for the login page
21.When an application uses form-based authentication,
a. / the username and password are encrypted before being sent to the serverb. / a dialog box automatically prompts the user for a username and password
c. / the usernames and passwords are stored in the tomcat-users.xml file
d. / the web.xml file provides the path for the login page
FILL IN THE MISSING BLANKS(30%)
Select the best fit from the following word, or words: request, response, request parameters, WEB-INF, META-INF, tomcat, doPost, doGet, JSP, servlet, JSTL, JDBC, JavaBeans, Realm element, web.xml, ServletContext, init, attributes, cookie, URL rewriting, set, get, self-signed, context.xml, Context, auth-method,Resource element.
. 1.When you use the MVC pattern, you often add ______to the request object before you forward it to a JSP or another servlet.
2.By default, the servlet API uses a ______to store a session ID.
3.To automatically append the session ID to a URL, you can use the encodeURL method of the ______object.
4.Cookies are retrieved from the ______object.
5.Instead of storing data that’s used for a single request in the session object, you can use hidden fields or ______.
6.One of the advantages that EL has over standard JSP tags is that you can not only use EL with ______but also with maps, arrays, and lists.
7.One of the disadvantages of using EL is that it doesn’t provide a way to ______properties.
8.You use the ______element in the ______file to specify the type (i.e. form-based type) of authentication that’s going to be used by the application.
9.When you use the DataSourceRealm,, you use the realm element of ______file to specify both the database and the tables for the users and roles.