单选题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. } T

题目
单选题
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);


相似考题
更多“单选题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. } T”相关问题
  • 第1题:

    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

  • 第2题:

    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

  • 第3题:

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

    • A、HttpSession session=request.getSession(true)
    • B、HttpSession session=request.getHttpSession(true)
    • C、HttpSession session=response.getSession(true)
    • D、HttpSession session=response.getHttpSession(true)

    正确答案:A

  • 第4题:

    下列代码正确的是哪项?() 

    • A、 public class Session implements Runnable, Clonable{   public void run ();public Object clone () ; }
    • B、 public class Session extends Runnable, Cloneable {  public void run() {/*dosomething*/}       public Object clone() {/*make a copy*/} }
    • C、 public abstract class Session implements Runnable, Clonable {       public void run() {/*do something*/}       public Object clone() {/*make a copy*/}        }
    • D、 public class Session implements Runnable, implements Clonable {       public void run() {/*do something*/}       public Object clone() {/*make a copy*/}       }

    正确答案:C

  • 第5题:

    Given that a scoped attribute cart exist only in a user’s session, which two, taken independently, ensure the scoped attribute cart no longer exists?()

    • A、 ${cart = null } 
    • B、 <c:remove var=”cart” /> 
    • C、 <c:remove var=”${cart}” /> 
    • D、 <c:remove var=”cart” scope=”session” /> 
    • E、 <c:remove scope=”session”>cart</c:remove>
    • F、 <c:remove var=”${cart}” scope=”session” /> 
    • G、 <c:remove scope=”session”>${cart}</c:remove>

    正确答案:D,E

  • 第6题:

    Given that a scoped attribute cart exists only in a user’s session, which two, taken independently, ensure the scoped attribute cart no longer exists?()

    • A、 ${cart = null} 
    • B、 <c:remove var="cart" /> 
    • C、 <c:remove var="${cart}" /> 
    • D、 <c:remove var="cart" scope="session" /> 
    • E、 <c:remove scope="session">cart</c:remove> 
    • F、 <c:remove var="${cart}" scope="session" /> 
    • G、 <c:remove scope="session">${cart}</c:remove>

    正确答案:D,E

  • 第7题:

    单选题
    下列代码正确的是哪项?()
    A

     public class Session implements Runnable, Clonable{   public void run ();public Object clone () ; }

    B

     public class Session extends Runnable, Cloneable {  public void run() {/*dosomething*/}       public Object clone() {/*make a copy*/} }

    C

     public abstract class Session implements Runnable, Clonable {       public void run() {/*do something*/}       public Object clone() {/*make a copy*/}        }

    D

     public class Session implements Runnable, implements Clonable {       public void run() {/*do something*/}       public Object clone() {/*make a copy*/}       }


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

  • 第8题:

    单选题
    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
    解析: 暂无解析

  • 第9题:

    单选题
    Your company runs Remote Desktop Services. You have a Remote Desktop Session Host (RD Session Host) server. You need to ensure that remote desktop users can print only to the printers that are installed on the RD Session Host server. What should you do?()
    A

    Enable the Do not allow client printer redirection Group Policy setting.

    B

    Disable the Do not allow client printer redirection Group Policy setting.

    C

    Enable the Do not set default client printer to be default printer in a session Group Policy setting.

    D

    Disable the Do not set default client printer to be default printer in a session Group Policy setting.


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

  • 第10题:

    多选题
    Given that a scoped attribute cart exist only in a user’s session, which two, taken independently, ensure the scoped attribute cart no longer exists?()
    A

    ${cart = null }

    B

    <c:remove var=”cart” />

    C

    <c:remove var=”${cart}” />

    D

    <c:remove var=”cart” scope=”session” />

    E

    <c:remove scope=”session”>cart</c:remove>

    F

    <c:remove var=”${cart}” scope=”session” />

    G

    <c:remove scope=”session”>${cart}</c:remove>


    正确答案: G,E
    解析: 暂无解析

  • 第11题:

    多选题
    Given that a scoped attribute cart exists only in a user’s session, which two, taken independently, ensure the scoped attribute cart no longer exists?()
    A

     ${cart = null} 

    B

    <c:remove var=cart />

    C

    <c:remove var=${cart} />

    D

    <c:remove var=cart scope=session />

    E

    <c:remove scope=session>cart</c:remove>

    F

    <c:remove var=${cart} scope=session />

    G

    <c:remove scope=session>${cart}</c:remove>


    正确答案: F,E
    解析: 暂无解析

  • 第12题:

    单选题
    在jsp中作用域由小到大的组合是()
    A

    request page session application

    B

    page request session application

    C

    pageContext request session application

    D

    pageScope request sessionScope applicationScope


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

  • 第13题:

    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

  • 第14题:

    Your company runs Remote Desktop Services. You have a Remote Desktop Session Host (RD Session Host) server. You need to ensure that remote desktop users can prin t only to the printers that are installed on the RD Session Host server. What should you do?()

    • A、Enable the Do not allow client printer redirection Group Policy setting.
    • B、Disable the Do not allow client printer redirection Group Policy setting.
    • C、Enable the Do not set default client printer to be default printer in a session Group Policy setting.
    • D、Disable the Do not set default client printer to be default printer in a session Group Policy setting.

    正确答案:A

  • 第15题:

    DO业务的Session呼叫控制流程,包含以下哪几种()。

    • A、Session建立流程
    • B、Session协商流程
    • C、Session配置流程
    • D、Session释放流程

    正确答案:A,C

  • 第16题:

    HttpSession session=request.getSession(false)与HttpSession session = request.getSession(true)的区别()。

    • A、没有区别
    • B、如果当前reqeust中的HttpSession 为null,当传入参数为空时,就创建一个新的Session,否则返回null
    • C、如果当前reqeust中的HttpSession 为null,当传入参数为true时,就创建一个新的Session,否则返回null

    正确答案:C

  • 第17题:

    You are building a Front Controller using a JSP page and you need to determine if the user’s session hasNOT been created yet and perform some special processing for this case. Which scriptlet code snippet willperform this test?()

    • A、<% if ( request.getSession(false) == null ) {// special processing} %>
    • B、<% if ( request.getHttpSession(false) == null ) {// special processing} %>
    • C、<% if ( requestObject.getSession(false) == null ) { // special processing} %>
    • D、<% if ( requestObject.getHttpSession(false) == null ) { // special processing} %>

    正确答案:A

  • 第18题:

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

    HttpSession session=request.getSession(true)

    B

    HttpSession session=request.getHttpSession(true)

    C

    HttpSession session=response.getSession(true)

    D

    HttpSession session=response.getHttpSession(true)


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

  • 第19题:

    单选题
    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
    解析: 暂无解析

  • 第20题:

    多选题
    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
    解析: 暂无解析

  • 第21题:

    单选题
    Your company runs Remote Desktop Services. You have a Remote Desktop Session Host (RD Session Host) server. You need to ensure that remote desktop users can prin t only to the printers that are installed on the RD Session Host server. What should you do?()
    A

    Enable the Do not allow client printer redirection Group Policy setting.

    B

    Disable the Do not allow client printer redirection Group Policy setting.

    C

    Enable the Do not set default client printer to be default printer in a session Group Policy setting.

    D

    Disable the Do not set default client printer to be default printer in a session Group Policy setting.


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

  • 第22题:

    单选题
    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域中

  • 第23题:

    单选题
    You are building a Front Controller using a JSP page and you need to determine if the user’s session hasNOT been created yet and perform some special processing for this case. Which scriptlet code snippet willperform this test?()
    A

    <% if ( request.getSession(false) == null ) {// special processing} %>

    B

    <% if ( request.getHttpSession(false) == null ) {// special processing} %>

    C

    <% if ( requestObject.getSession(false) == null ) { // special processing} %>

    D

    <% if ( requestObject.getHttpSession(false) == null ) { // special processing} %>


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