%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %> <%@ page import="java.io.*"%> <%@ page import="java.util.*"%> <%@ page import="org.apache.regexp.*"%> <% /* ************ JSPrint - This file is print.jsp Credit to PHPrint for inspiration (http://www.mikenew.net/printfriendly.php) Created May 2, 2003 by Dan Harrelson (daniel.harrelson@cw.com) ************ 1. Place somewhere in your HTML page where you consider it to be the start of printer friendly content, and goes at the end of that same content. 3. You place a link to print.jsp anywhere on the HTML page (preferably outside the printed content, like this: Print this page. */ // Define the text that denotes the start and end of the print area. String startingpoint = ""; String endingpoint = ""; // Get and set the page encoding String enc = request.getParameter("enc"); String encoding = ""; if (enc!=null) { response.setContentType("text/html; charset=" + enc); encoding = "text/html; charset=" + enc; } else { response.setContentType("text/html; charset=iso-8859-1"); encoding = "text/html; charset=iso-8859-1"; enc = "iso-8859-1"; } // Grab the refering URL by looping through the servlet header Enumeration enum; enum = request.getHeaderNames(); String refpage = null; while (enum.hasMoreElements()) { String key = (String)enum.nextElement(); if (key.equals("referer")) { refpage = request.getHeader(key); break; } } // Strip off the domain to get only the full path to the referer String path = null; if (refpage != null) { path = refpage; RE re = new RE("^http[s]?://[^/]+"); path = re.subst(path, ""); } // Find the file system path to the referer String realpath = null; String area = null; if (path != null) { realpath = request.getRealPath(path); RE reArea = new RE("/iw-mount/default/main/cw.com/global/WORKAREA/[^/]+"); // Grab just the workarea part of the URL boolean matched = reArea.match(realpath); area = reArea.getParen(0); RE re2 = new RE("/iw-mount/default/main"); // If on TeamSite, strip /iw-mount/default/main realpath = re2.subst(realpath, ""); RE re3 = new RE("/apps/WebSphere/AppServer/hosts/default_host/default_app/web"); // If on WAS, alter docroot realpath = re3.subst(realpath, "/apps/newcwcom"); // If doesn't end with ".html" then enter this statement RE reIDX = new RE("html$"); matched = reIDX.match(realpath); if (matched == false) { // Path doesn't end with ".html" // If path ends with a query string then enter this statement RE reQuery = new RE("[?].*$"); matched = reQuery.match(realpath); if (matched == true) { realpath = reQuery.subst(realpath, ""); // If ends with query string, then strip it off matched = reIDX.match(realpath); if (matched == false) realpath = realpath + "index.html"; // If appears to be a directory then add "index.html" } else { realpath = realpath + "index.html"; // If appears to be a directory then add "index.html" } } } // Open and read in the refering page line by line, saving to a string, then closing file String value = null; if (realpath != null) { File inputFile = new File(realpath); try { // Read in file as InputStream to specify encoding based on parameter BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(inputFile), enc)); String line=null; while ((line=in.readLine())!=null){ value = value + "\n" + line; } in.close(); } catch (FileNotFoundException e) { out.println(""); } } int start = 0; int finish = 0; int length = 0; // Grab the page title String title = null; if (value != null) { start = value.indexOf("
The print version of this page could not be loaded. Please notify the site administrator of this error via email. We apologize for any inconvenience this may have caused. |
The print version of this page could not be loaded. Please notify the site administrator of this error via email. We apologize for any inconvenience this may have caused. |
|