单选题Which retrieves all cookies sent in a given HttpSErvletRequest request?()Arequest.getCookies()Brequest.getAttributes()Crequest.getSession ().getCookies()Drequest.getSession (). GetAttributes()

题目
单选题
Which retrieves all cookies sent in a given HttpSErvletRequest request?()
A

 request.getCookies()

B

 request.getAttributes()

C

 request.getSession ().getCookies()

D

 request.getSession (). GetAttributes()


相似考题
更多“单选题Which retrieves all cookies sent in a given HttpSErvletRequest request?()A  request.getCookies()B  request.getAttributes()C  request.getSession ().getCookies()D  request.getSession (). GetAttributes()”相关问题
  • 第1题:

    YouarebuildingaFrontControllerusingaJSPpageandyouneedtodetermineiftheuser’ssessionhasNOTbeencreatedyetandperformsomespecialprocessingforthiscase.Whichscriptletcodesnippetwillperformthistest?()

    A.<%if(request.getSession(false)==null){//specialprocessing}%>

    B.<%if(request.getHttpSession(false)==null){//specialprocessing}%>

    C.<%if(requestObject.getSession(false)==null){//specialprocessing}%>

    D.<%if(requestObject.getHttpSession(false)==null){//specialprocessing}%>


    参考答案:A

  • 第2题:

    Fordebuggingpurposes,youneedtorecordhowmanytimesagivenJSPisinvokedbeforetheuser’ssessionhasbeencreated.TheJSP’sdestroymethodstoresthisinformationtoadatabase.WhichJSPcodesnippetkeepstrackofthiscountforthelifetimeoftheJSPpage?()

    A.<%!intcount=0;%><%if(request.getSession(false)==null)count++;%>

    B.<%@intcount=0;%>.<%if(request.getSession(false)==null)count++;%>

    C.<%intcount=0;.if(request.getSession(false)==null)count++;%>

    D.<%@intcount=0;.if(request.getSession(false)==null)count++;%>

    E.<%!intcount=0;.if(request.getSession(false)==null)count++;%>


    参考答案:A

  • 第3题:

    Given the definition of MyServlet: 11.public class MyServlet extends HttpServlet { 12.public void service(HttpServletRequest request, 13.HttpServletResponse response) 14.throws ServletException, IOException { 15.HttpSession session = request.getSession(); 16.session.setAttribute("myAttribute","myAttributeValue"); 17.session.invalidate(); 18.response.getWriter().println("value=" + 19.session.getAttribute("myAttribute")); 20.} 21.} What is the result when a request is sent to MyServlet?()

    • A、An IllegalStateException is thrown at runtime.
    • B、An InvalidSessionException is thrown at runtime.
    • C、The string "value=null" appears in the response stream.
    • D、The string "value=myAttributeValue" appears in the response stream.

    正确答案:A

  • 第4题:

    Given an HttpServletRequest request: 22.String id = request.getParameter("jsessionid"); 23.// insert code here 24.String name = (String) session.getAttribute("name"); Which three can be placed at line 23 to retrieve anexisting HttpSession object?()

    • A、HttpSession session = request.getSession();
    • B、HttpSession session = request.getSession(id);
    • C、HttpSession session = request.getSession(true);
    • D、HttpSession session = request.getSession(false);
    • E、HttpSession session = request.getSession("jsessionid");

    正确答案:A,C,D

  • 第5题:

    Given a header in an HTTP request:X-Retries:4 Which two retrieve the value of the header from a given HttpServletRequest request?()

    • A、Request.getHeader("X-Retries")
    • B、Request.getIntHeader("X-Retries")
    • C、Request.getRequestHeader("X-Retries")
    • D、Request.getHeaders("X-Retries").get(0)
    • E、Request.getRequestHeaders("X-Retries").get(0)

    正确答案:A,B

  • 第6题:

    下面哪句代码能获得硬盘上所有的Cookie?()

    • A、Cookie cookie[]=request.getCookies()
    • B、Cookie cookie[]=request.addCookies()
    • C、response.addCookie(cookie)
    • D、Cookie c=new cookie(“name”,“value”)
    • E、以上选项都不能

    正确答案:A

  • 第7题:

    Given an HttpServletRequest request, which retrieves an object of type Account with an Id of “account”?()

    • A、 Account account = request.get Resource(”account”):
    • B、 Account account = request.get Attribute (“account”):
    • C、 Account account = request.get Parameter (account”):
    • D、 Account account = (Account)request.getResource (“account”):
    • E、 Account account = (Account) request.get Attribute (“account”):
    • F、 Account account = (Account) request.get Paramter (“account”):

    正确答案:E

  • 第8题:

    Which retrieves all cookies sent in a given HttpSErvletRequest request?()

    • A、 request.getCookies()
    • B、 request.getAttributes()
    • C、 request.getSession ().getCookies()
    • D、 request.getSession (). GetAttributes()

    正确答案:A

  • 第9题:

    单选题
    Given the definition of MyServlet: 11.public class MyServlet extends HttpServlet { 12.public void service(HttpServletRequest request, 13.HttpServletResponse response) 14.throws ServletException, IOException { 15.HttpSession session = request.getSession(); 16.session.setAttribute("myAttribute","myAttributeValue"); 17.session.invalidate(); 18.response.getWriter().println("value=" + 19.session.getAttribute("myAttribute")); 20.} 21.} What is the result when a request is sent to MyServlet?()
    A

    An IllegalStateException is thrown at runtime.

    B

    An InvalidSessionException is thrown at runtime.

    C

    The string value=null appears in the response stream.

    D

    The string value=myAttributeValue appears in the response stream.


    正确答案: C
    解析: 暂无解析

  • 第10题:

    多选题
    Given an HttpServletRequest request: 22.String id = request.getParameter("jsessionid"); 23.// insert code here 24.String name = (String) session.getAttribute("name"); Which three can be placed at line 23 to retrieve anexisting HttpSession object?()
    A

    HttpSession session = request.getSession();

    B

    HttpSession session = request.getSession(id);

    C

    HttpSession session = request.getSession(true);

    D

    HttpSession session = request.getSession(false);

    E

    HttpSession session = request.getSession(jsessionid);


    正确答案: A,D
    解析: 暂无解析

  • 第11题:

    单选题
    HttpSession session=request.getSession(false)与HttpSession session = request.getSession(true)的区别()。
    A

    没有区别

    B

    如果当前reqeust中的HttpSession 为null,当传入参数为空时,就创建一个新的Session,否则返回null

    C

    如果当前reqeust中的HttpSession 为null,当传入参数为true时,就创建一个新的Session,否则返回null


    正确答案: A
    解析: 这里的参数如果为空,则默认false。这里的true和false代表未获取到Session时是否创建为true时,当request.getSession未获取到Session就创建一个新的Session,并放入request域中

  • 第12题:

    单选题
    For debugging purposes, you need to record how many times a given JSP is invoked before the user’ssession has been created. The JSP’s destroy method stores this information to a database. Which JSPcode snippet keeps track of this count for the lifetime of the JSP page?()
    A

    <%! int count = 0; %><% if ( request.getSession(false) == null ) count++; %>

    B

    <%@ int count = 0; %>. <% if ( request.getSession(false) == null ) count++; %>

    C

    <% int count = 0;. if ( request.getSession(false) == null ) count++; %>

    D

    <%@ int count = 0;. if ( request.getSession(false) == null ) count++; %>

    E

    <%! int count = 0;. if ( request.getSession(false) == null ) count++; %>


    正确答案: B
    解析: 暂无解析

  • 第13题:

    WhichretrievesallcookiessentinagivenHttpSErvletRequestrequest?()

    A.request.getCookies()

    B.request.getAttributes()

    C.request.getSession().getCookies()

    D.request.getSession().GetAttributes()


    参考答案:A

  • 第14题:

    Given an HttpServletRequest request and an HttpServletResponse response: 41.HttpSession session = null; 42.// insert code here 43.if(session == null) { 44.// do something if session does not exist 45.} else { 46.// do something if session exists47. } To implement the design intent,which statement must be inserted at line 42?()

    • A、session = response.getSession();
    • B、session = request.getSession();
    • C、session = request.getSession(true);
    • D、session = request.getSession(false);
    • E、session = request.getSession("jsessionid");

    正确答案:D

  • 第15题:

    For debugging purposes, you need to record how many times a given JSP is invoked before the user’ssession has been created. The JSP’s destroy method stores this information to a database. Which JSPcode snippet keeps track of this count for the lifetime of the JSP page?()

    • A、<%! int count = 0; %><% if ( request.getSession(false) == null ) count++; %>
    • B、<%@ int count = 0; %>. <% if ( request.getSession(false) == null ) count++; %>
    • C、<% int count = 0;. if ( request.getSession(false) == null ) count++; %>
    • D、<%@ int count = 0;. if ( request.getSession(false) == null ) count++; %>
    • E、<%! int count = 0;. if ( request.getSession(false) == null ) count++; %>

    正确答案:A

  • 第16题:

    写入和读取cookie的方法是()

    • A、request.addCookies()和response.getCookies()
    • B、response.addcookie()和request.getCookies()
    • C、request.addCookies()和request.getCookies()
    • D、response.addcookie()和response.getCookies()

    正确答案:B

  • 第17题:

    如何获取一个Cookie[]?()

    • A、request.getCookies()
    • B、request.getCookie()
    • C、response.getCookies()
    • D、response.getCookie()

    正确答案:A

  • 第18题:

    下列哪种方式可以在session中保存一个名为"name",值为"newer"的属性()

    • A、request.getSession().setAttribute(“name”,"newer")
    • B、request.getSession().getAttribute(“ID”,id);
    • C、request.getSession().setParameter(“ID”,id);
    • D、request.getSession().getParameter(“ID”,id)

    正确答案:A

  • 第19题:

    Given: 10.public void service(ServletRequest request, 11.ServletResponse response) { 12.ServletInputStream sis = 13.// insert code here 14.} Which retrieves the binary input stream on line 13?()

    • A、request.getWriter();
    • B、request.getReader();
    • C、request.getInputStream();
    • D、request.getResourceAsStream();

    正确答案:C

  • 第20题:

    单选题
    Given an HttpServletRequest request, which retrieves an object of type Account with an Id of “account”?()
    A

     Account account = request.get Resource(”account”):

    B

     Account account = request.get Attribute (“account”):

    C

     Account account = request.get Parameter (account”):

    D

     Account account = (Account)request.getResource (“account”):

    E

     Account account = (Account) request.get Attribute (“account”):

    F

     Account account = (Account) request.get Paramter (“account”):


    正确答案: C
    解析: 暂无解析

  • 第21题:

    单选题
    Given an HttpServletRequest request and an HttpServletResponse response: 41.HttpSession session = null; 42.// insert code here 43.if(session == null) { 44.// do something if session does not exist 45.} else { 46.// do something if session exists47. } To implement the design intent,which statement must be inserted at line 42?()
    A

    session = response.getSession();

    B

    session = request.getSession();

    C

    session = request.getSession(true);

    D

    session = request.getSession(false);

    E

    session = request.getSession(jsessionid);


    正确答案: A
    解析: 暂无解析

  • 第22题:

    单选题
    Which retrieves all cookies sent in a given HttpSErvletRequest request?()
    A

     request.getCookies()

    B

     request.getAttributes()

    C

     request.getSession ().getCookies()

    D

     request.getSession (). GetAttributes()


    正确答案: C
    解析: 暂无解析

  • 第23题:

    单选题
    写入和读取cookie的方法是()
    A

    request.addCookies()和response.getCookies()

    B

    response.addcookie()和request.getCookies()

    C

    request.addCookies()和request.getCookies()

    D

    response.addcookie()和response.getCookies()


    正确答案: C
    解析: 暂无解析

  • 第24题:

    单选题
    下面哪句代码能获得硬盘上所有的Cookie?()
    A

    Cookie cookie[]=request.getCookies()

    B

    Cookie cookie[]=request.addCookies()

    C

    response.addCookie(cookie)

    D

    Cookie c=new cookie(“name”,“value”)

    E

    以上选项都不能


    正确答案: A
    解析: 暂无解析