File upload program by jsf

I am doing one file upload program using
<af:inputFile label="File to Upload" columns="90"
value="#{FileProcessor.uploadedFile}"/>
component..
in Jdeveloper 11g i am getting the correct result,
but when i'm tryin to run it in Jdeveloper jdevstudio10131 it is giving this error.
java.io.EOFException: Per-request disk space limits exceeded. at oracle.adfinternal.view.faces.webapp.UploadedFileImpl.loadFile(UploadedFileImpl.java:187) at
i want this file upload application to run in ecplise..but there it is not working..do i need so some to import some jar files??
tomat 5.0 i'm using there..
Or is there any otherway to upload file using jsf component which should work in eclipse-tomcat enviornment also..
please help
thanks

Mr BalusC,
Yes Iam talking about a custom made upload component. The fileupload tutorials u send are good but my requirement is not meeting them. Among my requirements one is mutilple file uploads in the single view page. This is possible at present with my custom upload componet. Only if the problem gets solved. Any way once again please think on my problem and give your solution on it.
Here is my problem:
The problem is I have to access the components from view page which this kind of requirement possible in jsp by request parsing which results the key value pairs of the form components. This same thing/way I should get in backing bean from JSF view page.
The solution I want may like as follows.
Note this code is incorrect and wrong but for to understand my requirement.
someobject.getComponentIdValue("clientID"); which returns a string value as d:\images\Tutle.jpg
The clientID is upload file component' Id . In the request it may be the key associated with value as file complete path. By this kind of way my upload filter is able to get the orignal file. Ok i need this in my  backing bean to get the orignal filename to insert into the database. Please for this give the solution or reply.many thanx,
vijaycanaan.

