• 2022-06-11
    读取客户端存储的Cookie,以下操作正确的是( )。
    A: Cookie newCookie=new Cookie(String key,Object value);
    B: response.addCookie(newCookie);
    C: Cookie[] cookies=response.getCookies();
    D: Cookie[] cookies=request.getCookies();
  • D

    内容

    • 0

      以下哪段代码能从请求对象中获取名为"ORA-UID"的Cookie的值? ( ) A: String value = request. getCookie("ORA-UID"); B: String value = request.getHeader("ORA-UID"); C: Cookie[] cookies = request.getCookies();String cName= null;String value = null;if( cookies !=null){for(int i = 0 ;i<;cookies.length; i++){ cName = cookie[i].getName(;if(cName!=null &amp;&amp;. cName.equalsIgnoreCase("ORA-UID")){value = cookies[i].getValue();} D: Cookie[] cookies = request.getCookies();if(cookies. length>;0){String value = cookies[0].getValue();}

    • 1

      ASP.NET但含两个内部 Cookie集合:request对象的 Cookie集合和response对象的Cookie集合。

    • 2

      读取保存到客户端的 cookie,可使用 response对象的______________________

    • 3

      阅读下面代码:设置path为" / ",由localhost发送Cookie信息,在括号中填入正确代码,通知浏览器端立即删除名称为myCookie的对象。 Cookie cookie = new Cookie(“myCookie”,”xxxx”);【 】 【 】 response.addCookie(cookie);由localhost发送Cookie信息。

    • 4

      Cookie的管理包括两个方面:将Cookie对象发送给客户端和从客户端读取Cookie。