Java认证考试

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题:

GivenanHttpServletRequestrequestandanHttpServletResponseresponse:41.HttpSessionsession=null;42.//insertcodehere43.if(session==null){44.//dosomethingifsessiondoesnotexist45.}else{46.//dosomethingifsessionexists47.}Toimplementthedesignintent,whichstatementmustbeinsertedatline42?()

A.session=response.getSession();

B.session=request.getSession();

C.session=request.getSession(true);

D.session=request.getSession(false);

E.session=request.getSession("jsessionid");


参考答案:D

第2题:

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

第3题:

给定某servlet 程序的片段,如下:

Public void doGet(HttpServletRequest

request,Httpservletresponse response)

{

_________

}

要把session的失效时间设为30分钟,应该在下划线处插入( )

A、request.getSession().setTimeout(1800);

B、request.getSession().setTimeout(30)

C、request.getSession().setMaxInactiveInterval(1800);

D、request.getSession().setMaxInactiveInterval(30);


正确答案:C

第4题:

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

第5题:

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

第6题:

GivenanHttpServletRequestrequest:22.Stringid=request.getParameter("jsessionid");23.//insertcodehere24.Stringname=(String)session.getAttribute("name");Whichthreecanbeplacedatline23toretrieveanexistingHttpSessionobject?()

A.HttpSessionsession=request.getSession();

B.HttpSessionsession=request.getSession(id);

C.HttpSessionsession=request.getSession(true);

D.HttpSessionsession=request.getSession(false);

E.HttpSessionsession=request.getSession("jsessionid");


参考答案:A, C, D

第7题:

WhichretrievesallcookiessentinagivenHttpSErvletRequestrequest?()

A.request.getCookies()

B.request.getAttributes()

C.request.getSession().getCookies()

D.request.getSession().GetAttributes()


参考答案:A

第8题:

在Servlet里,能正确获取session的语句是()。

A、HttpSessionsession=request.getSession(true)

B、HttpSessionsession=request.getHttpSession(true)

C、HttpSessionsession=response.getSession(true)

D、HttpSessionsession=response.getHttpSession(true)


参考答案:A

第9题:

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

第10题:

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

更多相关问题