package response;
import java.io.IOException;
import java.io.OutputStream;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ResponseDemo1 extends HttpServlet {
//程序用什么吗表输出,就控制浏览器用什么吗表打开
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//控制浏览器用什么吗表打开
// response.setHeader("Content-type", "text/html;charset=gbk");
String data = "中国";
OutputStream out = response.getOutputStream();
//用html技术中的<meta>标签模拟一个http响应头。来控制浏览器的行为
out.write("<meta http-equiv='content-type' content='text/html;charset=gbk'>".getBytes());
//控制程序一什么吗表输出
out.write(data.getBytes("gbk"));
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}