public class FServlet extends HttpServlet {
/**
- 禁用浏览器缓存
/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
/* - Cache-Control、Pragma、expirse
*/
response.setHeader(“Cache-Control”, “no-cache”);
response.setHeader(“pragma”, “no-cache”);
response.setDateHeader(“expries”, -1);
response.getWriter().print(“hello”);
}
}
public class GServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
/* String s = “Hello”;
//字节
byte[]bs=s.getBytes();
response.getOutputStream().write(bs);
/
/*
- 演示响应字节数据
- 把一张图片读取到字节数组中
*/
String path = “D:\pic\1\322587.jpg”;
FileInputStream in = new FileInputStream(path);
byte[]bs=IOUtils.toByteArray(in);
response.getOutputStream().write(bs);
}
}