import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Demo91 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
//response.setContentType("text/html;charset=UTF-8");
//PrintWriter pw = response.getWriter();
//pw.write("Demo91");
//pw.flush();
//pw.close();
//转发
//request.getRequestDispatcher("/Demo92").forward(request,response);
//重定向
response.sendRedirect("/day06/success.html");
}
}
转发java
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 Demo92 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
//输出
response.getWriter().write("Demo92");
}
}
原文地址:http://blog.51cto.com/357712148/2104943