⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webprintinterfaceservlet.java

📁 adoble form 实现pdf 表单电子化管理的软件非常好
💻 JAVA
字号:
package com.res.webprint.sample;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

import com.res.webprint.servlet.*;


/**
 * <p>WebPrint Interface Servlet</p>
 * <p>This servlet is emulated to call webprint module. The calling routine
 *    is an example for using this printing system. You can make an adjustment
 *    to your application accordingly</p>
 *
 * @Copyright Realesoft (c) 2005
 * @version 1.0
 */

public class WebPrintInterfaceServlet extends HttpServlet implements PrintConstants {

  //调用打印的参照页面样例
  private final static String JSP_SAMPLE_PAGE = "/sample.jsp";

  //初始化Servlet
  public void init() throws ServletException {
  }
  //处理HTTP Get请求
  public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
     processRequest(request, response);
  }
  //处理HTTP Post请求
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
     processRequest(request, response);
  }
  //处理HTTP Get和Post请求
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {

     //准备打印信息:表单ID和打印数据(应用程序采集的客户化数据)
     String formId = request.getParameter(FORM_ID);
     String xmlData = request.getParameter(XML_DATA);

     //创建PrintKeyData事例
     PrintKeyData keyData = new PrintKeyData();
     //设置打印表单ID
     keyData.setFormId(formId);
     //设置打印数据,格式参照Part-4
     keyData.setXmlPrintStr(xmlData);
     //设置打印页面的相对路径,如 jsp
     keyData.setJspPath("jsp");
     //设置Web Server根路径,如http://localhost:8080/webprint
     keyData.setWebRootURI("http://localhost:8080/webprint");
     //创建PrintState事例
     PrintState state = new PrintState(request);
     //保存打印信息
     state.setPrintKeyData(keyData);

     //调用打印页面
     RequestDispatcher rd = getServletContext().getRequestDispatcher("/"+keyData.getJspPath()+JSP_SAMPLE_PAGE);
     rd.forward(request, response);
  }

  //释放资源
  public void destroy() {
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -