1.When using a RequestDispatcher, the use of which methods can Often lead to an
IllegalStateException ? (Choose all that apply.)
A. Read
B. flush
C. getOutputStream
D. Write
E. GetResourceAsStream
2. Which statements about ServletContext initialization parameters are true ?
A. They should be used for data that changes rarely.
B. They should be used for data that Changes Frequently.
C. They can be accessed using
ServletContext.GetParameter(String)
D. They can be accessed using
ServletContext.GetInitParameter(String)
E. They should be used for data that is specific to a particular servlet.
F. They should be used for data that is applicable
to an entire web application.
3. Which types define the methods getAttributee() and setAttribute() ?
A. HttpSession
B. ServletRequest
C. ServletResponse
D. ServletContext
E. Servletconfig
F. SessionConfig
4. If a servlet is invoked using the forward or include method of RequestDispatcher,
which methods of the servlet's request object can access the reques attributes set
by the container ? (Choose all that apply)
5. Which calls provide information about initialization parameters that are applicable to
an entire web application ?
A. ServletConfig.getInitParameters()
B. ServletContext.GetInitParameters()
C. ServletConfig.getInitParameterNames()
D. Servletcontext.GetInitParameterNames()
E. Servletconfiug.getInitParameter(String)
F. Servletcontext.getInitParameter(String)
6. which statements about Listeners are true ?
A. A ServletResponseListener can be used to perform an action When a servlet
response has been sent
B. An HttpSessionListener can be used to perform an action when an HttpSession
has timed out.
C. A servletContextListener can be used to perform an action
When the servlet context is about to be shut down.
D. A ServletRequestAttributeListener can be used to Perform an action when an
attribute has been removed from a ServletRequest.
E. A ServletContextAttributeListener can be used to perform
an action when the servlet context has just been created and is available
to service its first request.
7. Which is most logically stored as an attribute in session scope ?
A. A copy of a query parameter entered by a user.
B. The result of a database query to be returned
immediately to a user.
C. A database connection object used by all web components of the system.
D. An object representing a user who has just logged into the system.
E. A copy of an initialization parameter retrieved from a ServletContext object.
8. Given this code from an otherwise valid HttpServlet that has also been registered as
a ServletRequestAttributteListener.
What logging output is generated ?
A. A:a -> b P:a->b
B. A:a -> b M:a->b
C. A:a -> b P:a->b M:a->c
D. A:a -> b P:a->b P:a -> Null
E. A:a -> b M:a->b A:a -> b M:a->b
F. A:a -> b M:a->b A:a -> c P:a->Null
9. when declaring a listener in the DD, which sub-elements of the <listener>
element are required ?
A. <description>
B. <listener - name>
C. <listener - type>
D. <listener - class>
E. <servlet-mapping>
10. Which types of objects can store attributes ?
A. ServletConfig
B. ServletResponse
C. RequestDispatcher
D. HttpServletRequest
E. HttpSessionContext
11. Which are true ?
A. When a web application is preparing to shutdown, the order of listener
notification is not guaranteed.
B. When listener-friendly events occur, listener invocation order is not predictable
C. The container registers listeners based on declarations in the
deployment descriptor.
D. Only the container can invalidate a session.
12. Which statements about RequestDispatcher are true
(where applicable, assume the RequestDispatcher was not obtained via a call to
getNamedDispatcher())? (Choose all that apply.)
A. A RequestDispatcher can be used to forward a request to another servlet.
B. The only method in the RequestDispatcher interface is forward().
C. Parameters specified in the query string used to create a RequestDispatcher
are not forwarded by the forward() method.
D.The servlet to which a request is forwarded may access the original query
string by calling getQueryString() on the HttpServletRequest.
E. The servlet to which a request is forwarded may access the original query
string by calling getAttribute(“javax.servlet.forward.query_string”) on the
ServletRequest.
13. What is the recommended way to deal with servlets and thread safety?
A. Write the servlet code to extend ThreadSafeServlet.
B. Have the servlet implement SingleThreadModel.
C. Log all servlet method calls.
D. Use local variables exclusively, and if you have to use instance
vables,synchronize access to them.
14. Given the following methods:
- getCookies
- getContextPath
- getAttribute
Match the methods above to the following classes or interfaces. Note that each
method can be used more than once.
HttpSession _____________ ___________ __________
ServletContext _____________ ___________ __________
HttpServletRequest _____________ ___________ __________
15. Which are true about the RequestDispatcher interface? (Choose all that apply.)
A. Of its two methods, forward() is used most frequently.
B. Its methods take the following arguments: a resource, a request, and a
response.
C. Depending on the class whose method creates a RequestDispatcher, the path
to the resource to be forwarded to will change.
D. Regardless of the class whose method creates a RequestDispatcher, the path to
the resource to be forwarded to will NOT change.
E. If your servlet invokes RequestDispatcher.forward, it can send its own response
to the client before, but not after the invocation of forward. |