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"/>
response.sendRedirect之前不能有任何输出!
no,I am wrong; you must like this: response.sendRedirect("/test/other.jsp"); response.sendRedirect("/test/welcome.jsp"+"?myname="+name);
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"/>
you must like this:
response.sendRedirect("/test/other.jsp");
response.sendRedirect("/test/welcome.jsp"+"?myname="+name);