Similar Messages

  • HI Masters , I need information for file upload program in web dynpro java

    Hi masters,
           i need some inforamtion and documentation on file upload program in web dynpro java

    Hi surya,
    You can follow this procedure to upload the file
    i) Take One Context Attribute named as "D1" of Type "binary".
    ii) Take one FileUpload UI Element in the Layout Tab.
    iii) Bind FileUpload UI Element's data Property to the taken Context Attribute. Here it is "D1".
    iv) Take one Button UI Element in the Layout Tab named "Upload" and in the Action of that Button write the following Code.
    v) The following code Generates one Folder in the Server & inside that Folder given file is Uploaded.
    File ff=new File("FolderXYZ"); // Creates One Folder with the given Name ( Here Folder name is "FolderXYZ")
    ff.mkdir();
    try
    byte b[]=null;
    IWDAttributeInfo objAttinfo=null;
    IWDModifiableBinaryType binType=null;
    File f=null;
    FileOutputStream fos=null;
    if(wdContext.currentContextElement().getD1()!=null)
    b=wdContext.currentContextElement().getD1();
    objAttinfo=wdContext.getNodeInfo().getAttribute(IPrivateAttachView.IContextElement.D1);
    binType=(IWDModifiableBinaryType)objAttinfo.getModifiableSimpleType();
    f=new File(ff.getName()+"
    "+binType.getFileName());
    fos=new FileOutputStream(f);
    fos.write(b);
    fos.flush();
    fos.close();
    objMessageManager.reportSuccess("File uploaded to server");
    } catch (Exception e)
    objMessageManager.reportException("Unable to upload file to server, error is:"+e,false);
    return;
    The Uploaded file is stored in the folder & that folder is stored in the Server's following Path.
    <Your Server>\c$\usr\sap\J2E\JC00\j2ee\cluster\server0
    You can access your Uploaded file from the following Path
    <Your Server>\c$\usr\sap\J2E\JC00\j2ee\cluster\server0\FolderXYZ
    Regards
    Sagar Ingalwar

  • .CSV File upload  program in CCM

    HI Gurus,
    Is there any possibility of calling file upload program from another program which should pick the file stored in server and upload as we do it in manually selecting the supplier and upload the .csv file by specifying the path.Kindly advice.
    Thanks and Regards,
    Sathya kumar.

    Hi
    I have not tried this.. But i guess it's possible.
    What's your detailed business requirement ?
    Do let me know.
    Regards
    - Atul

  • File Upload Problem in JSF

    Hi all,
    I have a problem in file upload. I have a file upload third party component which uploads the file with the filter action depending on the url. My requirement is to trace the uploaded filename for addressing it with the database record. So I need the filename in my backing bean to store it in the database. Ho can i get the filename from view page to backing bean. Any Ideas and help please.
    Many thanx,
    vijaycanaan

    Mr BalusC,
    Yes Iam talking about a custom made upload component. The fileupload tutorials u send are good but my requirement is not meeting them. Among my requirements one is mutilple file uploads in the single view page. This is possible at present with my custom upload componet. Only if the problem gets solved. Any way once again please think on my problem and give your solution on it.
    Here is my problem:
    The problem is I have to access the components from view page which this kind of requirement possible in jsp by request parsing which results the key value pairs of the form components. This same thing/way I should get in backing bean from JSF view page.
    The solution I want may like as follows.
    Note this code is incorrect and wrong but for to understand my requirement.
    someobject.getComponentIdValue("clientID"); which returns a string value as d:\images\Tutle.jpg
    The clientID is upload file component' Id . In the request it may be the key associated with value as file complete path. By this kind of way my upload filter is able to get the orignal file. Ok i need this in my  backing bean to get the orignal filename to insert into the database. Please for this give the solution or reply.many thanx,
    vijaycanaan.

  • Flat file upload program is not working

    Hi Experts,
    I am using following code to upload a flat file from my local PC to SAP
    The code is NOT inserting records in zassum, /bic/pzassum and /bic/tzassum. zassum is SAP BW infoobject. I have run debugger and found that data is getting populated correctly for ztable_data and ztable_text.
    The program is getting compiled / activated successfully. I am even getting message " ZASSUM got updated successfully ". However the issue persists.
    I am new for ABAP. I might have committed some mistake any where in the code.
    Also  pls let me know whether statement  "PERFORM update_alv_grid_display" is really needed.
    Thanks
    Smith
    FORM upload_batches.
      DATA : wf_title    TYPE string,
              lt_filetab  TYPE filetable,
              l_separator TYPE char01,
              l_action    TYPE i,
              l_count     TYPE i,
              ls_filetab  TYPE file_table,
              wf_delemt TYPE rollname,
              wa_fieldcat TYPE lvc_s_fcat,
              tb_fieldcat TYPE lvc_t_fcat,
              rows_read TYPE i,
              p_error   TYPE char01,
              l_file      TYPE string.
      TYPES : BEGIN OF test_struc,
               /bic/zassum TYPE  /bic/oizassum,
               txtmd   TYPE rstxtmd,
               END OF test_struc.
      DATA : test_upload TYPE STANDARD TABLE OF test_struc.
      DATA : wa_test_upload TYPE test_struc,
             ztable_data TYPE TABLE OF /bic/pzassum,
             ztable_text TYPE TABLE OF /bic/tzassum,
             wa_upld_text TYPE /bic/tzassum,
             wa_upld_data TYPE /bic/pzassum,
             wa_actbatch TYPE /bic/pzassum.
      wf_title = text-026.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        EXPORTING
          window_title            = wf_title
          default_extension       = 'txt'
          file_filter             = 'Tab delimited Text Files (*.txt)'
        CHANGING
          file_table              = lt_filetab
          rc                      = l_count
          user_action             = l_action
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          OTHERS                  = 3.                          "#EC NOTEXT
      IF sy-subrc <> 0.
        EXIT.
      ENDIF.
      LOOP AT lt_filetab INTO ls_filetab.
        l_file = ls_filetab.
      ENDLOOP.
      CHECK l_action = 0.
      IF l_file IS INITIAL.
        EXIT.
      ENDIF.
      l_separator = 'X'.
      wa_fieldcat-fieldname = 'test'.
      wa_fieldcat-dd_roll = wf_delemt.
      APPEND wa_fieldcat TO tb_fieldcat.
      CLEAR wa_test_upload.
    Upload file from front-end (PC)
    File format is tab-delimited ASCII
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = l_file
          has_field_separator     = l_separator
        TABLES
         data_tab                = i_mara
        data_tab                   = test_upload
        EXCEPTIONS
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          OTHERS                  = 17.
      IF sy-subrc <> 0.
        EXIT.
      ELSE.
        LOOP AT test_upload INTO wa_test_upload.
          CLEAR :  p_error.
          DESCRIBE TABLE test_upload LINES rows_read.
          IF wa_test_upload-/bic/zassum IS  INITIAL.
            p_error = 'X'.
            MESSAGE s153 WITH wa_test_upload-/bic/zassum sy-tabix.
            CONTINUE.
          ELSE.
            IF sy-subrc = 0.
            ENDIF.
          ENDIF.
          wa_upld_text-txtmd  = wa_test_upload-txtmd.
          wa_upld_text-txtsh  = wa_test_upload-txtmd.
          wa_upld_text-langu =  sy-langu.
          wa_upld_data-/bic/zassum = '11'.
          wa_upld_data-chrt_accts = 'abc'.
          wa_upld_data-co_area = '1234'.
          wa_upld_data-/bic/zbhpbcsg = 'uv'.
          wa_upld_data-objvers = 'A'.
          wa_upld_data-/bic/zass_mdl = 'pqr'.
          wa_upld_data-/bic/zass_typ = 'I'.
          wa_upld_data-/bic/zdriver = 'defg'.
          MOVE-CORRESPONDING wa_test_upload TO wa_upld_data.
          MOVE-CORRESPONDING wa_test_upload TO wa_upld_text.
          APPEND wa_upld_data TO ztable_data.
          APPEND wa_upld_text TO ztable_text.
        ENDLOOP.
        CALL FUNCTION 'MESSAGES_INITIALIZE'.
        IF ztable_data IS NOT INITIAL.
          CALL FUNCTION 'RSDMD_WRITE_ATTRIBUTES_TEXTS'
            EXPORTING
              i_iobjnm               = 'ZASSUM'
              i_tabclass             = 'M'
            TABLES
              i_t_table              = ztable_data
            EXCEPTIONS
              attribute_name_error   = 1
              iobj_not_found         = 2
              generate_program_error = 3
              OTHERS                 = 4.
          COMMIT WORK.
          IF sy-subrc <> 0.
            CALL FUNCTION 'MESSAGE_STORE'
              EXPORTING
                arbgb  = 'Zmy_prg'
                msgty  = 'E'
                txtnr  = '054'
                msgv1  = text-033
              EXCEPTIONS
                OTHERS = 3.
            CALL FUNCTION 'MESSAGE_STORE'
              EXPORTING
                arbgb  = sy-msgid
                msgty  = sy-msgty
                txtnr  = sy-msgno
                msgv1  = sy-msgv1
                msgv2  = sy-msgv2
                msgv3  = sy-msgv3
                msgv4  = sy-msgv4
              EXCEPTIONS
                OTHERS = 3.
            MESSAGE e054(z_myprg) WITH 'ZASSUM'.
          ELSE.
            CALL FUNCTION 'MESSAGE_STORE'
              EXPORTING
                arbgb  = 'Z_BM_BPS'
                msgty  = 'S'
                txtnr  = '053'
                msgv1  = text-033
              EXCEPTIONS
                OTHERS = 3.
            MESSAGE s053(z_myprg).
            IF ztable_text[] IS NOT INITIAL.
              CALL FUNCTION 'RSDMD_WRITE_ATTRIBUTES_TEXTS'
                EXPORTING
                  i_iobjnm               = 'ZASSUM'
                  i_tabclass             = 'T'
                TABLES
                  i_t_table              = ztable_text
                EXCEPTIONS
                  attribute_name_error   = 1
                  iobj_not_found         = 2
                  generate_program_error = 3
                  OTHERS                 = 4.
              IF sy-subrc <> 0.
                CALL FUNCTION 'MESSAGE_STORE'
                  EXPORTING
                    arbgb  = 'Z_myprg'
                    msgty  = 'E'
                    txtnr  = '055'
                    msgv1  = text-033
                  EXCEPTIONS
                    OTHERS = 3.
                CALL FUNCTION 'MESSAGE_STORE'
                  EXPORTING
                    arbgb  = sy-msgid
                    msgty  = sy-msgty
                    txtnr  = sy-msgno
                    msgv1  = sy-msgv1
                    msgv2  = sy-msgv2
                    msgv3  = sy-msgv3
                    msgv4  = sy-msgv4
                  EXCEPTIONS
                    OTHERS = 3.
              ENDIF.
            ENDIF.
          ENDIF.
          COMMIT WORK.
        ENDIF.
      ENDIF.
      CALL FUNCTION 'RSDG_IOBJ_DEQUEUE'
        EXPORTING
          i_objnm = 'ZASSUM'
          i_scope = '1'.
      PERFORM update_alv_grid_display.
      CALL FUNCTION 'MESSAGES_SHOW'.
    ENDFORM. " upload_batches

    .

  • File Upload program with return value

    Hello,
    I have the following code in my Java program which I use to upload files and return the value of "filename" to the original opening window. Somehow there where changes which now invalidates this piece of code and gave a javascript error message of
    "Error : Access is denied"
    "Code : 0"
    Here is the portion of the code where processing seems to stop.
    fileOut.flush();
    out.println("<script language='javascript'>");
    out.println("this.window.opener.document.frm.sign2.value='" + saveFile + "';");
    out.println("window.close()");
    out.println("</script>");
    out.println("<br> !!! File written " +
    "<br> This is an attachment confirmation page" +
    "<br> *** Please close this window ***");
    More particularly the statement --> out.println("this.window.opener.document.frm.sign2.value=" + saveFile + ";");
    As I have stated, this program worked before and returns the value to the opening window.
    Now, it can still upload but doesn't not return the saveFile to the field sign2 of the opening window.
    Any help or leads will be very helpful and appreciated.
    Thanks very much.
    Juan

    No need of ; after window.close() ?

  • Data not indexed after running HV file upload program

    hello
    we using TREX 7.1
    we rae runing CRM_MKTTG_FDS_LOAD_FILE program
    I've did a sample test with just 11 rows of data based on the original
    file I have in TREX and CRM_MKTTG_FDS_LOAD_FILE program completed and
    11 records are indexed.
    However when I run the program with the same file format with
    a much more bigger set of data, the job finished with a time out error
    and when I checked TREXADMIN, none of the data get indexed. Both sample
    file and the orginal file have the same format and both datasource
    configured the same way.
    can somebody gine us a hint? appreciate your quick respose guys!

    Hello,
    What version of LabVIEW and of Microsoft Office are you using? I recommend that you use the latest version of both, since I found a few references about this error occurring with older versions of LabVIEW. Also, there are some example VIs that ship with LabVIEW for communicating with Excel through ActiveX...have you tried those examples to see if they work? If they work, there might be a problem with your implementation of the ActiveX functions in your program.
    I hope one of these suggestions helps. Please let me know if you continue to have any problems.
    Good luck, and have a pleasant day.
    Sincerely,
    Darren Nattinger
    Applications Engineer
    National Instruments
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • File Upload problem: JSF, IBM WPS and Portlet - Please HELP Vey Very Urgent

    I want to upload a file from the front end using JSF and Portlets deployed on IBM WebSphere Portal.
    I have used Apache's commons file upload functionality as the file upload provided in JSF doesnot work with portlets and the action event is not invoked If I keep enctype="multipart/form-data". So I included 3 forms in my Faces JSP file.
    1) h:form = For displyign error message on screen
    2) html:form = Include the enctype="multipart/form-data" and the input type file for uploading. And a submit button
    3) h:form: Here I have a command link which is remotely excuted on click of sumit button in my html form. This is to invoke the action event in the pagecode to get the bean value from the context.
    Now in the my doView method in the portlet, isMultipartContent(httpservletrequest) always returns null as the content type is text/html and not multipart. Onclick of the submit button in the the html form I am calling a javascript function which sets the __LINK_TARGET__ to the command link in the 3rd h:form which will call the page code.
    The problem here is action is invoked only when I return false from the above javascript else it will trigger for the first time and from second time onwards it will not invoke the action event in the pagecode method. Whent the javascript function returns false, the content type is always text/html. However if I return "true" from the javascript the content type is multipart/form-data, but the action is not triggered for the second time. So basically when the javascript functions returns true, for the first click everything works perfectly. When it returns false, the content type is text/html, but the action is invoked in the page code every time.
    Returning always true would solve my problem with the content type, but the action with the command link will not get invoked always as its some type of problem with h:commanLink :(.
    I guess I gave too much info. Heres my code stepby step.
    Can somebody please tell me , how I should also invoke the action in the page code and get the content type as "multipart/form-data" at the same time.
    1:
    ======================= Faces JSP File: BPSMacro.jsp ====================
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <meta name="GENERATOR" content="IBM Software Development Platform">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <%@taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
    <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%>
    <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@taglib uri="http://www.ibm.com/jsf/html_extended" prefix="hx"%>
    <%@taglib uri="/WEB-INF/tld/j4j.tld" prefix="j4j"%>
    <%@taglib uri="/WEB-INF/tld/core.tld" prefix="core"%>
    <%@page language="java" contentType="text/html; charset=ISO-8859-1"
         pageEncoding="ISO-8859-1" session="false"%>
    <portlet:defineObjects />
    <link rel="stylesheet" type="text/css"
         href='<%= renderResponse.encodeURL(renderRequest.getContextPath() + "/theme/stylesheet.css") %>'
         title="Style">
    <script type="text/javascript">
    function formSubmit() {
         var formName2 = document.getElementById("proxy_form_main_").title;
         var formName1 = document.getElementById("BPSMacroFormId").title;
         document.getElementById("__LINK_TARGET__").value = document.getElementById("proxy_HD_COMMAND_").title;
         document.getElementById(formName2).submit();
         return false;
    </script>
    <f:view>
         <hx:scriptCollector id="bpsMacroScriptCollector">
              <f:loadBundle var="bps" basename="bordereauprocessingsystem" />
              <table bgcolor="#FFF9C3">
                   <tr>
                        <td><h:form id="BPSMacroFormMain" styleClass="form">
                             <table class="tablemiddle" cellspacing="0" cellpadding="0">
                                  <tr>
                                       <td><h:messages layout="table" styleClass="errormessage"
                                                 id="ValidationErrorMsg" /> </td>
                                  </tr>
                             </table>
                             <j4j:idProxy id="proxy_form_main_0_" />
                        </h:form></td>
                   </tr>
                   <tr>
                        <td>
                        <form id="BPSMacroFormId" enctype="multipart/form-data">
                        <table bgcolor="#FFF9C3">
                             <tr>
                                  <td height="36" width="324">Worksheet <input type="file"
                                       name="upfile" /></td>
                             </tr>
                                  <tr>
                                       <td align="center" width="324"><input TYPE="submit"
                                       onclick="return formSubmit();" value="Upload">
                                  </td>
                             </tr>
                        </table>
                        </form>
                        </td>
                   </tr>
                   <tr>
                        <td>
                        <h:form id="BPSMacroFormMain2" styleClass="form">
                             <table cellspacing="2" cellpadding="2" class="tablemiddle">
                                  <tbody>
                                       <tr>
                                            <td colspan="2" align="center"><h:commandLink
                                                 styleClass="commandLink" id="lnkuserdelete"
                                                 action="#{pc_BPSMacro.doIdUpload1Action}">
                                                 <hx:graphicImageEx
                                                      styleClass="graphicImageEx" id="imgBtnCreateUser"
                                                      value="/theme/images/btnUpload.gif" style="border:0;cursor:pointer"></hx:graphicImageEx>
                                                 <j4j:idProxy id="proxy_HD_COMMAND_" />
                                            </h:commandLink></td>
                                            <h:inputHidden id="dtSize"
                                                 value="#{pc_BPSMacro.fileDetailsList.clicked}">
                                                 <j4j:idProxy id="proxy_clicked_" />
                                            </h:inputHidden>
                                       </tr>
                                  </tbody>
                             </table>
                             <j4j:idProxy id="proxy_form_main_" />
                        </h:form>
                   </td>
                   </tr>
              </table>
         </hx:scriptCollector>
    </f:view>
    ================== END: FACES JSP FILE: BPSMacro.jsp ========================
    2:
    =================== Action event in the Page Code: BPSMacro.java ============
    public String doIdUpload1Action() {
              System.out.println("PageCode");
              FacesContext context = FacesContext.getCurrentInstance();
              BPSMacroDetailsDataBean fileDetails = (BPSMacroDetailsDataBean)context.getApplication().createValueBinding("#{fileDetails}").getValue(context);
              BPSMacroListDataBean fileDetailsList = (BPSMacroListDataBean)context.getApplication().createValueBinding("#{fileDetailsList}").getValue(context);
              PortletSession sess = (PortletSession)context.getExternalContext().getSession(false);
              sess.setAttribute("BPS_MACRO_CONTEXT", context, PortletSession.APPLICATION_SCOPE);
              sess.setAttribute("BPS_MACRO_FILE_DETAILS", fileDetails, PortletSession.APPLICATION_SCOPE);
              sess.setAttribute("BPS_MACRO_FILE_LIST", fileDetailsList, PortletSession.APPLICATION_SCOPE);
              HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
              boolean isMultipart = ServletFileUpload.isMultipartContent(request);
              request.getContentType();
              return "gotoBPSMacro";
    ============== END Of Page Code Action event ==============================
    3:
    ============== doView() Portlet method ================================
    public void doView(RenderRequest arg0, RenderResponse arg1)
         throws PortletException, IOException {
              String METHOD_NAME = "doView(RenderRequest arg0, RenderResponse arg1)";
              Logger.debug(this.getClass(), METHOD_NAME, "Entering BPSMacroPortlet");
              FacesContext context = FacesContext.getCurrentInstance();      
              PortletSession sess1 = arg0.getPortletSession(true);
              BPSMacroDetailsDataBean fileDetails = new BPSMacroDetailsDataBean();
              BPSMacroListDataBean fileDetailsList = new BPSMacroListDataBean();
              context = (FacesContext)sess1.getAttribute("BPS_MACRO_CONTEXT", PortletSession.APPLICATION_SCOPE);
              if(context != null){
                   fileDetails = (BPSMacroDetailsDataBean)sess1.getAttribute("BPS_MACRO_FILE_DETAILS", PortletSession.APPLICATION_SCOPE);
                   fileDetailsList = (BPSMacroListDataBean)sess1.getAttribute("BPS_MACRO_FILE_LIST", PortletSession.APPLICATION_SCOPE);
              sess1.removeAttribute("BPS_MACRO_CONTEXT", PortletSession.APPLICATION_SCOPE);
              sess1.removeAttribute("BPS_MACRO_FILE_DETAILS", PortletSession.APPLICATION_SCOPE);
              sess1.removeAttribute("BPS_MACRO_FILE_LIST", PortletSession.APPLICATION_SCOPE);
              HttpServletRequest servletRequest = (HttpServletRequest)arg0;
              PortletRequest pReq = (PortletRequest)arg0;
              HttpServletResponse servletResponse= (HttpServletResponse)arg1;
              System.out.println("\n\n Content Type" + servletRequest.getContentType());
              try{
                   if(context != null){
              boolean isFileMultipart = ServletFileUpload.isMultipartContent(servletRequest);
              System.out.println("\nFILE TO BE UPLOADED IS MULTIPART ? " + isFileMultipart);
              if(isFileMultipart){
                   FileItemFactory factory = new DiskFileItemFactory();
                   ServletFileUpload upload = new ServletFileUpload(factory);
                   List items = upload.parseRequest(servletRequest);
                   Iterator iterator = items.iterator();
                   while (iterator.hasNext()) {
                        FileItem item = (FileItem) iterator.next();
                        InputStream iStream = item.getInputStream();
                        ByteArrayOutputStream ByteArrayOS = new ByteArrayOutputStream();
                        int sizeofFile =(int) item.getSize();
                        byte buffer[] = new byte[sizeofFile];
                        int bytesRead = 0;
                        while( (bytesRead = iStream.read(buffer, 0, sizeofFile)) != -1 )
                             ByteArrayOS.write( buffer, 0, bytesRead );
                        String data = new String( ByteArrayOS.toByteArray() );
                        int k = 0;
                        //Check if the file is Refund or Premium
                        int dynamicArraySize = 0;// = st2.countTokens() * 9;
                        dynamicArraySize = st2.countTokens() * 9;
                        if (!item.isFormField() ){
                             File cfile=new File(item.getName());
                             String fileName = "";
                             String separator = "\\";
                             int pos = item.getName().lastIndexOf(separator);
                             int pos2 = item.getName().lastIndexOf(".");
                             if(pos2>-1){
                                  fileName =item.getName().substring(pos+1, pos2);
                             }else{
                                  fileName =item.getName().substring(pos+1);
                             File fileToBeUploaded=new File("C:\\Sal\\BPS MACRO\\FileTransfer\\Desti", fileName);
                             item.write(fileToBeUploaded);
                             validate.displaySuccessMessage(context);
              }catch(Exception e){System.out.println(e);
              Logger.debug(this.getClass(), METHOD_NAME, "Leaving BPSMacroPortlet");
              super.doView(arg0, arg1);
    ==== END: doView method in the portle class. ================================
    Thanks.

    one more question. Is there a way where I can submit two forms ?
    Thats is submit 2nd form only when the first form is submitted.
    I tried this it works.
    function formSubmit(){
    document.form1.submit();
    alert();
    document.form2.submit();
    But If I dont put an alert(basically it disables the parent page) in between, only the second form is submitted.
    If I put a delay of say 3 seconds in between then it will throw a SOCKET CLOSED error in the code triggered due to first form submit.
    Thus disabling the paresnt page for a few seconds is reolving my problem.
    Any ideas ?
    Well Basically when the Alert pop's up the parent page "STALLS" and thus the form2 does not submit till I click on OK, Is there a way I can stall the browser/Parent JSP page using JAVA SCRIPT ??
    Edited by: hector on Oct 9, 2007 11:09 AM
    Edited by: hector on Oct 9, 2007 2:12 PM

  • Problem using File upload in portlets

    hello there
    I'm trying to use file upload component in one of my portlets. I searched a lot about a working component to be used in portlets since the standard one that comes with JSC doesn't work in portlets. I managed to get commons file upload and tomahawk to run in my portlet, but when I choose a file and try to get selected file's details it throughs a NullPointerException reporting that the file object is null.
    so please can anyone guide me to a working portlet example, I tried to find one but I couldn't. if that's hard to find, what should I do ?
    thank you in advance

    I added file upload component in JSF from portlets in Sun Java Portal server.
    Take a look...
    portlet.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
    version="1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
    <portlet>
    <description>SFTB Anonymous Mail Portlet</description>
    <portlet-name>SFTBAnonymousMailPortlet</portlet-name>
    <display-name>SFTBAnonymousMailPortlet</display-name>
    <portlet-class>org.apache.portals.bridges.portletfilter.FilterPortlet</portlet-class>
    <init-param>
    <name>portlet-class</name>
    <value>com.sun.faces.portlet.FacesPortlet</value>
    </init-param>
    <!-- Filter for MyFaces Tomahawk extension. -->
    <init-param>
    <name>portlet-filters</name>
    <value>jp.sf.pal.tomahawk.filter.ExtensionsPortletFilter</value>
    </init-param>
    <init-param>
    <description>Portlet init page</description>
    <name>com.sun.faces.portlet.INIT_VIEW</name>
    <value>/jsp/index.jsp</value>
    </init-param>
    <supports>
    <mime-type>text/html</mime-type>
    <portlet-mode>VIEW</portlet-mode>
    <portlet-mode>EDIT</portlet-mode>
    <portlet-mode>HELP</portlet-mode>
    </supports>
    <portlet-info>
    <title>&#1054;&#1090;&#1087;&#1088;&#1072;&#1074;&#1082;&#1072; &#1087;&#1088;&#1077;&#1076;&#1083;&#1086;&#1078;&#1077;&#1085;&#1080;&#1081;</title>
    <short-title>&#1054;&#1090;&#1087;&#1088;&#1072;&#1074;&#1082;&#1072; &#1087;&#1088;&#1077;&#1076;&#1083;&#1086;&#1078;&#1077;&#1085;&#1080;&#1081;</short-title>
    </portlet-info>
    </portlet>
    </portlet-app>
    web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <display-name>SFTBAnonymousMailComment</display-name>
    <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
    </context-param>
    <context-param>
    <param-name>javax.faces.CONFIG_FILES</param-name>
    <param-value>/WEB-INF/faces-config.xml</param-value>
    </context-param>
    <!--
    Extensions filter from Apache MyFaces Tomahawk used for uploads files.
    -->
    <filter>
    <filter-name>ExtensionsFilter</filter-name>
    <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
    <init-param>
    <param-name>uploadMaxFileSize</param-name>
    <param-value>10m</param-value>
    <description>Set the size limit for uploaded files.
    Format: 10 - 10 bytes
    10k - 10 KB
    10m - 10 MB
    1g - 1 GB
    </description>
    </init-param>
    <init-param>
    <param-name>uploadThresholdSize</param-name>
    <param-value>100k</param-value>
    <description>Set the threshold size - files
    below this limit are stored in memory, files above
    this limit are stored on disk.
    Format: 10 - 10 bytes
    10k - 10 KB
    10m - 10 MB
    1g - 1 GB
    </description>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>ExtensionsFilter</filter-name>
    <servlet-name>FacesServlet</servlet-name>
    </filter-mapping>
    <servlet>
    <servlet-name>FacesServlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>FacesServlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
    </servlet-mapping>
    </web-app>
    Files in WEB-INF/lib
    commons-beanutils-1.7.0.jar
    commons-collections-3.2.jar
    commons-digester-1.8.jar
    commons-fileupload-1.2.1.jar
    commons-io-1.2.jar
    commons-logging-1.1.1.jar
    faces-response-filter-0.2.jar
    jsf-api-1.1_02.jar
    jsf-impl-1.1_02.jar
    jsf-portlet-1.1.5.jar
    jstl-1.1.0-D13.jar
    log4j-1.2.9.jar
    portals-bridges-portletfilter-1.0.jar
    standard-1.1.0-D13.jar
    tomahawk-1.1.6.jar
    tomahawk-bridge-0.9.1.jar
    Files tomahawk-bridge-0.9.1.jar, faces-response-filter-0.2.jar may be found there http://sourceforge.jp/projects/pal/
    In JSF beans I'm using org.apache.myfaces.custom.fileupload.UploadedFile
    Hope this helps.
    Bests,
    Alex Magdenko

  • HELP! File Upload Servlet and Internet Explorer

    Hello people. I hope this is an easy problem to solve...
    I have a servlet upload program that works using Mozilla browser (www.mozilla.org), but for some reason it doesn't work using Microsoft IE. The servlet is also using the servlet upload API from Apache (commons).
    I'm using IE version 6.0.2800.1106 in a Win98SE host computer. I get a cannot find path specified error message (see below). At work, I also get the same error message using IE, but don't know what version. The OS is XP. Unfortunately, at work, I can't install Mozilla browser (or any software-company policy) to see if Mozilla works there too. I would've like to have tested to see if the upload program worked on Mozilla on a truly remote computer.
    So I figured, it must be a IE configuration issue, but darn it!! I began by resetting IE to default settings, but still have the problem, I played around with several different combinations of settings in "Tools"-->"Internet Options...", and I still get the error message. Someone PLEASE HELP ME!!!
    Dunno, if it will help, I've also pasted the upload servlet source code below and the html file that's calling the upload servlet, but you still need the Apache commons file upload API.
    Trust me on this one folks, for some reason it works for Mozilla, but not for IE. With IE, I can at least access web server, and therefore, the html file that calls the upload servlet , so I don't think it's a Tomcat configuration issue (version 5.0). I actually got the code for the file upload servlet from a book relatively new in the market (printed in 2003), and it didn't mention any limitations as far as what browser to use or any browser configuration requirements. I have e-mailed the authors, but they probably get a ton of e-mails...
    Anyone suggestions?
    Meanwhile, I will try to install other free browsers and see if the file upload program works for them too.
    ERROR MESSAGE:
    "HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: C:\TOMCAT\webapps\MyWebApps\files\C:\WINDOWS\Desktop\myfile.zip (The system cannot find the path specified)
         com.jspbook.FileUploadCommons.doPost(FileUploadCommons.java:43)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    root cause
    java.io.FileNotFoundException: C:\TOMCAT\webapps\MyWebApp\files\C:\WINDOWS\Desktop\myfile.zip (The system cannot find the path specified)
         java.io.FileOutputStream.open(Native Method)
         java.io.FileOutputStream.(FileOutputStream.java:176)
         java.io.FileOutputStream.(FileOutputStream.java:131)
         org.apache.commons.fileupload.DefaultFileItem.write(DefaultFileItem.java:392)
         com.jspbook.FileUploadCommons.doPost(FileUploadCommons.java:36)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    note The full stack trace of the root cause is available in the Tomcat logs.
    Apache Tomcat 5.0.16"
    FILE UPLOAD SERVLET source code:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import org.apache.commons.fileupload.*;
    import java.util.*;
    public class FileUploadCommons extends HttpServlet {
    public void doPost(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.print("File upload success. <a href=\"/MyWebApp/files/");
    out.print("\">Click here to browse through all uploaded ");
    out.println("files.</a><br>");
    ServletContext sc = getServletContext();
    String path = sc.getRealPath("/files");
    org.apache.commons.fileupload.DiskFileUpload fu = new
    org.apache.commons.fileupload.DiskFileUpload();
    fu.setSizeMax(-1);
    fu.setRepositoryPath(path);
    try {
    List l = fu.parseRequest(request);
    Iterator i = l.iterator();
    while (i.hasNext()) {
    FileItem fi = (FileItem)i.next();
    fi.write(new File(path, fi.getName()));
    catch (Exception e) {
    throw new ServletException(e);
    out.println("</html>");
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {
    doPost(request, response);
    HTML PAGE that calls the upload servlet:
    <html>
    <head>
    <title>Example HTML Form</title>
    </head>
    <body>
    <p>Select a file to upload or browse
    currently uploaded files.</p>
    <form action="http://##.##.##.####/MyWebApp/FileUploadCommons"
    method="post" enctype="multipart/form-data">
    File: <input type="file" name="file"><br>
    <input value="Upload File" type="submit">
    </form>
    </body>
    </html>
    Thanks in advance for any assistance.
    -Dan

    I'm guessing what is happening is that Mozilla tells the servlet "here comes the file myfile.zip". The servlet builds a file name for it:
        String path = sc.getRealPath("/files");
        // path is now C:\TOMCAT\webapps\MyWebApps\files\
        fi.write(new File(path, fi.getName()));
        // append myfile.zip to "path", making it C:\TOMCAT\webapps\MyWebApps\files\myfile.zipIE, however, tells "here comes the file C:\WINDOWS\Desktop\myfile.zip". Now imagine what the path+filename ends up being...
    So what you want to do is something along the lines of (assuming Windoze):
    public static String basename(String filename)
        int slash = filename.lastIndexOf("\\");
        if (slash != -1)
            filename = filename.substring(slash + 1);
        // I think Windows doesn't like /'s either
        int slash = filename.lastIndexOf("/");
        if (slash != -1)
            filename = filename.substring(slash + 1);
        // In case the name is C:foo.txt
        int slash = filename.lastIndexOf(":");
        if (slash != -1)
            filename = filename.substring(slash + 1);
        return filename;
        fi.write(new File(path, basename(fi.getName()));
        ....You can make the file name check more bomb proof if security is an issue. Long file names trying to overflow something in the OS, NUL characters, Unicode, forbidden names in Windos (con, nul, ...), missing file name, ...

  • File upload is not perform by weblogic 10

    Hello,
    I'm working a project my root folder name is "tcap1" in that folder "test" is another folder inside that folder I place "image" folder and develop a image file upload program in JSP. when user upload his/her photo that photo should be store in image folder. I'm tested that jsp file in tomcat7.0 i.e working good and image will store in image folder.
    Other hand side I'm using Weblogic10g. I crate a war file my project and deployed in weblogic10g and run my application it is working but my fileupload.jsp is not working.how is it possible to work my code working in Tomcat7.0 but not working in Weblogic10g.
    WebLogic10g exception come on console:_
    Releasing conn back to pool
    <May 26, 2012 10:46:28 AM IST> <Error> <HTTP> <BEA-101020> <[weblogic.ser
    ternal.WebAppServletContext@1cb1d37 - appName: 'tcap1', name: 'tcap1.war'
    xt-path: '/tcap1', spec-version: '2.5'] Servlet failed with Exception
    java.lang.NullPointerException
    at java.io.File.<init>(File.java:222)
    at com.braahmam.tcap1.test.AddImageServlet.doPost(AddImageServlet
    01)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAct
    (StubSecurityHelper.java:227)
    Truncated. see log file for complete stacktrace
    >
    In JSP page error comes_
    Error 500--Internal Server Error
    java.lang.NullPointerException
         at java.io.File.(File.java:222)
         at com.braahmam.tcap1.test.AddImageServlet.doPost(AddImageServlet.java:401)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3498)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(Unknown Source)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Edited by: 936878 on May 25, 2012 11:34 PM
    Edited by: 936878 on May 25, 2012 11:35 PM
    Edited by: 936878 on May 26, 2012 12:04 AM

    I figured out the problem.
    I kept jce.jar file under bea\jdk131_06\lib\ext.
    Plus changed java.policy,java.security to look like jre1.4 poicies.
    Added local_policy.jar, US_export_policy.jar
    I found these suggestions from web for a search of "install sun JCE"
    Thanks

  • Need Tutorial about file upload

    Hi folks!
    Have anybody a link or something else to a tutorial for uploading files with JSF?
    And i mean with the "plain" JSF RI 1.2 from Sun. Google gives me a lot of Websites with Apache myFaces and myfaces extensions, but i use facelets.
    So i have to bring all the the packages together and to mutch action for my little app.
    Greetings, cpt.crispy

    Using plain JSF RI 1.2 is not possible to do what you want.That's a pity!
    So, you need to use an additional component library
    like apache tomahawk.I know that. But what does the "additional component library" do?
    Don't misunderstand me please. I want to learn how file uploads works in JSF and J2EE, not to learn some "magic" libraries.
    For most Java problems you can get "additional libraries", but sometimes it's better you make it on your own to learn how it works.
    Thanks for your reply, cpt.crispy

  • Help with file upload

    I was wondering if there's a kind of lightweight component for uploading files in JSF. I tried Oracle's ADF Faces, but besides it being a couple of megs it screwed up the HTML code in my pages and some Javascript functions wouldn't work. I saw a post here where someone created his own component but as it will have minor use in my app i'd like something packed so I can just add it on.
    I only need to upload one file in my app, so maybe it's better to use a regular JSP and Servlet approach for this one. Suggestions or comments would be appreciated, thanks..

    I followed the examples in the chapter, but I needed a .tld file so I created one:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE taglib
    PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
    "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
    <taglib>
    <tlib-version>1.0</tlib-version>
    <jsp-version>1.2</jsp-version>
    <short-name>file</short-name>
    <uri>http://java.sun.com/upload</uri>
    <display-name>JSF File Upload</display-name>
    <description>File upload library fo JSF</description>
    <tag>
    <name>upload</name>
    <tag-class>com.corejsf.UploadTag</tag-class>
    <body-content>JSP</body-content>
    <description>
    Uploads the file.
    </description>
    <attribute>
    <name>value</name>
    <required>false</required>
    <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
    <name>target</name>
    <required>false</required>
    <rtexprvalue>false</rtexprvalue>
    </attribute>
    </tag>
    </taglib>
    Its in WEB-INF and declared in web.xml, but I'm getting an error:
    javax.faces.FacesException: Expression Error: Named Object: 'com.corejsf.Upload' not found.
    There's no such class in the component, but the UploadTag returns "com.corejsf.Upload" in both getRenderedType() and getComponentType().
    If someone has this working; help please!!

  • Error while during file upload in JSF

    Hi
    I do get this error while uploading a file in JSF .
    org.apache.myfaces.webapp.filter.MultipartRequestWrapper.parseRequest(MultipartRequestWrapper.java:134)
         at org.apache.myfaces.webapp.filter.MultipartRequestWrapper.getParameter(MultipartRequestWrapper.java:163)
         at javax.servlet.ServletRequestWrapper.getParameter(ServletRequestWrapper.java:157)
         at com.sun.faces.context.RequestParameterMap.get(ExternalContextImpl.java:673)
         at jsf.PagePhaseListener.afterPhase(PagePhaseListener.java:18)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:211)
    Can anybody wat i must do

    thanks....
    but that answer is not solve my question. Actually i want to know.. can we develope a custom tag in JSF for file upload......

  • File Uploading in JSF

    I am facing problem with File Uploding. :(( Could you please provide me some pointers for this.
    If possible detailed example is good for me as I am new to JSF
    I know how to use Jakartas File Upload Component. Can you provide me some pointers regarding this in JSF.
    Thanks
    Sudhakar

    I appretiate if you could point me out to the location of file upload component in the JSC. I know how to do it in servlets - just parse mime-multipart stream, but have no idea how to implement file upload/download in the JSC.
    Thank you for your help!

Maybe you are looking for

  • Problem with PDF Output

    Hi all,i am new to Oracle Apps.Today i happen to show the PDF o/p from my form.I created the template and attached in the XML publisher responsibility.But,when i try to run the form i can't see the PDF o/p,instead i get the XML o/p.Can anyone kindly

  • HELP my wma doesn't play correct on my site

    i have a problem on my site.. www.freewebs.com/powerofnature it goes about a movie.. i was busy with programming it.. and i tested the video but it worked correct... so i programmed further.. but when i tested it again it didn't work.. when i push th

  • Can we Transport 3.x DataSource in Dev Systm to 7.0 DS in Testing Systm?

    I have a Data Source 2lis_02_itm in Development system in 3.x. The same data source is there in testing system in 7.0 version. Can I create a  transport request for the DS from deveolpment to testing. Will there be any issues? The Datasource is inact

  • Sync phone to itunes ?

    not the other way around.

  • I have a firefox 3, but can't download the 5 version, have an Apple PC.

    Since the firefox 5 is out, I try to download it, but my computer just doesn't do it, in the bottom-bar there comes a long string of symbols ending with False? I wait, then check the downloads, and nothing has happened. I went to your website, but th