1. Choose the statement that best describes the relationship between JSP and servlets: |
Servlets are built on JSP semantics and all servlets are compiled to JSP pages for runtime usage. |
JSP and servlets are unrelated technologies. |
Servlets and JSP are competing technologies for handling web requests. Servlets are being superseded by JSP, which is preferred. The two technologies are not useful in combination. |
JSPs are built on servlet semantics and all JSPs are compiled to servlets for runtime usage.
|
2. What is a benefit of using JavaBeans to separate business logic from presentation markup within the JSP environment ? |
It allows the JSP to access middleware. |
It provides a dynamic markup environment, such that JavaBeans are integrated seamlessly with the template presentation content, in order to create the dynamic display for the client. |
It provides the developer with full access to the Java 2 Platform Enterprise Edition (J2EE), which is unavailable from outside the JavaBean environment. |
None of these
|
3. Why use RequestDispatcher to forward a request to another resource, instead of using a sendRedirect ? |
Redirects are no longer supported in the current servlet API. |
Redirects are not a cross-platform portable mechanism. |
The RequestDispatcher does not use the reflection API. |
The RequestDispatcher does not require a round trip to the client, and thus is more efficient and allows the server to maintain request state.
|
4. What alternatives exist to embedding Java code directly within the HTML markup of your JSP page ? |
Moving the code into your session manager. |
Moving the code into scriptlets. |
Moving the code into JavaBeans and servlets. |
Moving the code into a transaction manager.
|
5. What type of scriptlet code is better-suited to being factored forward into a servlet ? |
Code that deals with logic that is common across requests. |
Code that deals with logic that is vendor specific. |
Code that deals with logic that relates to database access. |
Code that deals with logic that relates to client scope.
|
6. Choose the statement that best describes how to connect JSP pages and Enterprise JavaBeans (EJBs): |
Lookup the EJBs from within a JSP, but use the EJBs from within a basic JavaBean. |
Lookup and use the EJBs from a separate business delegate. The JavaBeans that work with JSP pages are clients to these business delegates and know nothing about EJB specifics. |
Lookup the EJBs from within a servlet, delegating usage to specific JSP pages. |
Lookup and use the EJBs from within a JSP page, but only as remote references.
|
7. Are custom tags available in JSP 1.0? If not, how else might you implement iteration from within a JSP ? |
Yes, but the only tags available relate to database access. |
Yes, but custom tags will not help developers create tags for use in iterating over a collection. |
No. To iterate over a collection of values, one must use scriptlet code. |
No, but there is a standard tag that may be used.
|
8. What is the initial contact point for handling a web request in a Page-Centric architecture ? |
A JSP page. |
A JavaBean. |
A servlet. |
A session manager.
|
9. What is the difference between doing an include or a forward with a RequestDispatcher ? |
The two methods provide the same functionality, but with different levels of persistence. |
The forward method is deprecated as of JSP 1.1 and the include method should be used in order to substitute portions of a dynamic display at runtime. |
The include method transfers control to a dynamic resource, while the forward method allows for dynamic substitution of another JPS pages output, returning control to the calling resource. |
The forward method transfers control to the designated resource, while the include method invokes the designated resource, substitutes its output dynamically in the display, and returns control to the calling page.
|
10. Which of the following can the JSP include action include output from ? |
Another JSP |
Servlet |
Plain text file |
All of the above
|
11. The <jsp:include/< action can pass parameters to the page which it is including. How does this second page obtain the |
value of these parameters ? |
Using the <jsp:readParam/> action |
Using the <jsp:getParam/> action |
Use the request.getParameter() method
|
12. What is wrong with the following code ? <% if(strPassword.equals("boss")) { <jsp:forward page="Welcome.jsp" flush="true"/> } else { } %>
|
Unmatched bracket in for statement |
Flush attribute must be false |
Keyword 'file' should be used instead of 'page' in the <jsp:forward/> action |
Actions cannot be used within scriptlet blocks
|
13. What is wrong with the following code ? <jsp:include page="MainMenu.jsp" flush="true"/> <% Cookie c = new Cookie("UserName", "Alastair Gulland"); response.addCookie(c); %>
|
Cookie class can not take parameters in it's constructor |
The request object is used for creating cookies |
Although no error will be reported the use of the <jsp:include/> action means that the response object can't be used to create cookies. |
The <jsp:include/> action must be placed inside the script block
|
14. When a JSP page is compiled, what is it turned into ? |
Applet |
Servlet |
Application |
Mailet
|
15. Which of the following is not a standard method called as part of the JSP life cycle ? |
jspInit() |
jspService() |
_jspService() |
jspDestroy()
|
16. If you want to override a JSP file's initialization method, within what type of tags must you declare the method ? |
<@ @> |
<%@ %> |
<% %> |
<%! %>
|
17. Which of the following can not be used as the scope when using a JavaBean with JSP ? |
application |
response |
request |
session
|
18. What is the key difference between using a <jsp:forward> and HttpServletResponse.sendRedirect()? |
forward executes on the server while sendRedirect() executes on the client. |
forward executes on the client while sendRedirect() executes on the server. |
The two methods perform identically. |
None of these
|
19. How can a servlet call a JSP error page? |
This capability is not supported. |
When the servlet throws the exception, it will automatically be caught by the calling JSP page. |
The servlet needs to forward the request to the specific error page URL. The exception is passed along as an attribute named "javax.servlet.jsp.jspException". |
The servlet needs to redirect the response to the specific error page, saving the exception off in a cookie.
|
20. What is JSP ? |
Java Server Pages |
Java Special Pages |
Java Static Pages |
Java Showing Pages
|