在J2EE中,对于在Servlet如何获得会话,描述正确的是()。     A、HttpServletRequest类的getSession方法有两个:带参数的getSession方法和不带参数的getSession方法B、在Servlet中,可以使用HttpSession session = new HttpSession()创建session对象C、如果HttpServletRequest类的getSession方法的参数为false,表示如果没有与当前的请求相联系的会话对象时,该方法返回nullD、

题目

在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
更多“在J2EE中,对于在Servlet如何获得会话,描述正确的是()。     A、HttpServletRequest类的getSession方法有两个:带参数的getSession方法和不带参数的getSession方法B、在Servlet中,可以使用HttpSession session = new HttpSession()创建session对象C、如果HttpServletRequest类的getSession方法的参数为false,表示如果没有与当前的请求相联系的会话对象时,该方法返回nullD、”相关问题
  • 第1题:

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

    A、HttpSessionsession=request.getSession(true)

    B、HttpSessionsession=request.getHttpSession(true)

    C、HttpSessionsession=response.getSession(true)

    D、HttpSessionsession=response.getHttpSession(true)


    参考答案:A

  • 第2题:

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

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

    正确答案:B

  • 第3题:

    在J2EE中,在web.xml中,有如下代码: 30 < /session-config>    以下描述正确的是()。 

    • A、顶一了,默认的会话超时时长、时间为30秒。
    • B、可以使用HttpSession类的getMaxInactiveInterval()方法把该值提取出来
    • C、定义了默认的会话超时时长。时长为30小时
    • D、可以使用Session类的getMaxInactiveInterval()方法把该值取出来

    正确答案:B

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

    J2EE中,HttpServletRequest类的()方法用返回与当前请求相关联的会话,如果没有,则返回null。

    • A、getSession(null)
    • B、getSession(true)
    • C、getSession(false)

    正确答案:C

  • 第6题:

    HttpServletRequest接口的()方法用于创建会话。

    • A、setSession()
    • B、getContext()
    • C、getSession()
    • D、putSession()

    正确答案:C

  • 第7题:

    在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

  • 第8题:

    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

  • 第9题:

    单选题
    J2EE中,HttpServletRequest类的()方法用返回与当前请求相关联的会话,如果没有,则返回null。
    A

    getSession(null)

    B

    getSession(true)

    C

    getSession(false)


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

  • 第10题:

    多选题
    在J2EE中,以下对于会话跟踪的描述,正确的是()。
    A

    客户浏览器禁用了Cookie后,在Servlet中的getSession方法就无法获得HttpSession对象了

    B

    客户浏览器禁用了Cookie后,可以使用HttpServletResponse接口中的encodeURL()方法对URL编码。但客户如果没有禁用Cookie,使用HttpServletResponse接口中的encodeURL()方法对URL编码会出错

    C

    使用HttpServletResponse接口中的encodeURL()方法对URL编码后,这个方法把以分号开头的字符串形式的路径加入到输入的URL中,如;jsessionid = 123456789

    D

    只要使用HttpServletResponse接口中的encodeURL()方法对URL进行编码,Web应用程序的用户在浏览器中禁止cookie和不禁止cookie都是一样的


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

  • 第11题:

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

    req.getSession()

    B

    req.getSession(false)

    C

    req.getSession(true)

    D

    req.createSession()


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

  • 第12题:

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

  • 第13题:

    J2EE中,()类型的()方法用于得到会话。

    A.HttpServletRequest、getSession

    B.HttpServletResponse、newSession

    C.HtttpSession、newInstance

    D.HttpSession、getSession


    正确答案:A

  • 第14题:

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

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

    正确答案:A

  • 第15题:

    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

  • 第16题:

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

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

    正确答案:A

  • 第17题:

    在Java EE中,关于创建HttpServletRequest对象的说法正确的是()。 

    • A、 从request获取传入的参数,可以调用getParameter方法
    • B、 由Java Web应用的Servlet或JSP组件负责创建,当Servlet或JSP组件响应HTTP请求时,先创建HttpServletRequest对象
    • C、 由程序员通过编码形式创建,以传递请求数据
    • D、 以上都不对

    正确答案:A

  • 第18题:

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

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

    正确答案:A,C

  • 第19题:

    下列有关ServletRequest和ServletResponse的描述错误的是()?

    • A、Servlet引擎使用ServletRequest来向Servlet提供有关客户请求的信息,使用ServletResponse向客户端传送经过MIME编码的数据
    • B、HttpServletRequest类和HttpServletResponse类能够提供进一步的与协议相关的数据。Servlet的Service方法的参数是ServletRequest对象或ServletResponse对象中的一个
    • C、发送文本数据时,使用getWriter方法返回PrintWriter对象;发送二进制数据时,使getOutputStream方法返回ServletOutputStream对象
    • D、在调用getWriter或getOutputStream方法之前必须调用setContentType方法

    正确答案:B

  • 第20题:

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

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

    B

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

    C

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

    D

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


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

  • 第21题:

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

  • 第22题:

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

    直接返回会话对象

    B

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

    C

    直接返回null

    D

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


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

  • 第23题:

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