protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub /*
* 输出一个excel
* */
response.setContentType("application/vnd.ms-excel");
PrintWriter out = response.getWriter();
out.println("\tQ1\tQ2\tQ3\tQ4\tTotal");
out.println("Apples\t90\t40\t49\t55");
out.println("Oranges\t90\t40\t49\t55");
}

返回一个excel表格

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.setContentType("image/jpeg");
InputStream in = this.getClass().getClassLoader().getResourceAsStream("t.jpg");
byte[] b = new byte[in.available()];
in.read(b);
OutputStream out = response.getOutputStream();
out.write(b);
out.close();
in.close(); }

显示一张图片

Servlet_ResponseHeader的更多相关文章

  1. JQ二级菜单练习之一~~~

    <div class="nav"> <ul> <li><a href="#">首页</a> < ...

随机推荐

  1. Java类锁和对象锁实践(good)

    一.前言 之前对类锁和对象锁是否是互斥的不是太确定,因此决定编写相关的程序进行实践一下.编写前对相关定义约定约定如下: 1. 类锁:在代码中的方法上加了static和synchronized的锁,或者 ...

  2. robot_framewok自动化测试

    robot_framewok自动化测试 http://wenku.baidu.com/view/691abcaa4b73f242336c5fec.html 接口自动化测试框架设计 http://wen ...

  3. Linux下find命令用法小结

    find是个使用频率比较高的命令.常常用它在系统特定目录下,查找具有某种特征的文件. find命令的格式:find [-path……] -options [-print -exec -ok] path ...

  4. JfreeCHart 异常:Chart image not found

    http://bbs.justep.com/thread-54775-1-1.html java.lang.IllegalArgumentException: Width (0) and height ...

  5. UIView(包括子类)的几个初始化时执行动作的时机

    转载自:http://www.tqcto.com/article/mobile/56963.html 根据你需要执行的动作, 这里有几个方法: -(id)initWithFrame:(CGRect)f ...

  6. Android PopupWindow的使用技巧(转)

    Android PopupWindow的使用技巧 PopupWindow是Android上自定义弹出窗口,使用起来很方便. PopupWindow的构造函数为 public PopupWindow(V ...

  7. ms10_046_shortcut_icon_dllloader漏洞利用和ettercap dns欺骗

    ms10_046_shortcut_icon_dllloader漏洞利用过程 msf > use exploit/windows/browser/ms10_046_shortcut_icon_d ...

  8. 根据浏览器UA信息进行跳转(移动和pc)

    如何用php判断一个客户端是手机还是电脑?其实很简单,开发人员都知道,通过浏览器访问网站时,浏览器都会向服务器发送UA,即User Agent(用户代理).不同浏览器.同一浏览器的不同版本.手机浏览器 ...

  9. extjs最普通的grid

    的 <script> Ext.onReady(function () { //1.定义Model Ext.define("MyApp.model.User", { ex ...

  10. CodeForces 609C Load Balancing

    先算出目标状态,然后拿当前状态与目标状态对比,即可算出答案 #include<cstdio> #include<cmath> #include<cstring> # ...