response.sendRedirect之前不能有任何输出!如:response.addCookie(myname);

解决方案 »

  1.   

    because you have:
    response.addCookie(myname);response.sendRedirect("http://localhost:8080/test/welcome.jsp"+"?myname="+name);
    ==>
    <jsp:forward page="("http://localhost:8080/test/welcome.jsp"+"?myname="+name"/>response.sendRedirect("http://localhost:8080/test/other.jsp");
    ==>
    <jsp:forward page="http://localhost:8080/test/other.jsp"/>
      

  2.   

    response.sendRedirect之前不能有任何输出!
      

  3.   

    no,I am wrong;
    you must like this:
    response.sendRedirect("/test/other.jsp");
    response.sendRedirect("/test/welcome.jsp"+"?myname="+name);
      

  4.   

    我照你说的改了,可以重定向了,但是一访问wel.jsp,页面就定向到other.jsp了,也就是说我添加的cookie没有成功 ,我明明在前面添加了的啊,为什么判断的时候没有发现我添加的cookie而执行else的语句呢?