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. HDU 5833 (2016大学生网络预选赛) Zhu and 772002(高斯消元求齐次方程的秩)

    网络预选赛的题目……比赛的时候没有做上,确实是没啥思路,只知道肯定是整数分解,然后乘起来素数的幂肯定是偶数,然后就不知道该怎么办了… 最后题目要求输出方案数,首先根据题目应该能写出如下齐次方程(从别人 ...

  2. Redis学习笔记(二)-key相关命令【转载】

    转自 Redis学习笔记(二)-key相关命令 - 点解 - 博客园http://www.cnblogs.com/leny/p/5638764.html Redis支持的各种数据类型包括string, ...

  3. java字符编码,字符转码

    编码:String->byte[]; str.getBytes(charsetName) 解码:byte[]->String; new String(byte[],charsetName) ...

  4. 【gcd】 最大公约数

    int gcd(int a,int b) { int r; ) { r=a%b; a=b; b=r; } return a; }

  5. http 安全验证

    今天升级Xcode 7.0 bata发现网络访问失败.输出错误信息 The resource could not be loaded because the App Transport Securit ...

  6. 使用JAVA NIO实现的UDP client和server

    //////////////////////////////////////////////////////////////////////////////////////////////////// ...

  7. 【转载】彻底弄懂css中单位px和em,rem的区别

    原文链接:http://www.cnblogs.com/leejersey/p/3662612.html 国内的设计师大都喜欢用px,而国外的网站大都喜欢用em和rem,那么三者有什么区别,又各自有什 ...

  8. 集合-字典(Dictionary)

    字典(散列表):允许按照某个键来访问元素,能根据键快速查找元素,也可以自由添加,删除元素.比较像List<T>类,但没有list向后移动元素的性能开销. .net中最主要的字典类是Dict ...

  9. TCP与UDP的区别(转)

    源:http://blog.chinaunix.net/uid-20745340-id-1878774.html 参考:TCP协议与UDP协议的区别 TCP与UDP的区别 中国移动.中国联通推行的GP ...

  10. php的autoload机制

    php5版本中,当你尝试使用一个未定义的类或者接口时,会自动调用__autoload()函数 例如1 <?php function __autoload($class_name){ includ ...