response.setContentType("application/pdf");
试试看
试试看
解决方案 »
- myeclipse数据源连接数据库端口不合法
- 关于jsp一个经常出现tomcat的问题
- 菜鸟求助客户端打开保存数据为csv文件
- 在jsp中怎样获取js中定义的参数?
- 解释一下request.
- 关于SSL的编程
- Struts2同样的程序换了JAR包就报404了
- 装了JB9,还要装tomcat码?我想运行jsp程序
- 】】】】】jsp 俩个 小问题】】】】】
- Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated
- 傻瓜问题,用jbuilder9写jsp叶子有什么特殊的设置吗?
- 如何获得jsp页面中的控件呢?100分!近来就有!
<%
response.setContentType("application/pdf");
Document document=new Document();
ByteArrayOutputStream buffer=new ByteArrayOutputStream();
PdfWriter writer=PdfWriter.getInstance(document,buffer);
document.open();
document.add(new Paragraph("Hello World"));
document.close();
DataOutput output=new DataOutputStream(response.getOutputStream());
byte[] bytes=buffer.toByteArray();
response.setContentLength(bytes.length);
for(int i=0;i<bytes.length;i++)
{
output.writeByte(bytes[i]);
}
%>