package zhangeweb.atzhang.Httpservlet;
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 EhttpServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//转发到a.html页面(使用的是相对路径的方法)
//request.getRequestDispatcher("./myfile/a.html").forward(request, response);
//使用相对路径打方法转发到b.html文件
//request.getRequestDispatcher("./myfile/b.html").forward(request, response);
//转发到a.html页面(使用的是绝对路径的方法)
//String path = request.getContextPath();
//System.out.println(path);
//request.getRequestDispatcher("/myfile/a.html").forward(request, response);
//转发到b.html页面(使用的是绝对路径的方法)
//request.getRequestDispatcher("/myfile/b.html").forward(request, response);
//重定向到index.html(相对路径的方法)
//response.sendRedirect("./myfile/index.html");
//重定向到index页面使用(绝对路径的方法)
//String path = request.getContextPath();
//response.sendRedirect(path+"/myfile/index.html");
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}