Coffee Cram: Mock Exam Chapter 7

  1. Given this DD element:

    47. <jsp-property-group>
    48.   <url-pattern>*.jsp</url-pattern>
    49.   <el-ignored>true</el-ignored>
    50. </jsp-property-group>

    What does the element accomplish? (Choose all that apply.)

       

    A.

    All files with the specified extension mapping should be treated by the JSP container as well-formed XML files.

    B.

    All files with the specified extension mapping should have any Expression Language code evaluated by the JSP container.

    C.

    By default, all files with the specified extension mapping should NOT have any Expression Language code evaluated by the JSP container.

    D.

    Nothing, this tag is NOT understood by the container.

    E.

    Although this tag is legal, it is redundant, because the container behaves this way by default.

  2. Which directives specify an HTTP response that will be of type “image/svg”? (Choose all that apply.)

    A.

    <%@ page type="image/svg" %>

    B.

    <%@ page mimeType="image/svg" %>

    C.

    <%@ page language="image/svg" %>

    D.

    <%@ page contentType="image/svg" %>

    E.

    <%@ page pageEncoding="image/svg" %>

  3. Given this JSP:

    1.  <%@ page import="java.util.*" %>
    2.  <html><body> The people who like
    3.  <%= request.getParameter("hobby") %>
    4.  are: <br>
    5.  <% ArrayList al = (ArrayList) request.getAttribute("names"); %>
    6.  <% Iterator it = al.iterator();
    7.     while (it.hasNext()) { %>
    8.       <%= it.next() %>
    9.  <br>
    10. <% } %>
    11. </body></html>

    Which types of code are used in this JSP? (Choose all that apply.)

    A.

    EL

    B.

    directive

    C.

    expression

    D.

    template text

    E.

    scriptlet

  4. Which statements about jspInit() are true? (Choose all that apply.)

    A.

    It has access to a ServletConfig.

    B.

    It has access to a ServletContext.

    C.

    It is only called once.

    D.

    It can be overridden.

  5. Which types of objects are available to the jspInit() method? (Choose all that apply.)

    A.

    ServletConfig

    B.

    ServletContext

    C.

    JspServletConfig

    D.

    JspServletContext

    E.

    HttpServletRequest

    F.

    HttpServletResponse

  6. Given:

    <%@ page isELIgnored="true" %>

    What is the effect? (Choose all that apply.)

    A.

    Nothing, this page directive is NOT defined.

    B.

    The directive turns off the evaluation of Expression Language code by the JSP container in all of the web application’s JSPs.

    C.

    The JSP containing this directive should be treated by the JSP container as a well-formed XML file.

    D.

    The JSP containing this directive should NOT have any Expression Language code evaluated by the JSP container.

    E.

    This page directive will only turn off EL evaluation if the DD declares a <el-ignored>true</el-ignored> element with a URL pattern that includes this JSP.

  7. Which statement concerning JSPs is true? (Choose one.)

    A.

    Only jspInit() can be overridden.

    B.

    Only jspDestroy() can be overridden.

    C.

    Only _jspService() can be overridden.

    D.

    Both jspInit() and jspDestroy() can be overridden.

    E.

    jspInit(), jspDestroy(), and _jspService() can all be overridden.

  8. Which JSP lifecycle step is out of order?

    A.

    Translate the JSP into a servlet.

    B.

    Compile servlet source code.

    C.

    Call _jspService()

    D.

    Instantiate the servlet class.

    E.

    Call jspInit()

    F.

    Call jspDestroy()

  9. Which are valid JSP implicit variables? (Choose all that apply.)

    A.

    stream

    B.

    context

    C.

    exception

    D.

    listener

    E.

    application

  10. Given a request with two parameters: one named “first” represents a user’s first name and another named “last” represents his last name.

    Which JSP scriptlet code outputs these parameter values?

    A.

    <% out.println(request.getParameter("first"));
       out.println(request.getParameter("last")); %>

    B.

    <% out.println(application.getInitParameter("first"));
       out.println(application.getInitParameter("last")); %>

    C.

    <% println(request.getParameter("first"));
       println(request.getParameter("last")); %>

    D.

    <% println(application.getInitParameter("first"));
       println(application.getInitParameter("last")); %>
  11. Given:

    11. Hello ${user.name}!
    12. Your number is <c:out value="${user.phone}"/>.
    13. Your address is <jsp:getProperty name="user" property="addr" />
    14. <% if (user.isValid()) {%>You are valid!<% } %>

    Which statements are true? (Choose all that apply.)

    A.

    Lines 11 and 12 (and no others) contain examples of EL elements.

    B.

    Line 14 is an example of scriptlet code.

    C.

    None of the lines in this example contain template text.

    D.

    Lines 12 and 13 include examples of JSP standard actions.

    E.

    Line 11 demonstrates an invalid use of EL.

    F.

    All four lines in this example would be valid in a JSP page.

  12. Which JSP expression tag will print the context initialization parameter named “javax.sql.DataSource”?

    A.

    <%= application.getAttribute("javax.sql.DataSource") %>

    B.

    <%= application.getInitParameter("javax.sql.DataSource") %>

    C.

    <%= request.getParameter("javax.sql.DataSource") %>

    D.

    <%= contextParam.get("javax.sql.DataSource") %>

  13. Which statements about disabling scripting elements are true? (Choose all that apply.)

    A.

    You can’t disable scripting via the DD.

    B.

    You can only disable scripting at the application level.

    C.

    You can disable scripting programmatically by using the isScriptingEnabled page directive attribute.

    D.

    You can disable scripting via the DD by using the <scripting-invalid> element.

  14. In sequence, what are the Java types of the following JSP implicit objects: application, out, request, response, session?

    A.

    java.lang.Throwable
    java.lang.Object
    java.util.Map
    java.util.Set
    java.util.List

    B.

    javax.servlet.ServletConfig
    java.lang.Throwable
    java.lang.Object
    javax.servlet.jsp.PageContext
    java.util.Map

    C.

    javax.servlet.ServletContext
    javax.servlet.jsp.JspWriter
    javax.servlet.ServletRequest
    javax.servlet.ServletResponse
    javax.servlet.http.HttpSession

    D.

    javax.servlet.ServletContext
    java.io.PrintWriter
    javax.servlet.ServletConfig
    java.lang.Exception
    javax.servlet.RequestDispatcher
  15. Which is an example of the syntax used to import a class in a JSP?

    A.

    <% page import="java.util.Date" %>

    B.

    <%@ page import="java.util.Date" @%>

    C.

    <%@ page import="java.util.Date" %>

    D.

    <% import java.util.Date; %>

    E.

    <%@ import file="java.util.Date" %>

  16. Given the JSP:

    1. <%@ page isELIgnored="true" %>
    2. <%@ taglib uri="http://java.sun.com/jsp/jstl/core"
    prefix="c" %>
    3. <c:set var="awesomeBand" value="LIMOZEEN"/>
    4. ${awesomeBand}

    What will be the output?

    A.

    ${awesomeBand}

    B.

    LIMOZEEN

    C.

    No output

    D.

    An exception will be thrown because all taglib directives must precede any page directives.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset