String qq = request.getParameter("text1");
Cookie o = new Cookie("wangzhe",qq);
o.setMaxAge(60*60*24);
o.setDomain(".wangzhe.com");
o.setPath("/");
response.addCookie(o);
Cookie[] a = request.getCookies();
out.println(a.length);
上面的代码连本机的cookie都写不进去,前几天我用的win7,xp双系统在win7中可以成功写入cookie但是,在想xp中写入失败
我以为双系统影响的于是我把win7卸了,现在我的电脑里只有xp在写还是写不到磁盘中,晕死了。a的值是null。诸位高手请指点一下到底哪里有问题????????????????????????
Cookie o = new Cookie("wangzhe",qq);
o.setMaxAge(60*60*24);
o.setDomain(".wangzhe.com");
o.setPath("/");
response.addCookie(o);
Cookie[] a = request.getCookies();
out.println(a.length);
上面的代码连本机的cookie都写不进去,前几天我用的win7,xp双系统在win7中可以成功写入cookie但是,在想xp中写入失败
我以为双系统影响的于是我把win7卸了,现在我的电脑里只有xp在写还是写不到磁盘中,晕死了。a的值是null。诸位高手请指点一下到底哪里有问题????????????????????????
解决方案 »
- java调用jacob报错EXCEPTION_ACCESS_VIOLATION 高手帮忙看下
- 数据库连接问题
- 如何取值 java sql
- Servlet上下文监听出错!!(菜鸟请大侠帮助!!!!!!1)
- 急!! 谁用过JasperReport? 现在需要输出报表导html, 但字段需要动态定义,请问怎么实现啊?
- linux服务器下,中文命名文件在网页上无法打开,急
- 我的JSP 程序连上数据库以后 输出结果奇怪 大侠帮看下
- 奇哉怪哉,为什么SELECT结果只显示字符型字段值?
- 有关jsp+Resin的问题.
- 请问我的Servlet放在什么地方才能通过浏览器访问!???
- json-lib json to bean 转换问题
- Ajax的一个小问题
怎么输出cookie的值
out.println(a.length);
获取的a,用debug检测a=null。所以下一条语句才报异常。
这句话之后就打印一下看看O里边有东西没,如果没有的话,那可能真的没写进去
以前维护别人的代码时出现过能cookie写不进的情况,后来排查前人把response的流关了。
Cookie o = new Cookie("wangzhe",qq);
o.setMaxAge(60*60*24);
response.addCookie(o);Cookie[] a = request.getCookies();
for(int i=0;i<a.length;i++)
{
out.println(a[i].getName());
}你这样试一下
HTTP Status 500 -
type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception java.lang.NullPointerException
lichao.doPost(lichao.java:61)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.24 logs
out.println(a.length);