Which retrieves all cookies sent in a given HttpSErvletRequest request?()
第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");
第2题:
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}%>
第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);
第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?()
第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++;%>
第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");
第7题:
A.request.getCookies()
B.request.getAttributes()
C.request.getSession().getCookies()
D.request.getSession().GetAttributes()
第8题:
A、HttpSessionsession=request.getSession(true)
B、HttpSessionsession=request.getHttpSession(true)
C、HttpSessionsession=response.getSession(true)
D、HttpSessionsession=response.getHttpSession(true)
第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?()
第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?()