在public HttpSession getSession(boolean bool)的方法定义中,当bool为false时表明()A、直接返回会话对象B、当服务器已经创建了会话对象就返回该对象,否则返回nullC、直接返回nullD、当服务器已经创建了会话对象就返回该对象,否则新建一个会话对象并返回

题目

在public HttpSession getSession(boolean bool)的方法定义中,当bool为false时表明()

  • A、直接返回会话对象
  • B、当服务器已经创建了会话对象就返回该对象,否则返回null
  • C、直接返回null
  • D、当服务器已经创建了会话对象就返回该对象,否则新建一个会话对象并返回

相似考题
更多“在public HttpSession getSession(b”相关问题
  • 第1题:

    J2EE中,哪个类的哪个方法用于创建对话?()

    • A、HttpServletRequest、getSession
    • B、HttpServletResponse、newSession
    • C、HtttpSession、newInstance
    • D、HttpSession、getSession

    正确答案:A

  • 第2题:

    Given: 3.public class MyTagHandler extends TagSupport { 4.public int doStartTag() { 5.// insert code here 6.// return an int 7.} 8.// more code here ... 18.} There is a single attribute foo in the session scope. Which three code fragments,inserted independently atline 5,return the value of the attribute?()

    • A、Object o = pageContext.getAttribute("foo");
    • B、Object o = pageContext.findAttribute("foo");
    • C、Object o = pageContext.getAttribute("foo",PageContext.SESSION_SCOPE);
    • D、HttpSession s = pageContext.getSession();Object o = s.getAttribute("foo");

    正确答案:B,C,D

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

    Upon a user’s first visit to the website, which two operations are always performed when the getSession method is called with no arguments in a servlet?()

    • A、 All URLs returned by the server are rewritten.
    • B、 An HttpSession object is created if necessary.
    • C、 The user name and password of the user are checked.
    • D、 The session ID is stored in the HTTP response as a cookie.

    正确答案:B,D

  • 第5题:

    在Java EE中,如果req是HttpServletRequest的实例,要通过req获取已经存在的HttpSession对象,如果不存在就创建一个HttpSession对象,下面选项中()可以实现。

    • A、 req.getSession()
    • B、 req.getSession(false)
    • C、 req.getSession(true)
    • D、 req.createSession()

    正确答案:A,C

  • 第6题:

    下列哪种方式可以在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

  • 第7题:

    下面关于HttpSession的说法正确的是()

    • A、Servlet容器负责创建HttpSession对象
    • B、每个HttpSession对象都有惟一的ID
    • C、HttpSession的数据保存在客户端
    • D、对客户端每次请求服务器都会创建HttpSession对象

    正确答案:A,B

  • 第8题:

    单选题
    下列选项中关于HttpSession描述错误的是()。
    A

     HttpSession通过HttpServletRequest对象获得

    B

     HttpSession可以用来保存数据,并实现数据的传递

    C

     HttpSession被创建后,将始终存在,直到服务停止

    D

     调用HttpSession的invalidate()方法,可以删除创建的HttpSession对象及数据


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

  • 第9题:

    多选题
    在Java EE中,如果req是HttpServletRequest的实例,要通过req获取已经存在的HttpSession对象,如果不存在就创建一个HttpSession对象,下面选项中()可以实现。
    A

    req.getSession()

    B

    req.getSession(false)

    C

    req.getSession(true)

    D

    req.createSession()


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

  • 第10题:

    多选题
    Upon a user’s first visit to the website, which two operations are always performed when the getSession method is called with no arguments in a servlet?()
    A

    All URLs returned by the server are rewritten.

    B

    An HttpSession object is created if necessary.

    C

    The user name and password of the user are checked.

    D

    The session ID is stored in the HTTP response as a cookie.


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

  • 第11题:

    多选题
    在J2EE中,对于在Servlet如何获得会话,描述正确的是()。
    A

    HttpServletRequest类的getSession方法有两个:带参数的getSession方法和不带参数的getSession方法

    B

    在Servlet中,可以使用HttpSession session = new HttpSession()创建session对象

    C

    如果HttpServletRequest类的getSession方法的参数为false,表示如果没有与当前的请求相联系的会话对象时,该方法返回null

    D

    如果HttpServletRequest类的getSession方法的参数为true,表示如果没有与当前的请求相联系的会话对象时,该方法返回null


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

  • 第12题:

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


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

  • 第13题:

    在J2EE中,对于在Servlet如何获得会话,描述正确的是()。     

    • A、HttpServletRequest类的getSession方法有两个:带参数的getSession方法和不带参数的getSession方法
    • B、在Servlet中,可以使用HttpSession session = new HttpSession()创建session对象
    • C、如果HttpServletRequest类的getSession方法的参数为false,表示如果没有与当前的请求相联系的会话对象时,该方法返回null
    • D、如果HttpServletRequest类的getSession方法的参数为true,表示如果没有与当前的请求相联系的会话对象时,该方法返回null

    正确答案:A,C

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

    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

  • 第16题:

    J2EE中,()类的()方法用于创建对话。

    • A、HttpServletRequest;getSession
    • B、HttpServletRequest;NewSession
    • C、HttpSession;newInstance
    • D、HttpSession;getSession

    正确答案:A

  • 第17题:

    下列选项中关于HttpSession描述错误的是()。

    • A、 HttpSession通过HttpServletRequest对象获得
    • B、 HttpSession可以用来保存数据,并实现数据的传递
    • C、 HttpSession被创建后,将始终存在,直到服务停止
    • D、 调用HttpSession的invalidate()方法,可以删除创建的HttpSession对象及数据

    正确答案:C

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

    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

  • 第20题:

    单选题
    在public HttpSession getSession(boolean bool)的方法定义中,当bool为false时表明()
    A

    直接返回会话对象

    B

    当服务器已经创建了会话对象就返回该对象,否则返回null

    C

    直接返回null

    D

    当服务器已经创建了会话对象就返回该对象,否则新建一个会话对象并返回


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

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

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

  • 第23题:

    单选题
    下列哪种方式可以在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)


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