pdf 简单连接servlet

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("application/pdf");
try {
// We get a resource from our web app
response.setContentType("application/pdf");
try {
Document document = new Document();
PdfWriter.getInstance(document, response.getOutputStream());
document.open();
document.add(new Paragraph("Hello World"));
document.add(new Paragraph(new Date().toString()));
Paragraph p = new Paragraph();
Chunk imdb = new Chunk("Internet Movie Database");
imdb.setAction(new PdfAction(new URL("http://localhost:8080/iTextPdf/servlet/PdfServlet1")));
p = new Paragraph(
"Click on a country, and you'll get a list of movies, containing links to the ");
p.add(imdb);
p.add(".");
document.add(p);
p = new Paragraph("This list can be found in a ");
Chunk page1 = new Chunk("separate document");
page1.setAction(PdfAction.createSubmitForm("/PdfServlet", null, 0));
p.add(page1);
p.add(".");
document.add(p);
document.add(Chunk.NEWLINE);
document.close();
} catch (DocumentException de) {
throw new IOException(de.getMessage());
}
//
} catch (Exception e) {
throw new IOException(e.getMessage());
}
}
Servlet3.1规范(最终版) JavaTM Servlet 规范 版本 3.1(最终版) Shing Wai Chan Rajiv Mordani [作者] 穆茂强 张开涛 [译者] 2012年6月翻译 2013年7月修订 目录 前言 ............................... 3 其他资料 ............................................................................................................................................................ 3 谁应该读此规范 ................................................................................................................................................ 3 API规范 ............................................................................................................................................................3 其他的 Java 平台规范 ....................................................................................................................................... 3 其他重要参考资料 ............................................................................................................................................ 4 提供反馈 ............................................................................................................................................................ 4 专家组成员 ........................................................................................................................................................ 5 答谢 .................................................................................................................................................................... 5 目录 ............................... 6 概览 .............................. 13 1.1 1.2 1.3 1.4 1.5 1.6 什么是 Servlet? .................................................................................................................................. 13 什么是Servlet容器?...............................................................................................................................13 例子...........................................................................................................................................................13 Serv
servlet课件Servlet课件..........................................................................................1 第一章 Servlet基础部分 .....................................................................2 1.1 Servlet简介 .........................................................................2 1.2 Web服务器...........................................................................2 1、介绍...............................................................................2 2、Tomcat的配置..................................................................2 3、Tomcat服务器具体介绍 .......................................................3 4、jar命令介绍......................................................................3 1.3 Servlet的配置文件 .................................................................3 1.4 Servlet的调用过程 .................................................................4 第二章 Servlet核心...........................................................................5 2.1 整体介绍 .............................................................................5 2.2 Servlet的接口.......................................................................5 2.3 servlet的生命周期..................................................................6 1、Servlet的生命周期分为四个阶段 ............................................6 2、在web.xml文件中配置Servlet对象的启动时就创建......................7 3、通过<init-param>标签来配置初始化参数.................................7 2.4 Get请求和Post请求 ................................................................7 2.5 ServletRequest ....................................................................8 request.getInputStream()方法................................................8 request.getReader()方法 .......................................................8 request.getParameter(String name)方法,...............................8 request.getContextPath()方法 ................................................8 等等。。。。。。。。。。。。。。。。。。。。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值