package com.mahe666.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class Redirect extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //重定向其实就做了这两件事
        /*
        resp.setHeader("Location","/resp/imgCode");
        resp.setStatus(302);
        */

        //跳转的地址前需要加上项目名
        resp.sendRedirect("/resp/imgCode");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
