HttpServletRequest类的getSession方法有两个:带参数的getSession方法和不带参数的getSession方法
在Servlet中,可以使用HttpSession session = new HttpSession()创建session对象
如果HttpServletRequest类的getSession方法的参数为false,表示如果没有与当前的请求相联系的会话对象时,该方法返回null
如果HttpServletRequest类的getSession方法的参数为true,表示如果没有与当前的请求相联系的会话对象时,该方法返回null
第1题:
在jsp页面声明中定义了一个方法,下列( )代码不能放入该方法中
public void test(HttpServletReqeust request)
{
}
A、HttpSession session =request.getSession();
B、String name=(String)request.getAttribute("name");
C、String name=(String)session.getAttibute("name");
D、request.sendRedirect(“index.jsp”);
第2题:
A.HttpServletRequest、getSession
B.HttpServletResponse、newSession
C.HtttpSession、newInstance
D.HttpSession、getSession
第3题:
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都是一样的
第4题:
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?()
第5题:
J2EE中,哪个类的哪个方法用于创建对话?()
第6题:
A、HttpSessionsession=request.getSession(true)
B、HttpSessionsession=request.getHttpSession(true)
C、HttpSessionsession=response.getSession(true)
D、HttpSessionsession=response.getHttpSession(true)
第7题:
在public HttpSession getSession(boolean bool)的方法定义中,当bool为false时表明()
第8题:
A.HttpServletRequest类的getSession方法有两个:带参数的getSession方法和不带参数的getSession方法
B.在Servlet中,可以使用HttpSessionsession=newHttpSession()创建session对象
C.如果HttpServletRequest类的getSession方法的参数为false,表示如果没有与当前的请求相联系的会话对象时,该方法返回null
D.如果HttpServletRequest类的getSession方法的参数为true,表示如果没有与当前的请求相联系的会话对象时,该方法返回null
第9题:
在J2EE中,对于在Servlet如何获得会话,描述正确的是()。
第10题:
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?()