转发(代码实现)
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;
public class RequestForwardServlet extends HttpServlet{
public void doGet(HttpServlet request,
HttpServletResponse response)throws ServletException,IOException{
response.serContentType("text/html;charset=utf-8");
//将数据存储到request对象中
request.setAttribute("company","北京华信智原教育有限公司");
RequestDispatcher dispatcher=request.getRequestDispatcher("/RequestServlet");
dispatcher.forward(request,response);
}
public void doPost(HttpServletRequest request,
HttpServletResponse response)throws ServletException,IOException{
doGet(request,response);
}
}
重定向(代码实现)
response.sendRedirect("download.html");