如何用setHeader("refresh"...实现跳转?

用setHeader("refresh"...跳转:
马克- to-win:马克 java社区:防盗版实名手机尾号: 73203。
马克-to-win:使用response对象的setHeader()方法可以实现在某个时间点跳转到某个页面的作用。比如 response.setHeader("refresh",60);可以实现六十秒以后,又一次访问当前页面。而response.setHeader ("refresh","3;URL=http://localhost:8080/ServletHello/cookie.html"); 实现3秒后访问新页面:http://localhost:8080/ServletHello/cookie.html。



例:3.2.1


package com;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class DeleteCookie extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setHeader("refresh","2;URL=http://localhost:8080/ServletHello/cookie.html");
    }
}