O'Reilly logo

Head First Servlets and JSP, 2nd Edition by Bert Bates, Bryan Basham, Kathy Sierra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Coffee Cram: Mock Exam Chapter 6

  1. Given:

    10. public class MyServlet extends HttpServlet {
    11.   public void doGet(HttpServletRequest request,
                              HttpServletResponse response)
    12.           throws IOException, ServletException {
    13.   // request.getSession().setAttribute("key", "value");
    14.   // request.getHttpSession().setAttribute("key", "value");
    15.   // ((HttpSession)request.getSession()).setAttribute("key", "value");
    16.   // ((HttpSession)request.getHttpSession()).setAttribute("key", "value");
    17.   }
    18. }

    Which line(s) could be uncommented without causing a compile or runtime error? (Choose all that apply.)

    A.

    Line 13 only.

    B.

    Line 14 only.

    C.

    Line 15 only.

    D.

    Line 16 only.

    E.

    Line 13 or line 15.

    F.

    Line 14 or line 16.

  2. If a client will NOT accept a cookie, which session management mechanism could the web container employ? (Choose one.)

    A.

    Cookies, but NOT URL rewriting.

    B.

    URL rewriting, but NOT cookies.

    C.

    Either cookies or URL ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required