题目内容

下面选项中,HttpServletRequest定义了用于获取Session对象的方法是()

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

查看答案
更多问题

给定一个Servlet的代码片段如下所示:public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{String str = "world";HttpSession session = request.getSession();session.setAttribute("str", str);___________________}要取出session中的值,下划线处的代码可以是()

A. String s = session.getParameter("str");
B. String s = (String)session.getAttribute("str");
C. Object o = session.getAttribute("str");
D. Object o = (Object)session.getParameter("str");

下列选项中,适合将信息存入Session的是 ()

A. 用户登录信息
B. 验证码
C. 购物车
D. 聊天室

在Servlet1中使用如下代码设置Cookie:Cookie c = new Cookie(“myCookie”,”xxxx”);response.addCookie(c);当访问http://localhost:8080/news/servlet/Servlet1运行Servlet1后,下列选项中,哪个Servlet可以获取到这个Cookie信息?()

A. http://localhost:8080/news/servlet/Servlet1
B. http://localhost:8080/news/servlet/Servlet2
C. http://localhost:8080/news/Servlet3
D. http://localhost:8080/news/servlet/n/Servlet4

下列选项,生成一次性验证码所用到的主要类和接口的是 ()

A. BufferedImage
B. ImageIO
C. Graphic
D. IOImage

答案查题题库