FiledownloadresourcePath

if i have a webdynpro project that have file upload and download feature
when i click upload the file will store in directory specify by me,
later on...when i try to download the file....
how to the system know which directory i stored......
or the system will only retrieve from specific location ?

normally it will store in this location right...
localhost\d$\usr\sap\N01\DVEBMGS01\j2ee\cluster\server0
something very weird happen...
when i try my run my webdynpro locally...it can export successfully...it will prompt me to download
when i run in the http://xxx.com/webdynpro/MailApp
it cannot export the file....the external window popup and close back
[code]
try {
                    final byte[] content = this.getByteArrayFromResourcePath("OutboundMail.xls");
               //final byte[] content = this.getByteArrayFromResourcePath("
localhost
d$
usr
sap
N01
DVEBMGS01
j2ee
cluster
server0
tm.xls");
               final IWDCachedWebResource resource = WDWebResource.getWebResource(content, WDWebResourceType.XLS);
               resource.setResourceName("MailOutbound_Report_Summary");
               try {
               final IWDWindow window = wdComponentAPI.getWindowManager().createExternalWindow(resource.getAbsoluteURL(), "WD_Filedownload", false);
//                 wdComponentAPI.getMessageManager().reportSuccess("resourcePath"+resource.getAbsoluteURL());
               window.open();
               catch(Exception e)
               wdComponentAPI.getMessageManager().reportException(new WDNonFatalException(e), false);
               } catch (IOException e) {
//                  TODO Auto-generated catch block
               e.printStackTrace();
private byte[] getByteArrayFromResourcePath(String resourcePath)
            throws FileNotFoundException, IOException {
            FileInputStream in = new FileInputStream(new File(resourcePath));
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            int len;
            byte[] part = new byte[10 * 1024];
            while ((len = in.read(part)) != -1) {
            out.write(part, 0, len);
            in.close();
            return out.toByteArray();
public Map DownloadToExcel(ArrayList columnInfos1,String type)
          byte[] b = null;
          String linktoFile = null;
          StringBuffer err = new StringBuffer();
          StringBuffer xml_file = new StringBuffer();
          int noofelem = wdTableNode.size();
          ArrayList columnInfos = trimHeaderTexts(columnInfos1);
          String nodename = wdTableNode.getNodeInfo().getName().trim();
          String _nodename = nodename.substring(0, 1).toUpperCase()+nodename.substring(1).toLowerCase();
          xml_file.append("<?xml version='1.0' encoding='UTF-8' standalone='no'?><")
                         .append(_nodename)
                         .append(">\n");
          int size = columnInfos.size();
          for(int i =0;i<noofelem;i++){     
                    IWDNodeElement elem = wdTableNode.getElementAt(i);
                    xml_file.append("<")
                              .append(_nodename)
                              .append("Element>");
                    for (int j = 0;j<columnInfos.size();j++)
                         String attributeName = (String)columnInfos.get(j);
                         xml_file.append("<")
                                   .append(attributeName)
                                   .append(">")     
                                   .append(elem.getAttributeValue(attributeName))
                                   .append("</")
                                   .append(attributeName)
                                   .append(">\n");
                    xml_file.append("</")
                              .append(_nodename)
                              .append("Element>\n");
               xml_file.append("</")
                         .append(_nodename)
                         .append(">\n");
               try {
                         //modify here
                    if (type=="MailInbound"){
                         FileOutputStream fout=new FileOutputStream("tm.xml");
                         OutputStreamWriter out=new OutputStreamWriter(fout,"UTF-8");
                                            out.write(xml_file.toString());
                                             out.flush();
                                             out.close();
                                             File xmlDocument = new File("tm.xml");
                                             generateInboundMailExcel(xmlDocument);
                    }else if(type=="MailOutbound"){
                         FileOutputStream fout=new FileOutputStream("OutboundMail.xml");
                         OutputStreamWriter out=new OutputStreamWriter(fout,"UTF-8");
                                             out.write(xml_file.toString());
                                             out.flush();
                                             out.close();
                                             File xmlDocument = new File("OutboundMail.xml");
                                             generateOutboundMailExcel(xmlDocument);
                    //b =  xml_file.toString().getBytes("UTF-8");                         
               //     IWDCachedWebResource xlfile = WDWebResource.getWebResource(b,WDWebResourceType.XLS);
                          //xlfile.setResourceName(wdTableNode.getNodeInfo().getName()+" List");
                         //linktoFile = xlfile.getURL();
                         //System.err.println("Link To Url: " +linktoFile);
                         }     catch (WDURLException e1) {
                                   err.append(""+e1.getCause());
                    }catch (UnsupportedEncodingException e) {
                              err.append(""+e.getCause());
               }catch(IOException e){
                    System.err.println("IOException:" +e.getMessage());
          //     Map m = new HashMap();
          //     m.put("data",b);
          //     m.put("url",linktoFile);
          //     m.put("error",""+err.toString());
          //     System.err.println("Hash Map:" +m.toString());
       //     return m;
public static void generateInboundMailExcel(File xmlDocument) {
                                   try {// Creating a Workbook
                                      HSSFWorkbook wb = new HSSFWorkbook();
                                      HSSFSheet spreadSheet = wb.createSheet("spreadSheet");
                                      spreadSheet.setColumnWidth((short) 0, (short) (256 * 25));
                                      spreadSheet.setColumnWidth((short) 1, (short) (256 * 25));
                                      // Parsing XML Document
                                      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                                      DocumentBuilder builder = factory.newDocumentBuilder();
                                      Document document = builder.parse(xmlDocument);
                                      System.err.println("tableemailinelement");
                                      NodeList nodeList = document.getElementsByTagName("TablesemailinElement");
                                      //Create font style
                                      HSSFFont font=wb.createFont();
                                      font.setFontHeightInPoints((short)10);
                                      font.setFontName("Verdana");
                                      font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
                                      HSSFCellStyle style=wb.createCellStyle();
                                      style.setFont(font);
                                      // Creating Rows
                                      System.out.println("create row");
                                      HSSFRow row = spreadSheet.createRow(0);
                                      HSSFCell cell = row.createCell((short) 0);
                                      cell.setCellValue("DATE IN");
                                      cell.setCellStyle(style);
                                      cell = row.createCell((short) 1);
                                      cell.setCellValue("EMAIL ID");
                                      cell.setCellStyle(style);
                                      cell = row.createCell((short) 2);
                                      cell.setCellValue("SUBJECT");
                                      cell.setCellStyle(style);
                                      cell = row.createCell((short) 3);
                                      cell.setCellValue("DATE RECEIVED");
                                      cell.setCellStyle(style);
                                      cell = row.createCell((short) 4);
                                      cell.setCellValue("ACK DELIVERY");
                                      cell.setCellStyle(style);
                                      cell = row.createCell((short) 5);
                                      cell.setCellValue("DATE ACK");
                                     cell.setCellStyle(style);
                                      cell = row.createCell((short) 6);
                                      cell.setCellValue("SENDER");
                                      cell.setCellStyle(style);
                                      cell = row.createCell((short) 7);
                                      cell.setCellValue("RECEIPIENT");
                                      cell.setCellStyle(style);
                                      for(int i=0;i<nodeList.getLength();i++){
                                           System.err.println("loop: node" );
                                      HSSFRow rowno=spreadSheet.createRow(i+1);     
                                      HSSFCellStyle cellStyle = wb.createCellStyle();
                                          cellStyle.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
                                          cellStyle.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
                                          cellStyle.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
                                          cellStyle.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
                                          //***********take note for string and date*************
                                          cell = rowno.createCell((short) 0);
                                               cell.setCellValue(((Element) (nodeList.item(i)))
                                                   .getElementsByTagName("dateIn").item(0)
                                                   .getFirstChild().getNodeValue());
                                        cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                                          cell = rowno.createCell((short) 1);
                                               cell.setCellValue(((Element) (nodeList.item(i)))
                                                   .getElementsByTagName("emailId").item(0)
                                                   .getFirstChild().getNodeValue());
                                               cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                                         cell = rowno.createCell((short) 2);
                                             cell.setCellValue(((Element) (nodeList.item(i)))
                                                  .getElementsByTagName("subject").item(0)
                                                  .getFirstChild().getNodeValue());
                                             cell.setCellType(HSSFCell.CELL_TYPE_STRING);          
                                        cell = rowno.createCell((short) 3);
                                             cell.setCellValue(((Element) (nodeList.item(i)))
                                                  .getElementsByTagName("dateReceive").item(0)
                                                  .getFirstChild().getNodeValue());     
                                            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                                        cell = rowno.createCell((short) 4);
                                             cell.setCellValue(((Element) (nodeList.item(i)))
                                                  .getElementsByTagName("ackDelivery").item(0)
                                                  .getFirstChild().getNodeValue());     
                                             cell.setCellType(HSSFCell.CELL_TYPE_STRING); 
                                        cell = rowno.createCell((short) 5);
                                             cell.setCellValue(((Element) (nodeList.item(i)))
                                                  .getElementsByTagName("dateAck").item(0)
                                                  .getFirstChild().getNodeValue());     
                                             cell.setCellType(HSSFCell.CELL_TYPE_STRING);      
                                        cell = rowno.createCell((short) 6);
                                             cell.setCellValue(((Element) (nodeList.item(i)))
                                                  .getElementsByTagName("sender").item(0)
                                                  .getFirstChild().getNodeValue());
                                            cell.setCellType(HSSFCell.CELL_TYPE_STRING);          
                                        cell = rowno.createCell((short) 7);
                                             cell.setCellValue(((Element) (nodeList.item(i)))
                                                  .getElementsByTagName("receipient").item(0)
                                                  .getFirstChild().getNodeValue());     
                                             cell.setCellType(HSSFCell.CELL_TYPE_STRING);     
                                      // Outputting to Excel spreadsheet
                                      System.err.println("Outputing");
                                      FileOutputStream output = new FileOutputStream(new File("tm.xls"));
                                      wb.write(output);
                                      output.flush();
                                      output.close();
                                     // byte[] bs = new byte[(int) xmlDocument.length()];
                                     // IWDCachedWebResource xlfile = WDWebResource.getWebResource(bs,WDWebResourceType.XLS);
                                     // xlfile.setResourceName("Report");
                                   } catch (IOException e) {
                                      System.out.println("IOException " + e.getMessage());
                                   } catch (ParserConfigurationException e) {
                                      System.out
                                          .println("ParserConfigurationException " + e.getMessage());
                                   } catch (SAXException e) {
                                      System.out.println("SAXException " + e.getMessage());
     public static void generateOutboundMailExcel(File xmlDocument) {
                                        try {// Creating a Workbook
                                           HSSFWorkbook wb = new HSSFWorkbook();
                                           HSSFSheet spreadSheet = wb.createSheet("spreadSheet");
                                           spreadSheet.setColumnWidth((short) 0, (short) (256 * 25));
                                           spreadSheet.setColumnWidth((short) 1, (short) (256 * 25));
                                           // Parsing XML Document
                                           DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                                           DocumentBuilder builder = factory.newDocumentBuilder();
                                           Document document = builder.parse(xmlDocument);
                                           System.err.println("tableemailoutelement");
                                           NodeList nodeList = document.getElementsByTagName("TablesemailoutElement");
                                           //Create font style
                                           HSSFFont font=wb.createFont();
                                           font.setFontHeightInPoints((short)10);
                                           font.setFontName("Verdana");
                                           font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
                                           HSSFCellStyle style=wb.createCellStyle();
                                           style.setFont(font);
                                           // Creating Rows
                                           System.out.println("create row");
                                           HSSFRow row = spreadSheet.createRow(0);
                                           HSSFCell cell = row.createCell((short) 0);
                                           cell.setCellValue("DATE IN");
                                           cell.setCellStyle(style);
                                           cell = row.createCell((short) 1);
                                           cell.setCellValue("EMAIL ID");
                                           cell.setCellStyle(style);
                                           cell = row.createCell((short) 2);
                                           cell.setCellValue("SUBJECT");
                                           cell.setCellStyle(style);
                                           cell = row.createCell((short) 3);
                                           cell.setCellValue("ACK DELIVERY");
                                           cell.setCellStyle(style);
                                           cell = row.createCell((short) 4);
                                           cell.setCellValue("DATE SENT");
                                           cell.setCellStyle(style);
                                           cell = row.createCell((short) 5);
                                           cell.setCellValue("SENDER");
                                           cell.setCellStyle(style);
                                           cell = row.createCell((short) 6);
                                           cell.setCellValue("RECEIVER");
                                           cell.setCellStyle(style);
                                           for(int i=0;i<nodeList.getLength();i++){
                                             System.err.println("loop: node" );
                                           HSSFRow rowno=spreadSheet.createRow(i+1);     
                                           HSSFCellStyle cellStyle = wb.createCellStyle();
                                               cellStyle.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
                                               cellStyle.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
                                               cellStyle.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
                                               cellStyle.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
                                          //**********************take note for the cell date and string*************************
                                               cell = rowno.createCell((short) 0);
                                                    cell.setCellValue(((Element) (nodeList.item(i)))
                                                        .getElementsByTagName("dateIn").item(0)
                                                        .getFirstChild().getNodeValue());
                                             cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                                               cell = rowno.createCell((short) 1);
                                                    cell.setCellValue(((Element) (nodeList.item(i)))
                                                        .getElementsByTagName("emailId").item(0)
                                                        .getFirstChild().getNodeValue());
                                                    cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                                              cell = rowno.createCell((short) 2);
                                                  cell.setCellValue(((Element) (nodeList.item(i)))
                                                       .getElementsByTagName("subject").item(0)
                                                       .getFirstChild().getNodeValue());
                                                  cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                                             cell = rowno.createCell((short) 3);
                                                  cell.setCellValue(((Element) (nodeList.item(i)))
                                                       .getElementsByTagName("ackDelivery").item(0)
                                                       .getFirstChild().getNodeValue());     
                                                  cell.setCellType(HSSFCell.CELL_TYPE_STRING);               
                                             cell = rowno.createCell((short) 4);
                                                  cell.setCellValue(((Element) (nodeList.item(i)))
                                                       .getElementsByTagName("dateSend").item(0)
                                                       .getFirstChild().getNodeValue());     
                                                  cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                                             cell = rowno.createCell((short) 5);
                                                  cell.setCellValue(((Element) (nodeList.item(i)))
                                                       .getElementsByTagName("sender").item(0)
                                                       .getFirstChild().getNodeValue());
                                                  cell.setCellType(HSSFCell.CELL_TYPE_STRING);          
                                             cell = rowno.createCell((short) 6);
                                                  cell.setCellValue(((Element) (nodeList.item(i)))
                                                       .getElementsByTagName("receipient").item(0)
                                                       .getFirstChild().getNodeValue());     
                                                  cell.setCellType(HSSFCell.CELL_TYPE_STRING);     
                                           // Outputting to Excel spreadsheet
                                           System.err.println("Outputing");
                                           FileOutputStream output = new FileOutputStream(new File("OutboundMail.xls"));
                                           wb.write(output);
                                           output.flush();
                                           output.close();
                                          // byte[] bs = new byte[(int) xmlDocument.length()];
                                          // IWDCachedWebResource xlfile = WDWebResource.getWebResource(bs,WDWebResourceType.XLS);
                                          // xlfile.setResourceName("Report");
                                        } catch (IOException e) {
                                           System.out.println("IOException " + e.getMessage());
                                        } catch (ParserConfigurationException e) {
                                           System.out
                                               .println("ParserConfigurationException " + e.getMessage());
                                        } catch (SAXException e) {
                                           System.out.println("SAXException " + e.getMessage());
[/code]
Message was edited by:
        yzme yzme
Message was edited by:
        yzme yzme
Message was edited by:
        yzme yzme

Similar Messages

Maybe you are looking for

  • How to delete an iCloud account and turnoff Find my Phone for a email address that does not exist

    I have switched my itunes account to a new email address but the iCloud account is still registered to the old email account which I can no longer access. If I go to Settings>iCloud it requests my Apple ID password for the old email account but as th

  • Account Substitution in FB60

    Hi All, I have a requirement in which I need to substituted the intercompany GL accounts proposed by the system with vendor/customer accounts when a user enters an intercompany vendor invoice via FB60. I have tried substitution at call point 2( line

  • Audio And Video Not Linked

    When I drag clips from the Viewer to the Timeline I get audio and video together, but afterwards they are separate. They aren't selected together unless I do a shift-click selection, and even then I can't trim both at once. FCE does seem to remember

  • LMS3.2 log rotation (syslog_info)

    Hi, What should I do to get my syslog_info file rotated whenver the file grows to 512 megabytes in size? I've set up the log rotation in Common Services->Server->Admin but it doesn't seem to work, the file grew to 1.9 gigabytes. Is there any process

  • Full screen show

    Is there any way to lock full screen mode so that users are not aviable to cancel it by mouse? Keyboard is inside of furniture... [email protected]