Problem in sending file to browser through JSF

Hi,
I have developed a web page in JSF through which user can download a file.
I write file to the OutputStream of response, it works fine.
But an exception is printed on console:
java.lang.IllegalStateException: Cannot forward after response has been committed
Probably, this is because in backing bean class I have acquired output stream of session and I have written file data to it.
Is there any resolution to the above problem?
Thanks.

Add FacesContext#responseComplete() to the end of the code to let JSF lifecycle know that the response is already completed manually, otherwise JSF will render the response again.
Also see: http://balusc.blogspot.com/2006/05/pdf-handling.html
I'd rather to use a servlet for streaming files and use a plain GET link for that however.
Also see: http://balusc.blogspot.com/2007/07/fileservlet.html

Similar Messages

  • Problem trying to send file to browser in JSF

    Hi I've tried two different techniques for sending a file to a browser(making the user download a file). I've tried an example from myfaces wikipage
    FacesContext context = FacesContext.getCurrentInstance();
    HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getResponse();
    int read = 0;
    byte[] bytes = new byte[1024];
    String fileName = "test.txt";
    response.setContentType("text/plain");
    response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\"");
    OutputStream os = null;
    StringBuffer stringBuffer1 = new StringBuffer("Java Forums rock");
    ByteArrayInputStream bis1;
    try {
        bis1 = new ByteArrayInputStream(stringBuffer1.toString().getBytes("UTF-8"));
        os = response.getOutputStream();
         while ((read = bis1.read(bytes)) != -1) {
            os.write(bytes, 0, read);
        os.flush();
        os.close();
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }FacesContext.getCurrentInstance().responseComplete();
    I have also tried using a component named fileDownload from PrimeFaces. Both give the same result:
    I get a response from the server, the response contains text that should be in the file. The header is a follows:
    X-Powered-By    Servlet/3.0, JSF/2.0
    Server  GlassFish v3
    Content-Disposition attachment;filename="test.txt"
    Content-Type    text/plain
    Transfer-Encoding   chunked
    Date    Thu, 20 May 2010 06:30:20 GMTTo me this looks correct but for some reason I don't get to download the file, I just get this response in firebug.
    Does anyone have any idea?, could it be a serversetting problem? I using glassfish 3
    Thanks / Stefan

    False alarm, it didn't really work, I think it was just a glitsh in JSF that made it work. I think the problem lies in JSF and facelets. I use a facelet and a template.
    Template
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
         xmlns:h="http://java.sun.com/jsf/html"
         xmlns:f="http://java.sun.com/jsf/core"
         xmlns:p="http://primefaces.prime.com.tr/ui"
         xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
         <title><ui:insert name="windowTitle">Default title</ui:insert></title>
         <link rel="stylesheet" type="text/css"
              href="/admin/resources/css/mainGUI.css" />
              <noscript lang="NO">Beklager, dette nettstedet krever at Javascript er skrudd på / tilgjengelig.</noscript>
              <noscript lang="EN">We're sorry, this site need Javascript to be enabled.</noscript>
    </h:head>
    <h:body>
         <div id="fwCenterMiddle" class="fwCenterMiddle"><ui:insert
              name="content">Default content</ui:insert></div>
    </h:body>
    </html>Facelet
    <f:view xmlns="http://www.w3.org/1999/xhtml"
         xmlns:f="http://java.sun.com/jsf/core"
         xmlns:h="http://java.sun.com/jsf/html"
         xmlns:ui="http://java.sun.com/jsf/facelets"
         xmlns:p="http://primefaces.prime.com.tr/ui"
         xmlns:c="http://java.sun.com/jsp/jstl/core" contentType="text/html"
         xmlns:em="http://java.sun.com/jsf/composite/emcomp/"
         xmlns:fn="http://java.sun.com/jsp/jstl/functions">
         <ui:composition template="/templates/masterLayout.xhtml">
              <ui:define name="content">
                   <h1><h:outputText value="Export">
                   </h:outputText></h1>
                   <h:outputText value="#{ChooseExportController.selectEvent}"/>
                                  <h:outputText value="#{ChooseExportController.selectRole}"/>
                   <h:form id="form" >
                        <p:panel header="Velg Election event" style="margin-bottom:10px;" rendered="#{ChooseExportController.selectEvent}">
                             <h:selectOneMenu value="#{ChooseExportController.eventPk}"
                                  onchange="this.form.submit();"
                                  valueChangeListener="#{ChooseExportController.eventListener}">
                                  <f:selectItem itemLabel="" itemValue="0"/>
                                  <f:selectItems
                                       value="#{ChooseExportController.electionEventList}" var="n"
                                       itemLabel="#{n.name}" itemValue="#{n.pk}" />
                             </h:selectOneMenu>
                        </p:panel>
                         <p:messages errorClass="errors" layout="table" showDetail="true"
                             globalOnly="true" />
                        <p:dataTable id="datatable" value="#{ChooseExportController.operatorRoleList}" rendered="#{ChooseExportController.selectRole}"
                             var="operatorRole" border="1" selectionMode="single"
                             selection="#{ChooseExportController.operatorRole}" paginator="true" rows="10">
                             <p:column sortBy="#{operatorRole.role.name}">
                                  <f:facet name="header">
                                       <h:outputText value="Name" />
                                  </f:facet>
                                  <h:outputText value="#{operatorRole.role.name}" />
                             </p:column>
                             <p:column sortBy="#{operatorRole.mvArea.areaLevelString}">
                                  <f:facet name="header">
                                       <h:outputText value="OmrÃ¥desnivÃ¥" />
                                  </f:facet>
                                  <h:outputText value="#{operatorRole.mvArea.areaLevelString}" />
                             </p:column>
                             <p:column sortBy="#{operatorRole.mvArea}">
                                  <f:facet name="header">
                                       <h:outputText value="OmrÃ¥deskontekst" />
                                  </f:facet>
                                  <h:outputText value="#{operatorRole.mvArea}" />
                             </p:column>
                             <p:column sortBy="#{operatorRole.mvElection.electionLevelString}">
                                  <f:facet name="header">
                                       <h:outputText value="ValgnivÃ¥" />
                                  </f:facet>
                                  <h:outputText value="#{operatorRole.mvElection.electionLevelString}" />
                             </p:column>
                             <p:column sortBy="#{operatorRole.mvElection}">
                                  <f:facet name="header">
                                       <h:outputText value="Valgkontekst" />
                                  </f:facet>
                                  <h:outputText value="#{operatorRole.mvElection}" />
                             </p:column>
                        </p:dataTable>
                         <br />
                         <p:commandButton value="Velg rolle" id="selectRole" action="#{ChooseExportController.download}"/>
                        <br />
                        <br />
                        <br />
                   </h:form>
              </ui:define>
         </ui:composition>
    </f:view>But if I rewrite the facelet like this, the download works, and it works with the mimetype text/plain
    <html   xmlns="http://www.w3.org/1999/xhtml"
         xmlns:h="http://java.sun.com/jsf/html"
         xmlns:f="http://java.sun.com/jsf/core"
         xmlns:p="http://primefaces.prime.com.tr/ui"
         xmlns:ui="http://java.sun.com/jsf/facelets">
    <body>
    <f:view>
                   <h1><h:outputText value="Export">
                   </h:outputText></h1>
                        <h:outputText value="#{ChooseExportController.selectEvent}"/>
                                  <h:outputText value="#{ChooseExportController.selectRole}"/>
                   <h:form id="form" >
                   <h:outputText value="Velg Election event: "/>
                   <br/>
                   <h:selectOneMenu value="#{ChooseExportController.eventPk}"
                        onchange="this.form.submit();"
                        valueChangeListener="#{ChooseExportController.eventListener}">
                        <f:selectItem itemLabel="" itemValue="0"/>
                        <f:selectItems
                             value="#{ChooseExportController.electionEventList}" var="n"
                             itemLabel="#{n.name}" itemValue="#{n.pk}" />
                   </h:selectOneMenu>
                        <p:dataTable id="datatable" value="#{ChooseExportController.operatorRoleList}" rendered="#{ChooseExportController.selectRole}"
                             var="operatorRole" border="1" selectionMode="single"
                             selection="#{ChooseExportController.operatorRole}" paginator="true" rows="10">
                             <p:column sortBy="#{operatorRole.role.name}">
                                  <f:facet name="header">
                                       <h:outputText value="Name" />
                                  </f:facet>
                                  <h:outputText value="#{operatorRole.role.name}" />
                             </p:column>
                             <p:column sortBy="#{operatorRole.mvArea.areaLevelString}">
                                  <f:facet name="header">
                                       <h:outputText value="OmrÃ¥desnivÃ¥" />
                                  </f:facet>
                                  <h:outputText value="#{operatorRole.mvArea.areaLevelString}" />
                             </p:column>
                             <p:column sortBy="#{operatorRole.mvArea}">
                                  <f:facet name="header">
                                       <h:outputText value="OmrÃ¥deskontekst" />
                                  </f:facet>
                                  <h:outputText value="#{operatorRole.mvArea}" />
                             </p:column>
                             <p:column sortBy="#{operatorRole.mvElection.electionLevelString}">
                                  <f:facet name="header">
                                       <h:outputText value="ValgnivÃ¥" />
                                  </f:facet>
                                  <h:outputText value="#{operatorRole.mvElection.electionLevelString}" />
                             </p:column>
                             <p:column sortBy="#{operatorRole.mvElection}">
                                  <f:facet name="header">
                                       <h:outputText value="Valgkontekst" />
                                  </f:facet>
                                  <h:outputText value="#{operatorRole.mvElection}" />
                             </p:column>
                        </p:dataTable>
                         <br />
                         <p:commandButton value="Velg rolle" id="selectRole" action="#{ChooseExportController.download}"/>
                        <br />
                        <br />
                        <br />
                   </h:form>
    </f:view>
    </body>
    </html>

  • Sending files to IPhone through OBEX

    Hi.
    I want to send files to IPhone through OBEX protocol.
    But I can not find this service for sending.
    Maybe someone had such problem.
    Thanks in advance

    What does your question have to do with the subject of this forum, which is "Sun Java Wireless Toolkit"?
    If the answer is "nothing" or if this is not answered, this thread will be removed as being off topic and in violation of the CoC for the site.
    db

  • Problem in Sender File Adapter using FCC with Variable structure

    Hi Experts,
    Hi Experts,
    I have facing an issues while using FCC in Sender File adapter. Below are the configs for the same:-
    Recordset structure required is ==HEADER,1,DATA,*,TRAILER,1
    Recordset per message == *
    Key Field Name == Key
    (Sorry i dont know how to insert screen shot here..pls tell me how can i insert screen shots here on sdn)
    HEADER.fieldSeparator           ,
    HEADER.endSeparator           u2018nlu2019
    HEADER.fieldNames               Key,x,y,zu2026
    HEADER.keyFieldValue          1
    HEADER.keyFieldInStructure      ignore
    HEADER.fieldContentFormatting     trim
    HEADER.additionalLastFields     ignore
    HEADER.missingLastFields     ignore
    DATA.fieldSeparator
    DATA.endSeparator
    DATA.fieldNames
    DATA.keyFieldValue
    DATA.keyFieldInStructure
    DATA.fieldContentFormatting
    DATA.additionalLastFields
    DATA.missingLastFields
    Using same variables for Trailer record as well.
    Source CSV file which i am picking:-
    ADSE ,RASD,replan  Contact ,2  0080509 0 8:43:25   ,        
    EMPL ,0011111,  S Top Up ,20080401  ,20080430  ,sdf  ,                          00000000431250  ,2007                                    ,  ,  ,  ,  ,  ,20080414  18:07:35,
    EMPL ,0222222,  r Cash Award ,20070701  ,20070703  ,ded  ,                          00000000023509  ,2007                                    ,  ,  ,  ,  ,  ,20080414  18:09:31,
    EMPL ,0233333,   Cash Award ,20070801  ,20070831  ,df  ,                          00000000044057  ,2007                                    ,  ,  ,  ,  ,  ,20080414  18:10:56,
    EMPL ,0244444,   Cash Award ,20080101  ,20080111  ,sf  ,                          00000000026717  ,2007                                    ,  ,  ,  ,  ,  ,20080414  18:08:29,
    BTRL ,   5140, 
    When i tested the scenario and monitored it using MDT in CC monitoring tool its giving me below mentioned error.
    The XML page cannot be displayed
    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
    XML document must have a top level element. Error processing resource 'http://myurlname/mdt/me...
    However if i change the occurence of DATA as some specific value for eg 4 instead of * it works fine.
    Kindly help me in solving this problem.
    Thanks,
    Aditya Verma

    Hi Madan,
    Thanks a lot for giving me the way to this. But when i tested this with the below file its giving me the same error. Please let me know if i need to do any changes to the parameters mentioned above:-
    ADSE ,ASDA,Sha  replan Fr ont Feed Contact ,2  0080509 0 8:43:25   ,        
    EMPL ,0011111,   Cash Top Up ,20080401  ,20080430  ,TPV  ,                          00000000431250  ,2007                                    ,  ,  ,  ,  ,  ,20080414  18:07:35,
    EMPL ,0222222,   r Cash Award ,20070701  ,20070703  ,TPV  ,                          00000000023509  ,2007                                    ,  ,  ,  ,  ,  ,20080414  18:09:31,
    EMPL ,0233333,  r Cash Award ,20070801  ,20070831  ,TPV  ,                          00000000044057  ,2007                                    ,  ,  ,  ,  ,  ,20080414  18:10:56,
    EMPL ,0244444,   Cash Award ,20080101  ,20080111  ,TPV  ,                          00000000026717  ,2007                                    ,  ,  ,  ,  ,  ,20080414  18:08:29,
    EMPL ,0255555,   Cash Award ,20080301  ,20080320  ,TPV  ,                          00000000027870  ,2007                                    ,  ,  ,  ,  ,  ,20080414  18:08:25,
    EMPL ,0266666,   Cash Award ,20071001  ,20071020  ,TPV  ,                          00000000020681  ,2007                                    ,  ,  ,  ,  ,  ,20080414  18:09:31,
    EMPL ,0877777,   Cash Top Up ,20080401  ,20080430  ,TPV  ,                          00000000036000  ,2007                                    ,  ,  ,  ,  ,  ,20080414  18:07:05,
    EMPL ,0888888,   Leaver Cash Award ,20071201  ,20071231  ,TPV  ,                          00000000157200  ,2007                                    ,  ,  ,  ,  ,  ,20080414  18:11:29,
    EMPL ,0899999,  S Leaver Cash Award ,20080301  ,20080331  ,TPV  ,                          00000000153530  ,2007                                    ,  ,  ,  ,  ,  ,20080414  18:07:42,
    EMPL ,0800000,  S Leaver Cash Award ,20070701  ,20070731  ,TPV  ,                          00000000012234  ,2007                                    ,  ,  ,  ,  ,  ,20080414  18:08:34,
    BTRL ,   5140,
    This the original csv file which i'll get in live. Kindly suggest as ur solution worked with other file but not working with this scv file.
    Thanks a lot,
    Aditya.

  • Problem in Sender File content conversion

    Hi all,
    my sender file structure is as follows:
    records
    header
      f1   minlength=1 MaxLenth=1
      f2   minlength=5 MaxLenth=5
      f3   minlength=7 MaxLenth=7
    detail
      f1   minlength=1 MaxLenth=1
      f2   minlength=5 MaxLenth=5
      f3   minlength=18 MaxLenth=18
    now i need to use these fixed field legth file and perform fcc.
    under fcc of communication channel
    documentname=MT_details
      rcs   header,,detail,
    header.fieldNames  header.f1,header.f2,header.f3
    header.fixedFieldLengts 1,5,7
    detail.fieldNames  detail.f1,detail.f2,detail.f3
    here I Am not using any key field
    when i test the scenario with test file
    A E123 X12345
    T T123 Textlineitem12345
    My problem is the file is not getting picked from the specified path.
    Please correct my configuration.
    Thanks,

    Check the FOLDER permission of the path.
    There may be some permissions missing to access that folder .
    Check with your BASIS or UNIX team.
    Edited by: Naresh Nelapatla on Feb 27, 2012 7:17 PM

  • Problem with Sending files over Sockets

    Hi. I have a problem when I try to send files over sockets. When I send text files it works well but when I try to send .jpg or other kind of files it doesn't work well because some characters are wrong, I hope you can help me.
    Here is my code:
    //Sender code
    import java.io.*;
    import java.net.*;
    class Servidor{
         Servidor(){
              try{
                   String arch="art.jpg";
                   ServerSocket serv=new ServerSocket(125);
                   Socket socket=serv.accept();
                   System.out.println("Conectado");
                   int c;
                   BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
                   FileInputStream fis=new FileInputStream(arch);
                   File f=new File(arch);
                   bw.write(""+f.length());
                   bw.newLine();
                   bw.flush();
                   System.out.println("Escribiendo");
                   while((c=fis.read())!=-1){
                        bw.write(c);
                   bw.flush();
                   fis.close();
                   System.out.println("Terminado");
                   while(true){
              }catch(Exception e){
                   System.out.println(e);
         public static void main(String arg[]){
              new Servidor();
    //Client code
    import java.io.*;
    import java.net.*;
    class Cliente{
         Cliente(){
              try{
                   Socket socket=new Socket("localhost",125);
                   System.out.println("Conectado");
                   BufferedReader br=new BufferedReader(new InputStreamReader(socket.getInputStream()));
                   long tam=Long.parseLong(br.readLine());
                   long act=0;
                   FileOutputStream fos=new FileOutputStream("resp.jpg");
                   System.out.println("Recibiendo: "+tam);
                   while(act<tam){
                        fos.write(br.read());
                        act++;
                   System.out.println("Terminado: "+act+" / "+tam);
                   fos.close();
              }catch(Exception e){
                   System.out.println(e);
         public static void main(String arg[]){
              new Cliente();
    }

    I don't think you want BufferedReader and OutputStreamWriter, you want ByteArrayOutputStream and ByteArrayInputStream . The problem is that you are sending jpegs (binary data) as text.

  • Problem in sender file adapter

    Hi all,
      I have a sender file adapter using ftp with processing mode delete. But my input file is not getting deleted. In RWB, the adapter satus is green with msg processed sucessfully. I tried with a file name that is not available in the ftp folder, but still the adapter status is green with msg processed succesfully.
    Help me debug this error.
    Regards,
    Jai Shankar.

    Are you using Content conversion ?
    If adapter monitoring is green, and shows processed successfully, then if you have any errors , you can see in the RWB->Message Monitoring->Audit Log (Message display Tool).
    If there is no error, then try to do the cache refresh as I told. Ask Admin help for that. Restarting a Adapter engine may help you here/
    Regards,
    moorthy

  • Problem with sender file adapter

    Hi all,
    I am having a problem in reading file with complex structure,
    my structure is like this:
    Header - 1
    rows - 0 - unbound
    Footer 1
    In the recordset Structure - Header,1, Row,*, Footer,1
    The file is not being read, only if I cahnge the * to the exact number of roes type ROw it is working,
    Thnaks,
    Naama.

    Hi,
    I tried it on a simple file and it works,
    But for some reason it doesnt work on my file, I think it because the structure of the segments.
    the first line is the header and its key value is H u2013 it should appear once in the file
    the second line is the header2 and its key value is D u2013 it should appear once in the file
    the 3+4 lines is the details and its key value is L u2013 it should appear * times
    the last line is the footer and its key value is D u2013 it should appear once in the file
    Header1.
    T   H T150380149462.DAT                30/07/08 13:05:04 7 014946/2i`cpei driaz
    Header2.
    T   D  D06AA038H08052587014946245-519-60 045000WKMHDN41BP6U122056  0807230807236915    1000000      000000000000000000H,28910,22040             2828910R0000000200000000000000004830800100000001P
    Details.
    T   D  D06AA038_L_08052587014946210128910R00010020002000  
    T   D  D06AA038_L_08052587014946210128910R00010020002000  
    Footer.
    T   T T150380149462.DAT                00008  014946/2*** seq ****
    I think that because the beginning of header2 and detail is the same it does not work,
    Any Ideas?

  • Show files in browser with JSF

    Hi,
    I'm trying to show several kinds of files in browser, but I still haven't been successful in it, it only show the binarys in browser. This my portion of code where I'm working it. In the example I'm trying too show a pdf's file but it could be, jpg, doc, xls, gif as well
         public void ver(ActionEvent e){
               // Prepare.
            FacesContext facesContext = FacesContext.getCurrentInstance();
            ExternalContext externalContext = facesContext.getExternalContext();
            HttpServletResponse response = (HttpServletResponse) externalContext.getResponse();
            String fileName="D:\\documentacion\\tecnica\\hacia una arquitectura.pdf";
            File file = new File(fileName);
            BufferedInputStream input = null;
            BufferedOutputStream output = null;
            try {
                // Open file.
                input = new BufferedInputStream(new FileInputStream(file),10240);
                // Init servlet response.
                response.reset();
              //  response.setHeader("Content-Type", "application/pdf");
                response.setContentType("application/pdf");
                response.setHeader("Content-Length", String.valueOf(file.length()));           
                response.setHeader("Content-Disposition", "inline; filename=\"" + file.getName()+ "\"");
                output = new BufferedOutputStream(response.getOutputStream(), 10240);
                // Write file contents to response.
                byte[] buffer = new byte[1024];
                int length;
                while ((length = input.read(buffer)) > 0) {
                    output.write(buffer, 0, length);
                // Finalize task.
                output.flush();
            }catch(Exception ex){
                 ex.printStackTrace();
            } finally {
                // Gently close streams.
                close(output);
                close(input);
            facesContext.responseComplete();
    }

    Very frustrating, but I found the fix (on another site - can't believe with 360 views, no one here knew). In Firefox, PDFs are automatically set to open with the faulty Adobe plug-in. To change it to open with Adobe Reader, check out the instructions here:
    https://support.mozilla.org/en-US/kb/pdf-files-are-blank-and-cant-be-downloaded-mac#os=mac &browser=fx16
    Super easy!

  • PROBLEM IN SENDING MAIL TO POSITIONS THROUGH SEND MAIL STEP

    Hi Experts,
    I am facing some problems in sending mail to positions from the organization structure from the send mail step.When I am using user as the recipient type it is working fine...but when i am choosing S position as the recipient type it is giving the error in the workflow log stating that method SENDTASKDESCRIPTION cannot be executed.
    I need to find a solution urgently...any suggestion would be sincerely appreciated.
    thanks.
    Narsingh

    Well you have probably tried this.. but just a recheck.
    1 . send email setep select Organizational Object
    2. Recipient Type Organizational Unit
    3. Here do an F4 and then select the Unit...
    Try this SAP behaves weirdly at times...
    after this do Refresh Buffers.. and Org Unit...
    Let us know if this works

  • How to send files between computers through 8080 port?

    I'm programming an application in JAVA and I need to send one file from my computer (in which I am) to another remote computer through port 8080 (I can configure and install what I want in this remote computer if needed).
    I'm thinking about using servlets and JSP but I don't know if this is the better solution and I don't know how to do it.
    I guess I could install a web server (tomcat) in the remote computer and make a servlet and a JSP (with a formulary to select a file). Then from my computer I could connect to the remote website and select a file, then make a submit, the servlet would proccess the request and it'd upload the file from my computer to remote computer (in which web server is hosted). The problem is that I don't know how the servlet can get the file from my computer and upload it to the remote computer.
    The idea is similar to email at Hotmail,Yahoo... when you select a file as and attachment and then it's uploaded to the server.
    Well, it seems complicated and I don't know if it's the best way to do it. But the most important it's that I can only use port 8080 (due to an intermediate proxy (in my computer side) that I can't configure).
    Please, help, it's very urgent.

    I have a simple servlet class that should get you started.
    http://www.discoverteenergy.com/files/UploadServlet.java
    Here is the MultipartRequest class
    http://www.discoverteenergy.com/files/MultipartRequest.java
    (which was given to me by somebody and is similiar the one from oreilly that a lot of people use: http://www.servlets.com/cos/index.html
    The servlet will show you how to invoke the multipart request. Its one line really:
    MultipartRequest multi = new MultipartRequest(req, uploadDirectory, maxFileSize);
    Hope this helps.

  • Help! problem running .bat files in browser

    HI! Hope you can help me!
    I have a simple applet that runs .bat files and retrieves the resulting information into a text box.
    To run those files I use:
    Runtime rt = Runtime.getRuntime();
    Process processo=rt.exec("C:/po2PrtMonitor.bat 04600105 ope >C:/infoPrt.txt");
    in wich "04600105","ope" and ">C:/infoPrt.txt" are parameters that the .bat file is expecting. When the file is ran it saves the resulting information on a simple .txt file, that I later read by using:
    fichResposta = new FileInputStream(fichRespostaPath[0]);
    When I run my applet on JDeveolper 9.0.2.822 is works perfectly, the problem is when run it on the browser.
    On the browser the applet executes the file by opening a MS-DOS prompt and when it finishes executing the file, the prompt closes automatically and doesn't send the information into the .txt file.
    My .bat file is something like:
    jre -cp PrtSrv20.jar sibs.deswin.prt.PrtMonGateway 10.46.1.22 5003 %1 %2 %3
    where %1,2%,3% are the above parameters given by the applet when the file is ran.
    If I run it on JDeveloper I get:
    C:\>jre -cp PrtSrv20.jar sibs.deswin.prt.PrtMonGateway 10.46.1.22 5003 04600105 ope
    PRTSES=04600105 HDR=0460010000000005 STA=OPENED TRF=ACTIVE TRP=CONN ILTS=15 Long postings are being truncated to ~1 kB at this time.

    Here is what is missing:
    ILT=0 MSQ=388 HDR=04.60.01.00.00.00.00.05.41.00.01.84. CMD=STRT-TRF
    When the applet is run on the IE broser what I get is simply:
    jre -cp PrtSrv20.jar sibs.deswin.prt.PrtMonGateway 10.46.1.22 5003 04601005 ope
    I have no idea as to what the problem might be! Do native methods work differently on the browser?! Could it be a problem on the deployment? A library not included on the deployment profile? Suggestions are very welcome.
    Hugo Rosas

  • Problems displaying PDF files in browser - Help requested

    The scenario is that I visit a website that has information available via a link that normally would open a PDF document in a browser window.  The sort of document, that once open, if I clicked 'File-save as' in the browser would immediately save as a PDF file.  In the current situation I click on the link and all I get that opens is a screen full of random characters from top to bottom.  I have tried right click 'file save as' on the link that would open the PDF in the browser, but all it wants to save is a .PNG file, i.e. http://echa.europa.eu/echa-styled-theme/images/doc_lang/en.png - which is what I get from right click 'properties' on that link which should open the PDF in the brawser - normally I would see a .PDF file described. I therefore can't even download the file to open as a PDF direct from a stored location on my own PC - all it seems to see is the graphics format - this probably why when the browser goes to open the PDF file I get the random characters, i.e. the application is doing its best to translate what it does see.  I would be grateful for some advice.  Pertinant information follows:
    1.  It happens across more websites than just one example that I've quoted.
    2.  It happens on my desktop only - I don't have the problem on 4 other portable computers, including ones running the same O/S
    3.  Desktop is running Windows Home Pro, all updates executed, running the latest version of Acrobat reader with all updates executed - I tried yet another uninstall, reboot, new download, reinstall, reboot etc. yesterday.  Desktop is HP Pavillion with 12GB RAM
    4.  I get the random character display when running IE9 on the desktop, I have also replicated the problem with other versions of IE installed instead.  If I try using Chrome as a browser it goes away and tries and just fails to open the link entirely and reverts to the original page.
    5.  I've already checked online for similar problems and can confirm that all the Adobe plugins are installed per what seems standard advice I have also checked the internet settings in Adobe Acrobat preferences and all seems fine.
    6.  Thing like the browsers and Adobe arobat are running as per their standard set-ups with nothing else done to these.
    7.  Any other PDF files stored on the hard drive of the desktop open in Acrobat reader without problems
    8.  Acrobat reader version is 11.0.06.70
    Any assistance to open the PDF files in the browser and get it working particularly with IE would be great, I am quite IT literate and can try most things.  Many thanks

    Moderator
    I have no idea how to edit the above message, but apparently it has been rejected.  I cannot understand why, I am a regular contributor in many forums and have never suffered the indignity of having had a message rejected before.  The message contains an excellent example of the problems I am having in the following link Vacancies
    How on earth can I demonstrate the problems I am having without being to post an example - that example has both sorts of links on one page, ones I can open and ones I can't - if anyone with technical knowledge is trying to help me then that is just the sort of page that would be useful to help solve the problem.  Rather than the link to the ECHA website in the above posting (which I note was approved).  I struggle with your logic in accepting one message and rejecting the other.  It is difficult enough as a user to describe a problem in words let alone have the best example of the problem rejected without explanation and no right of appeal on the email that I got telling me.  Not happy here!   All I am trying to do is to solve the problem I have

  • Problem in sending data to BW through XI

    Hi all,
    I am using "How to..push data to BW from XI".
    There a javascript code is given for sending data to BW using XI.
    But when I use that code for sending XML file it is showing a java script error:"Automation server can't create object".
    I think it has something to do with ADODB.Stream object.
    As given in the microsoft document I have deleted the registry entry which disables ActiveX component ADODB.Stream object.
    Even then it is showing the same error.
    Can someone figure out what is the problem.
    Any help will be appreciated.
    Regards,
    Anand

    Hi Anand,
            Sure, first i tried to send hardcoded data by using a report in bw, and refering the classes from transaction sproxy.
    The code was:
    REPORT  ZZ_TEST_XI_POC.
    *& Report  ZZ_TEST_XI_POC
    *& start of code by Anirban Ghatak , 14/03/06
    *& This Report will send data to sap xi
    *& start of code by Anirban Ghatak , 14/03/06
    DATA prxy TYPE REF TO ZPUSHCO_PROXY_INTERFACE_OB.
    CREATE OBJECT prxy.
    DATA it TYPE  ZPUSHPUSH_TABLE1.
    TRY.
        it-PUSH_TABLE-EMP_NO = 'Anirban'.
        it-PUSH_TABLE-EMP_NAME = '393'.
        it-PUSH_TABLE-DEPARTMENT_NAME = 'NetWeaver'.
        CALL METHOD prxy->execute_asynchronous
          EXPORTING
            output = it.
         commit work.
      CATCH cx_ai_system_fault .
        DATA fault TYPE REF TO cx_ai_system_fault .
        CREATE OBJECT fault.
        WRITE :/ fault->errortext.
    ENDTRY.
    *& End of code by Anirban Ghatak , 14/03/06
    then execute it , this sends data to xi.
    Refer /people/ravikumar.allampallam/blog/2005/03/14/abap-proxies-in-xiclient-proxy
    this can send data from bw to xi.
    Try have a look and see if you can replicate, actually mine is a POC so i have a little bit of flexibility but if you are working on a live devlopement reconsider the solution.
    Anirban.

  • Problem with Sender File Content conversion

    Hi everybody,
    I have a flat file with the following structure:
    PR1xxxx
    CL1.1xxx
    ALxxx
    PTxxx
    PTxxx
    PTxxx
    CL1.2xxx
    ALxxx
    PTxxx
    PTxxx
    Cl1.3xxx
    PR2xxx
    CL2.1
    Alxxx
    PTxxx
    Ptxxx
    CL2.2xxx
    ALxxx
    PR3xxx
    I need to send an IDOC (ORDERS05) per CL and I also need that the PR goes together with the CL.
    Something like that:
    IDOC 1
    PR1xxx
    CL1.1xxx
    ALxxx
    PTxxx
    PTxxx
    PTxxx
    IDOC 2
    PR1xxx
    CL1.2xxx
    ALxxx
    PTxxx
    PTxxx
    IODC 3
    PR2xxx
    CL2.1xxx
    The problem is that I am not able to attach the PR with each CL because the PR is written once at the beginning.
    I have tested all the posibilities in the content conversion area but I don`t find the way to achiveve that.
    Maybe, Have I to do something in the mapping program?
    Nested substructures are possible in the File Content Conversion?
    Any idea?
    Thanks for everything

    We can handle this in mapping as follows
    Crate an Intermediate structure Identical to your input structure. Just you need to add an sub element (Let’s say "T" to your CL node.
    This sub element will be used to remember CL node belongs to which PR node.
    Map your Input structure to Intermediate structure.
    While mapping PR Node of input to PR Node of Intermediate structure use a user defined function as follows
    Integer ii;
    GlobalContainer g;
    g=container.getGlobalContainer();
    Object o= g.getParameter("_&HLID");
    if (o==null) ii=new Integer(0);
    else
    ii =(Integer)o;
    ii =new Integer(ii.intValue()+1);
    g.setParameter("_&HLID",ii);
    Use another user defined function to retrieve the value of this _&HLID and put it to T as follows:
    GlobalContainer g;
    g=container.getGlobalContainer();
    Object o= g.getParameter("_&HLID");return o.toString();
    For all other fields just do a 1:1 mapping.
    Then
    Map your intermediate structure to destination structure (IDOC)
    Here the only catch is:
    For populating the value of PR for each CL
    Pass both the element T and the element of PR from which you want to pick the value to a user-defined function (raise the context of both elements to the top node).
    In array a we have the value of T
    In array b we have the value of element of PR
    int j=0;
    for(int k=0;k<b.length;k++){
    for (int i=0;i<a.length;i++)
         if (a<i>.equals(new Integer(j+1).toString())){
              System.out.println(b[j]);
         j=j+1;
    Hope this takes care of your problem.
    If you don't get anything please get back to me.
    Abinash

Maybe you are looking for