<%@ page contentType="text/html;charset=utf-8" %><%@page import="java.util.*, java.io.*, java.lang.String, java.text.*" %><% request.setCharacterEncoding("utf-8"); //------------------------------------ // 0. ÆÄ¶ó¸ÞÅÍ ¹ÞÀ½ //------------------------------------ String pOOF = (request.getParameter("oof") == null ? "" : request.getParameter("oof")); String pFileName = (request.getParameter("filename") == null ? "" : request.getParameter("filename")); String pFileType = (request.getParameter("filetype") == null ? "" : request.getParameter("filetype")); //pOOF = "http://localhost:8080/RexServer30/rebfiles/samples/sqlserver_customers_orders.xml{%dataset.xml.root%}1name"; //------------------------------------ // 1. »ó¼ö Á¤ÀÇ //------------------------------------ String sBasePath = "D:\\rexpert30\\RexServer30\\export\\"; String sExporter = "D:\\rexpert30\\RexServer30\\bin\\export.dos.exe"; String sessionid = session.getId(); Date date = new Date(); //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); String sDateTime = sdf.format( date); //String sOOFFileName = sDateTime + "_" + pFileName + "_" + sessionid + ".xml"; //String sExportFileNameSource = sDateTime + "_" + pFileName + "_" + sessionid + "." + pFileType; //String sExportFileNameTarget = pFileName + "." + pFileType; String sExportFileName = pFileName + "." + pFileType; String sOOFFileName = pFileName + ".xml"; //------------------------------------ // 2. OOF, xml data, img µ¥ÀÌÅÍ ÆÄÀÏ·Î ÀúÀå //------------------------------------ saveFile(sBasePath + sOOFFileName, pOOF); //System.out.println(sBasePath + sXmlDataFile); //saveFile(sBasePath + sXmlDataFile, pData); //------------------------------------ // 3. pdfÆÄÀÏ export ÀúÀå //------------------------------------ Runtime rt = Runtime.getRuntime(); //System.out.println(pOOF); //System.out.println(sBasePath + sExportFileNameSource); try { Process proc; //proc = rt.exec(new String[]{sExporter, "load", pOOF, pFileType, sBasePath + sExportFileNameSource}); proc = rt.exec(new String[]{sExporter, "path", sBasePath + sOOFFileName, pFileType, sBasePath + sExportFileName}); proc.waitFor(); } catch(Exception e) { throw new Exception(e.getMessage()); } deleteFile(sBasePath + "" + sOOFFileName); %><%! //******************************************************************// // °øÅë ÇÔ¼ö //******************************************************************// public void deleteFile(String sFile) { File file = null; try { file = new File(sFile); if(file.exists()) { if (!file.delete()) { System.gc(); Thread.sleep(200); file.delete(); } } } catch(Exception e) { // System.out.println(e); } } // ¹®ÀÚ¿­ replace public String replaceStr(String content, String old_str, String new_str) { StringBuffer rtn = new StringBuffer(); int from_idx = 0; int to_idx = 0; while ((to_idx = content.indexOf(old_str, from_idx)) >= 0) { rtn.append(content.substring(from_idx, to_idx)); rtn.append(new_str); from_idx = to_idx + old_str.length(); } if (from_idx == 0) { rtn.append(content); } else if (from_idx < content.length()) { rtn.append(content.substring(from_idx)); } return rtn.toString(); } // replaceStr // ¹®ÀÚ¿­ split public String[] fnSplit(String sDelimiter, String sValue) { int index = sValue.indexOf(sDelimiter); List list = new ArrayList(); int currPos = 0; int len = sDelimiter.length(); while (index != -1) { list.add(sValue.substring(currPos, index)); currPos = index + len; index = sValue.indexOf(sDelimiter, currPos); } // end while list.add(sValue.substring(currPos)); String[] vAddString = (String[]) list.toArray(new String[list.size()]); return vAddString; } // fnSplit // ÆÄÀÏ ÀúÀå boolean saveFile(String fileName, String inputString) { File f = new File(fileName); ByteArrayInputStream is = null; FileOutputStream fos= null; BufferedOutputStream bos = null; try{ f.createNewFile(); is = new ByteArrayInputStream(inputString.getBytes("UTF-8")); fos = new FileOutputStream(f); bos = new BufferedOutputStream(fos); // ÆÄÀÏ¿¡ ÀúÀå int su=0; byte b[] = new byte[512]; while((su=is.read(b)) != -1){ fos.write(b,0,su); } }catch(IOException ie){ ie.printStackTrace(); return false; // ¿¹¿Ü°¡ ¹ß»ýÇÏ¸é ½ÇÆÐ }finally{ try { bos.close(); fos.close(); } catch (IOException e) {} } return true; } %>