Unreport exception in file upload

Hi all,
in jsp
DiskFileUpload fu = new DiskFileUpload();
List fileItems = fu.parseRequest(request);
why want I move then to servlet , I get unreport exception, why?
Thank you

You should not rephrase errors. You should know that better after hanging around here that long time.
Copypaste the actual exception type, message and stacktrace.

Similar Messages

  • Exception During File Upload

    Hi,
    I had deployed the fileupload application in weblogic & i am using apache server to access the URL.some times when i tried to upload a file, i'm getting below exception..
    +"ERROR CommonsMultipartRequestHandler - Failed to parse multipart request+
    +org.apache.commons.fileupload.FileUploadException: Processing of multipart/form-data request failed. EOF after reading only: '0' of: '46939' promised bytes, out of which at least: '0' were already buffered+
    +at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:429)+
    +at org.apache.struts.upload.CommonsMultipartRequestHandler.handleRequest(CommonsMultipartRequestHandler.java:233)+
    +at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1209)+
    +at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)+
    +at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)+
    +at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)+
    +at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)+
    +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)+
    +"+Can anyone helpme ...?
    Thanks !!!!

    Here is a common tag that is used to upload a file:
    <input type="file">
    Also, have you tried to upload a simple (text) file using your method. Then a file that has simple context but is about the size of the file you have problems with. Then, the file you are trying to upload.
    That will determine if its your upload method, a problem with the size of the file, or something funny about the content of that particular file (perhaps its corrupt).

  • Java Exception after File Upload while retreiving using Filepath

    Hello everyone,
    I am performing the following steps:-
    1) I am uploading a file from my local File system (D:/ a.XML) using FileUpload UI Element in Web Dynpro.
    2) In the OnActionMethod of the View, I am trying to get the content of the file using the Filepath (D:/ a.XML).
    But I am getting a Java Exception "No Such File or Directory" after deploying the archive and run on to the remote server.
    The Exception is  not a Web Dynpro Runtime Exception. But I am able to catch it in the try, catch block of the Java code.
    Do I need the file to be present in the server as well. What is the Solution? Please advise me about, where is the content of the uploaded XML file stored and how can it be retrieved.
    How can I retrieve the content of the file using a valid file path, because my method which will open the uploaded file requires argument as a filepath. Please suggest about this problem. I would be very thankful for your help.
    Kind Regards,
    Phani.
    Edited by: Armin Reichert on Apr 18, 2008 2:43 PM

    Hi Ayyaparaj,
    Please have a look at the code that I am using for my application. I am getting the exception method after the load method i.e after this line of code "msgMgr.reportSuccess("\n\nInit0\n\n");". The exception that I am getting is "Invalid Stream Header".
      public void onActionMaximalJoin(
          com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent)
        // @@begin onActionMaximalJoin(ServerEvent)
        MessageManager msgMgr = (MessageManager) wdThis.wdGetAPI().getComponent()
            .getMessageManager();
        InputStream text = null;
        int temp = 0;
        try
          File file = new File(wdContext.currentContextElement().getUploadXML()
              .getResourceName().toString());
          FileOutputStream op = new FileOutputStream(file);
          if (wdContext.currentContextElement().getUploadXML() != null)
            text = wdContext.currentContextElement().getUploadXML().read(false);
            while ((temp = text.read()) != -1)
              op.write(temp);
          op.flush();
          op.close();
          String path = file.getAbsolutePath();
          wdComponentAPI.getMessageManager().reportSuccess(path);
          Ontology ontology = new Ontology();
          msgMgr.reportSuccess("\n\nInit0\n\n");
          ontology = Ontology.load(path);
          Lexicon mainLexicon = ontology.getMainLexicon();
          msgMgr.reportSuccess("\n\nInit1\n\n");
          text = null;
          temp = 0;
          File file1 = new File(wdContext.currentContextElement().getUploadGraph1()
              .getResourceName().toString());
          FileOutputStream op1 = new FileOutputStream(file1);
          if (wdContext.currentContextElement().getUploadGraph1() != null)
            text = wdContext.currentContextElement().getUploadGraph1().read(false);
            while ((temp = text.read()) != -1)
              op1.write(temp);
          op1.flush();
          op1.close();
          String path1 = file1.getAbsolutePath();
          wdComponentAPI.getMessageManager().reportSuccess(path1);
          CG cg1 = new CG();
          msgMgr.reportSuccess("\n\nInit2\n\n");
          cg1 = CG.load(path1);
          text = null;
          temp = 0;
          File file2 = new File(wdContext.currentContextElement().getUploadGraph2()
              .getResourceName().toString());
          FileOutputStream op2 = new FileOutputStream(file2);
          if (wdContext.currentContextElement().getUploadGraph2() != null)
            text = wdContext.currentContextElement().getUploadGraph2().read(false);
            while ((temp = text.read()) != -1)
              op2.write(temp);
          op2.flush();
          op2.close();
          String path2 = file1.getAbsolutePath();
          wdComponentAPI.getMessageManager().reportSuccess(path2);
          CG cg2 = new CG();
          msgMgr.reportSuccess("\n\nInit3\n\n");
          cg2 = CG.load(path2);
          CG maximalJoinResult = (CG) cg1.maximalJoin(cg2);
          StringBuffer output = new StringBuffer();
          output.append(maximalJoinResult.toString(mainLexicon));
          msgMgr.reportSuccess("\n\nInit4\n\n");
          System.out.println(output.toString());
          msgMgr.reportSuccess("\n\nInit5\n\n");
          msgMgr.reportSuccess(output.toString());
          msgMgr.reportSuccess("\n\nInit6\n\n");
        catch (Exception e)
          msgMgr.reportSuccess(e.getMessage());
        // @@end
    Please advise me if you find any mistake.
    Edited by: Armin Reichert on Apr 9, 2008 1:27 PM

  • Exception on File uploading ...?

    Hi,
    We haev developed web application ,which provides options to upload file/videos/images to end users .
    I am able to upload ll types of Stuff on my local system project , but when i try to upload that stuff into website then i am getting the below Exception please check it ........
    let me know what main cause to arrise below exception ASAP ....?
    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: javax/servlet/jsp/SkipPageException
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:273)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    root cause
    java.lang.NoClassDefFoundError: javax/servlet/jsp/SkipPageException
         org.apache.jsp.uploaddocs2_jsp._jspService(uploaddocs2_jsp.java:380)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.25 logs.
    Apache Tomcat/5.5.25

    j_guru wrote:
    hoo the server is conecting to class if the file size is less than 100kb and file will uploads into server .
    when i try to upload file more 100kb its not connecting to the database also ....whats the reason ...?.Either your code logic is wrong, or you tested it the wrong way.
    What API are you using to upload a file? For example the Apache Commons FileUpload API or some homegrown stuff? If the first, please post the related code (yes, only the RELATED code), so that we can try to reproduce it. If the second, please throw it away and use a real, reliable and thoroughly tested API instead. No one can write a better multipart/form-data parser than the FileUpload API already did. It is really not worth the effort to try to reinvent the wheel.

  • Error "A web exception has occurred during file upload" when trying to import ESXi image file into Update Manager

    I'm encountering this error and not sure how to fix, I'm quite new to vCenter so please bear with me.
    I'm trying out vCenter 5.1 with Update Manager 5.1 right now.  No license key has been entered and I still have 50 odd days to try it out.
    2 ESXi hosts are being managed by this vCenter, and they're both running ESXi 4.0
    I'm looking to use Update Manager to try to upgrade the ESXi 4.0 hosts to ESXi 5.1
    I downloaded the image file VMware-VIMSetup-all-5.1.0-799735.iso from VMWare website, and is looking to import it using the Update Manager so I can update the ESXi hosts, but I keep on getting the error:
    File name:     VMware-VIMSetup-all-5.1.0-799735.iso
    Failed to transfer data
    Error was: A web exception has occurred during file upload
    I tried importing it by using vSphere client to connect to vCenter server both remotely and locally, with firewall disabled.
    I've read http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1026602
    I've disabled firewall, and there is no anti-virus program on the server.  I've also restarted the machine several times, to no avail, I didn't reinstall update manager because the whole Windows and VCenter installations are clean from scratch.
    I logged into the vSphere Client using Active Directory credentials, and I've made all Domain Admins (which my account is a member of) part of the administrator group on the vCenter server. I can't log in using admin@System-Domain because it tells me I don't have permissions for it, I still haven't really had the chance to figure out why that is and not sure if that makes a difference.
    Also, I'm fairly certain I'm using the right image file, as I've burned some DVD's used that image file to upgrade some other ESXi hosts.  Unless there's a special image file I need to download?
    I'm at lost on what I can do to make it work.  Please advise.
    Thanks.

    The ISO file you mentioned is the one for vCenter Server. What you need is the "VMware-VMvisor-Installer-5.1.0-799733.x86_64.iso" (or VMware-VMvisor-Installer-201210001-838463.x86_64.iso) for the ESXi host.
    André

  • File upload in KM throws a system exception: java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key xtlt_Required

    Hi All,
    We are on Netweaver 7.01 SP14. (well I understand we are way behind patch levels, but a simple file upload should be working ?/)
    We are trying to upload (HTML &/ Image) a file in one of the KM's public folder.
    As and when we select folder and click on upload we get the below message:
    Below is the error trace details:
    Full Message Text
    com.sapportals.wdf.WdfException
    at com.sapportals.wcm.control.edit.ResourceUploadControl.render(ResourceUploadControl.java:688)
    at com.sapportals.wdf.layout.HorizontalLayout.renderControls(HorizontalLayout.java:42)
    at com.sapportals.wdf.stack.Pane.render(Pane.java:155)
    at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:73)
    at com.sapportals.wdf.layout.HorizontalLayout.renderPanes(HorizontalLayout.java:73)
    at com.sapportals.wdf.stack.Pane.render(Pane.java:158)
    at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:73)
    at com.sapportals.wdf.layout.HorizontalLayout.renderPanes(HorizontalLayout.java:73)
    at com.sapportals.wdf.stack.Pane.render(Pane.java:158)
    at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:73)
    at com.sapportals.wdf.layout.HorizontalLayout.renderPanes(HorizontalLayout.java:73)
    at com.sapportals.wdf.stack.Pane.render(Pane.java:158)
    at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:73)
    at com.sapportals.wdf.WdfCompositeController.internalRender(WdfCompositeController.java:709)
    at com.sapportals.wdf.WdfCompositeController.buildComposition(WdfCompositeController.java:674)
    at com.sapportals.htmlb.AbstractCompositeComponent.preRender(AbstractCompositeComponent.java:33)
    at com.sapportals.htmlb.Container.preRender(Container.java:120)
    at com.sapportals.htmlb.Container.preRender(Container.java:120)
    at com.sapportals.htmlb.Container.preRender(Container.java:120)
    at com.sapportals.portal.htmlb.PrtContext.render(PrtContext.java:408)
    at com.sapportals.htmlb.page.DynPage.doOutput(DynPage.java:238)
    at com.sapportals.wcm.portal.component.base.KMControllerDynPage.doOutput(KMControllerDynPage.java:134)
    at com.sapportals.htmlb.page.PageProcessor.handleRequest(PageProcessor.java:133)
    at com.sapportals.portal.htmlb.page.PageProcessorComponent.doContent(PageProcessorComponent.java:134)
    at com.sapportals.wcm.portal.component.base.ControllerComponent.doContent(ControllerComponent.java:88)
    at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
    at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
    at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
    at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:215)
    at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:645)
    at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
    at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:753)
    at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:249)
    at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:557)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:430)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
    at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:386)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:364)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:1064)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:265)
    at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
    at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
    at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
    at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
    at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:104)
    at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:176)
    --- Nested WDF Exception -----------------------
    java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key xtlt_Required
    at java.util.ResourceBundle.getObject(ResourceBundle.java:327)
    at java.util.ResourceBundle.getObject(ResourceBundle.java:324)
    at java.util.ResourceBundle.getString(ResourceBundle.java:287)
    at com.sapportals.wcm.util.resource.ResourceBundles.getString(ResourceBundles.java:55)
    at com.sapportals.wcm.control.base.WcmBaseControl.getBaseBundleString(WcmBaseControl.java:150)
    at com.sapportals.wcm.control.base.WcmBaseControl.getBaseBundleString(WcmBaseControl.java:176)
    at com.sapportals.wcm.control.edit.ResourceUploadControl.renderUploadFileContent(ResourceUploadControl.java:773)
    at com.sapportals.wcm.control.edit.ResourceUploadControl.render(ResourceUploadControl.java:655)
    at com.sapportals.wdf.layout.HorizontalLayout.renderControls(HorizontalLayout.java:42)
    at com.sapportals.wdf.stack.Pane.render(Pane.java:155)
    at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:73)
    at com.sapportals.wdf.layout.HorizontalLayout.renderPanes(HorizontalLayout.java:73)
    at com.sapportals.wdf.stack.Pane.render(Pane.java:158)
    at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:73)
    at com.sapportals.wdf.layout.HorizontalLayout.renderPanes(HorizontalLayout.java:73)
    at com.sapportals.wdf.stack.Pane.render(Pane.java:158)
    at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:73)
    at com.sapportals.wdf.layout.HorizontalLayout.renderPanes(HorizontalLayout.java:73)
    at com.sapportals.wdf.stack.Pane.render(Pane.java:158)
    at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:73)
    at com.sapportals.wdf.WdfCompositeController.internalRender(WdfCompositeController.java:709)
    at com.sapportals.wdf.WdfCompositeController.buildComposition(WdfCompositeController.java:674)
    at com.sapportals.htmlb.AbstractCompositeComponent.preRender(AbstractCompositeComponent.java:33)
    at com.sapportals.htmlb.Container.preRender(Container.java:120)
    at com.sapportals.htmlb.Container.preRender(Container.java:120)
    at com.sapportals.htmlb.Container.preRender(Container.java:120)
    at com.sapportals.portal.htmlb.PrtContext.render(PrtContext.java:408)
    at com.sapportals.htmlb.page.DynPage.doOutput(DynPage.java:238)
    at com.sapportals.wcm.portal.component.base.KMControllerDynPage.doOutput(KMControllerDynPage.java:134)
    at com.sapportals.htmlb.page.PageProcessor.handleRequest(PageProcessor.java:133)
    at com.sapportals.portal.htmlb.page.PageProcessorComponent.doContent(PageProcessorComponent.java:134)
    at com.sapportals.wcm.portal.component.base.ControllerComponent.doContent(ControllerComponent.java:88)
    at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
    at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
    at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
    at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:215)
    at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:645)
    at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
    at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:753)
    at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:249)
    at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:557)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:430)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
    at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:386)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:364)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:1064)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:265)
    at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
    at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
    at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
    at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
    at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:104)
    at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:176) 

    Hi Vijay,
    Thanks for the quick reply.
    I have gone through the notes 1535201  & now on 1606563  after your advise.
    Both the notes says the fix is available on 7.01 after SP 07 and we are on SP 14 already.
    Also just in case I did checked with our basis and they confirmed we are a head and we have the above notes in our release already.
    Unfortunately the notes are not the solution to the investigation till date.
    Thanks,
    Sai

  • Exception while excel processing after upload using commons file upload

    Hi all,
    I am experiencing problem while creating a workbook after getting the input stream from the uploaded file. its not going catch block instead it is going to finally and giving null pointer exeption in finally as one variable in finally is not defined. the variable is defined in try as well as catch but during run time the variable is not getting assigned any value also. I'll put the code over here. please help me with a solution
    import org.w3c.dom.* ;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import jxl.*;
    import org.apache.commons.fileupload.*;
    import org.apache.commons.fileupload.disk.*;
    import org.apache.commons.fileupload.servlet.*;
    import org.apache.poi.poifs.filesystem.POIFSFileSystem;
    import org.apache.poi.hssf.usermodel.HSSFCell;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    public class CescoreUploadServlet extends baseHttpServlet
         private DataSource cesDS = null;
         public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
              doPost(req, res);
         public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
              String targetPage = null;
              File f = null;
              System.out.println("Upload Controller");
              HttpSession session = req.getSession(true);
              try
                   if(cesDS == null){
                        cesDS = new JNDIDataSource(getServletContext().getInitParameter(Constants.DATA_SOURCE_NAME));
                   CesRepository cRep = new CesRepository(cesDS);
                   if (session.getAttribute("DataContainerInfo") == null) {
                        System.out.println("Initializing DataContainerInfo");
                        DataContainer DataContainer = new DataContainer();
                        cRep.setInitialParameters(DataContainer);
                        session.setAttribute("DataContainerInfo",DataContainer);
                   else System.out.println("DataContainerInfo is available");
                   UserInfo userInfo = null;               
                   String login_id = req.getRemoteUser();
                   if(session.getAttribute("UserID") != null) login_id = (String)session.getAttribute("UserID");
                   if(session.getAttribute("userProfile") == null ) session.setAttribute("userProfile", cRep.getUserInfo(login_id));
                   userInfo = (UserInfo)session.getAttribute("userProfile");
                   System.out.println("<<<<<< userInfo contains : "+userInfo.getHrID()+" >>>>>>");
                   String projIdValue = null;
                   String msg = null;
                   boolean isMultipart = FileUpload.isMultipartContent(req);
                   if(isMultipart){
                        System.out.println("is MultiPart");
                        DiskFileUpload upload = new DiskFileUpload();
                        List fileList = upload.parseRequest(req);
                        InputStream uploadedFileStream = null;
                        String uploadedFileName = null;
                        ArrayList impArray = new ArrayList();
                        Iterator iter = fileList.iterator();
                        while (iter.hasNext()) {
                             System.out.println("inside while");
                             FileItem item = (FileItem) iter.next();
                             if (!item.isFormField()) {
                                  System.out.println("item is not form field");
                                  if (item.getSize() < 1)
                                       throw new Exception("No file was uploaded");
                                  else
                                       uploadedFileName = item.getName();
                                       System.out.println("uploaded file name "+uploadedFileName);
                                       System.out.println("uploaded file size is "+item.getSize());
                                       uploadedFileStream = item.getInputStream();
                                       System.out.println("uploaded input stream available size is "+uploadedFileStream.available());
                             else
                                  System.out.println("item is form field");
                                  String key     = item.getFieldName();
                                  String value = item.getString();
                                  System.out.println("key is"+key);
                                  System.out.println("value is"+value);
                                  if(key.equals("projectId2")){
                                       projIdValue = value;
                        System.out.println("outside while");
                        POIFSFileSystem fs = new POIFSFileSystem(uploadedFileStream);
                        System.out.println("got POIFSFileSystem");//this is been printed in logs
                        HSSFWorkbook wb = new HSSFWorkbook(fs);//it is breaking over here
                        System.out.println("got HSSFWorkbook");//this is not been printed in logs
                        HSSFSheet sheet = wb.getSheetAt(0);
                        System.out.println("got HSSFSheet");
                        Iterator rows = sheet.rowIterator();
                        if(rows.hasNext()){
                        while( rows.hasNext() ) {
                             System.out.println("rows iteration");
                             HSSFRow row = (HSSFRow) rows.next();
                             Iterator cells = row.cellIterator();
                             while( cells.hasNext() ) {
                                  System.out.println("cell iteration");
                                  HSSFCell cell = (HSSFCell) cells.next();
                                  HashMap hm = new HashMap();//if everything is fine i'll use this hashmap to store values
                             System.out.println("CES UPLOAD.SERVLET. After adding");
                             msg = "Attendees have been added successfully";
                             req.setAttribute("msgText", msg);
                             targetPage = "/ces_disp.jsp";
                        else
                             throw new Exception("The Excel Sheet Uploaded has no entries. Please check and try again");
                   else{
                        throw new Exception("The Form is not Multipart");
              catch (Exception e)
                   System.out.println("CES UPLOAD.SERVLET.EXCEPTION ::: Exception");
                   targetPage = "/ces_disp.jsp";
                   if(e != null) req.setAttribute("msgText", e.getMessage());
                   else req.setAttribute(Constants.EXCEPTION_ATTR_NAME, new Exception("Unknown Exception"));
                   e.printStackTrace();
              finally{
                   System.out.println("CES UPLOAD.SERVLET. ::: Finally");
                   ServletContext stx = getServletConfig().getServletContext();
                   RequestDispatcher dispatcher = sCx.getRequestDispatcher(targetPage);
                   dispatcher.forward(req, res);
    Message was edited by: Noufal
    Noufal_k
    Message was edited by:
    Noufal_k

    import org.w3c.dom.* ;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import jxl.*;
    import org.apache.commons.fileupload.*;
    import org.apache.commons.fileupload.disk.*;
    import org.apache.commons.fileupload.servlet.*;
    import org.apache.poi.poifs.filesystem.POIFSFileSystem;
    import org.apache.poi.hssf.usermodel.HSSFCell;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    public class CescoreUploadServlet extends baseHttpServlet
    private DataSource cesDS = null;
    public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    doPost(req, res);
    public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    //including only relevant code
    String targetPage = null;
    System.out.println("Upload Controller");
    HttpSession session = req.getSession(true);
    try
    String projIdValue = null;
    String msg = null;
    boolean isMultipart = FileUpload.isMultipartContent(req);
    if(isMultipart){
    System.out.println("is MultiPart");
    DiskFileUpload upload = new DiskFileUpload();
    List fileList = upload.parseRequest(req);
    InputStream uploadedFileStream = null;
    String uploadedFileName = null;
    Iterator iter = fileList.iterator();
    while (iter.hasNext()) {
    System.out.println("inside while");
    FileItem item = (FileItem) iter.next();
    if (!item.isFormField()) {
    System.out.println("item is not form field");
    if (item.getSize() < 1)
    throw new Exception("No file was uploaded");
    else
    uploadedFileName = item.getName();
    System.out.println("uploaded file name "+uploadedFileName);//printing  c:/excelsheets/fileToUpload.xls
    System.out.println("uploaded file size is "+item.getSize());//printing size is 15872
    uploadedFileStream = item.getInputStream();
    System.out.println("uploaded input stream available size is "+uploadedFileStream.available());//printing available input stream size is 15872
    else
    System.out.println("item is form field");
    String key = item.getFieldName();
    String value = item.getString();
    System.out.println("key is"+key);
    System.out.println("value is"+value);
    if(key.equals("projectId2")){
    projIdValue = value;
    System.out.println("outside while");
    POIFSFileSystem fs = new POIFSFileSystem(uploadedFileStream);
    System.out.println("got POIFSFileSystem");//this is been printed in logs
    HSSFWorkbook wb = new HSSFWorkbook(fs);//it is breaking over here
    System.out.println("got HSSFWorkbook");//this is not been printed in logs
    HSSFSheet sheet = wb.getSheetAt(0);
    System.out.println("got HSSFSheet");
    Iterator rows = sheet.rowIterator();
    if(rows.hasNext()){
    while( rows.hasNext() ) {
    System.out.println("rows iteration");
    HSSFRow row = (HSSFRow) rows.next();
    Iterator cells = row.cellIterator();
    while( cells.hasNext() ) {
    System.out.println("cell iteration");
    HSSFCell cell = (HSSFCell) cells.next();
    HashMap hm = new HashMap();//if everything is fine i'll use this hashmap to store values
    System.out.println("CES UPLOAD.SERVLET. After adding");
    msg = "Attendees have been added successfully";
    req.setAttribute("msgText", msg);
    targetPage = "/ces_disp.jsp";
    else
    throw new Exception("The Excel Sheet Uploaded has no entries. Please check and try again");
    else{
    throw new Exception("The Form is not Multipart");
    catch (Exception e)
    System.out.println("CES UPLOAD.SERVLET.EXCEPTION ::: Exception");
    targetPage = "/ces_disp.jsp";
    if(e != null) req.setAttribute("msgText", e.getMessage());
    else req.setAttribute(Constants.EXCEPTION_ATTR_NAME, new Exception("Unknown Exception"));
    e.printStackTrace();
    finally{
    System.out.println("CES UPLOAD.SERVLET. ::: Finally");
    ServletContext stx = getServletConfig().getServletContext();
    RequestDispatcher dispatcher = stx.getRequestDispatcher(targetPage);//throwing null pointer exception for this line
    dispatcher.forward(req, res);
    }

  • Multiple file uploads, or only one at a time?

    I have multiple files in folders on my iPad.  I want to upload entire folders of documents.  So far I have only been able to upload one document at a time.  Then after uploading, I have to put them in acrobat.com folders one document at a time.  It is very time consuming.  Is there any way to upload multiple files at one time?  Once the documents are uploaded, is it possible to move multiple documents into a folder at one time?  Or does each document have to be a separate upload action, and each move into folder a separate document-by-document one at a time?

    On my iPad I have been opening and saving pdf's in Adobe Reader.  I would like to upload these pdf files from the iPad Adobe Reader to acrobat.com.  I have thus far been uploading them from the iPad one fie at a time.  It is very slow and tedious.  There is also no way to get multiple pdf files from the iPad Adobe Reader to a computer except one file at a time.  So it seems that once I used the iPad Adobe Reader app to save the files, I am stuck with one file at a time movement.  I did, however, find that once I get files to acrobat.com, I can move multiples files at a time into folders on acrobat.com via the iPad.  The problem is getting them uploaded from the iPad Adobe Reader app to acrobat.com. Is there a solution I'm missing, or am I correct in my understanding of the iPad Adobe Reader app upload situation?

  • FILE UPLOAD PROBLEM SHOWING THE CONTENTS IN THE SAME BROWSER WINDOW

    Hi,
    This is amit Joshi
    I have uploaded content using input tag of type file and posted to jsp as multipart/form-data type
    in that jsp i am using following code to display the content in browser but only first content is displayed How can i modify it to show all content in the file ..
    <html>
    <head>
    <title>File Upload Display</title>
    </head>
    <body>
    <%
    //ServletOutputStream sout=response.getOutputStream();
    StringBuilder strBuilder = new StringBuilder();
    int count=0;
    String f;
    f=request.getParameter("filedb");
    DBManager dbm = new DBManager();
    //dbm.createTable("mms3");
    //log.info("In JSP : "+ f);
    //dbm.insert_data(f,"mms3");
    %>
    <%
    if (ServletFileUpload.isMultipartContent(request)){
    ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
    List fileItemsList = servletFileUpload.parseRequest(request);
    strBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>").append('\r').append('\n').append("<xpage version=\"1.0\">").append('\r').append('\n');
    String optionalFileName = "";
    FileItem fileItem = null;
    Iterator it = fileItemsList.iterator();
    ServletOutputStream outputStream=null;
    while (it.hasNext()){
    FileItem fileItemTemp = (FileItem)it.next();
    if (fileItemTemp.isFormField()){
    %>
    <b>Name-value Pair Info:</b>
    Field name: <%= fileItemTemp.getFieldName() %>
    Field value: <%= fileItemTemp.getString() %>
    <%
    if (fileItemTemp.getFieldName().equals("filename"))
    optionalFileName = fileItemTemp.getString();
    else
    fileItem = fileItemTemp;
    if (fileItem!=null){
    String fileName = fileItem.getName();
    %>
    <b>Uploaded File Info:</b>
    Content type: <%= fileItem.getContentType() %>
    Field name: <%= fileItem.getFieldName() %>
    File name: <%= fileName %>
    <%
    if(fileItem.getContentType().equals("image/jpeg")) { %>
    File : <p><%
         //response.setContentType("image/gif");
         byte[] bArray=fileItem.get();
         response.setContentType("image/jpeg");
         outputStream=null;
         outputStream= response.getOutputStream();
         outputStream.write(bArray);
         outputStream.flush();
         outputStream.close();
    else if(fileItem.getContentType().equals("text/plain"))
         %> File : <%= fileItem.getString() %>
    <%
    byte[] bArray=fileItem.get();
    response.setContentType("text/plain");
         outputStream = response.getOutputStream();
         out.println();
         outputStream.write(bArray);
         outputStream.flush();
         outputStream.close();
    %> </p> <%
    %>
    </body>
    </html>
    Edited by: Amit_Joshi on Nov 13, 2007 10:58 PM

    Well Well Well..
    That would not work...
    What you have to do is save the uploaded file content on to a location and then pass the fileName as a request parameter to a deidicated which displays the contents of that file.
    Just as an example
    <html>
    <head>
    <title>File Upload Display</title>
    </head>
    <body>
    <%
    //ServletOutputStream sout=response.getOutputStream();
    StringBuilder strBuilder = new StringBuilder();
    int count=0;
    String f;
    f=request.getParameter("filedb");
    DBManager dbm = new DBManager();
    //dbm.createTable("mms3");
    //log.info("In JSP : "+ f);
    //dbm.insert_data(f,"mms3");
    %>
    <%
    if (ServletFileUpload.isMultipartContent(request)){
    ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
    List fileItemsList = servletFileUpload.parseRequest(request);
    strBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>").append('\r').append('\n').append("<xpage version=\"1.0\">").append('\r').append('\n');
    String optionalFileName = "";
    FileItem fileItem = null;
    Iterator it = fileItemsList.iterator();
    ServletOutputStream outputStream=null;
    while (it.hasNext()){
       FileItem fileItemTemp = (FileItem)it.next();
    %>
    Name-value Pair Info:
    Field name: <%= fileItemTemp.getFieldName() %><br/>
    Field value: <%= fileItemTemp.getString() %><br/>
    <%
    if (fileItemTemp.getFieldName().equals("filename"))
        optionalFileName = fileItemTemp.getString();
    if(!fileTempItem.isFormFiled()){
       String fileName = fileItem.getName();
       fileItem.write(optionalFileName);
    %>
    Uploaded File Info:
    Content type: <%= fileItem.getContentType() %><br/>
    Field name: <%= fileItem.getFieldName() %><br/>
    File name: <%= fileName %><br/>
    <%
    if(fileItem.getContentType().equals("image/jpeg") || fileItem.getContentType().equals("image/pjeg")) {
    %>
      <img src="FileServlet?fileName=<%=optionalFileName%>"   
    <%
    %>
    </body>
    </html>a sample code snippet for FileServlet.
    String fileName =  request.getParameter(fileName);
      File file = new File(fileName);
       if(!file.exists())
         return;
      // If JSP
      String mimeType = application.getMimeType("fileName");
           If you are using servlet
           String mimeType = this.getServletContext().getMimeType(fileName);
         response.setContentType(mimeType);  
         response.setHeader("Content-Disposition","inline;filename=\\"+fileName+"\\");
      BufferedOutputStream out1 = null;
      InputStream in = null;
      if(mimeType == null)
         mimeType = "application/octet-stream";
      try{
         in = new FileInputStream(f);
         response.setContentLength(in.available());
         BufferedOutputStream out1 = new BufferedOutputStream(response.getOutputStream(),1024);
         int size = 0;
         byte[] b = new byte[1024];
         while ((size = in.read(b, 0, 1024)) > 0)
            out1.write(b, 0, size);
      }catch(Exception exp){
      }finally{
          if(out1 != null){
             try{
                out1.flush();               
                out1.close();
             }catch(Exception e){}
          if(in != null){
            try{in.close();}catch(Exception e){}
      } Hope that might answer your question :)
    However,this is not the recommended way of doing this make use of MVC pattern.Would be a better approach.
    you might think of googling on this and can findout what is the best practise followed for problems of this sort
    REGARDS,
    RaHuL

  • Unable to get the filename from file upload UI element

    Hi,
    I added a FileUpload UI element.
    I created an attribute of type resource , assigned to the resource property of the file upload element.
    I created an action button called upload and added the following code.
    try {
           IWDResource resource = wdContext.currentContextElement().getFileupload();
          } catch (Exception e) {
             e.printStackTrace();
    when I debug to see the value of resource it is null.
    Please let me know where I am going wrong.
    Regards,
    Narayani

    Hi,
    Check if there are any space characters in your uploading path (file path).
    First try to upload a file without any space characters in the uploading path(file path). If the problem is with the space characters then use the below encoding & decoding to resolve that issue.
    Encoding while uploading the file:
    // Getting the file resource
    IWDResource resource = element.getCtx_va_FileResource();
    //Getting the resource name
    String resourceName = resource.getResourceName();
    //Encoding the resource name
    String encoderesourceName = java.net.URLEncoder.encode(resourceName,"UTF-8");
    Again while downloading you can use decoder.
    Hope this helps to resolve your issue.
    See this below link.
    Re: File Upload Problem
    Try this encoding even if there are no space characters.
    Regards,
    Charan

  • File Upload.. Strange Problem..

    im trying to read file data and print it in the browser. I dont want to save the file. just to read the uploaded file which is TAB delimited..
    First time it works fine. but If I browse back button and reload another file and submit. I am getting content of first file and second file. I closed the browser and reopened it but still problem is not resolved. it keeps on adding file content instead of showing current uploaded file. I dont know what to do.
    here is my code
    upload.html
    <html>
    <head>
    <title>File Upload Form</title>
    </head>
    <body>
    Upload File using this..
    <FORM METHOD="POST" ENCTYPE="multipart/form-data" action="uploadFile.jsp">
    File: <input type="file" name="file"><br>
    <input value="Submit" type="submit">
    </form>
    </body>
    </html>
    UploadFile.jsp
    =============
    <%@page language="java" import="java.io.*" %>
    <%@page language="java" import="java.util.*" %>
    <%!
    private BufferedInputStream bis = null;
    int MAX_LINES = 2000;
    private String currentLine = "";
    //private String[] PartNumber;
    //private String[] Quantity;
    public int disp_counter = 0;
    public int mime_counter = 0;
    public int boundary_counter = 0;
    private String content_diposition = null;
    private HttpServletRequest request;
    private javax.servlet.jsp.JspWriter mOut;
    The incoming request needs to be an InputStream before it can be parsed. This method creates an InputStream from the request. The
    request contains the uploaded file contents
    public void setInputStream(HttpServletRequest request, JspWriter _out)throws IOException {
    try{
    bis = new BufferedInputStream(request.getInputStream());
    } catch(IOException e){
    e.printStackTrace();
    this.request = request;
    this.mOut = _out;
    //mOut.println("After setting input Stream<br>");
    private int getRealContentLength() throws Exception
    boundary_counter = readBoundaryLength(bis);
    content_diposition = readContentDisposition(bis);
    //mOut.println(" getRealContentLength() content_diposition ="+content_diposition+"<br>");
    mime_counter = readUntilBody(bis);
    int tmpContentLength = getContentLength();
    int retLength;
    mOut.println(" getRealContentLength() boundary_counter ="+boundary_counter+"<br>");
    mOut.println(" getRealContentLength() content_diposition ="+content_diposition+"<br>");
    mOut.println(" getRealContentLength() disp_counter ="+disp_counter+"<br>");
    mOut.println(" getRealContentLength() mime_counter ="+mime_counter+"<br>");
    mOut.println(" getRealContentLength() tmpContentLength ="+tmpContentLength+"<br>");
    retLength = getContentLength()-boundary_counter-2-mime_counter-disp_counter;
    return retLength;
    private int readBoundaryLength(BufferedInputStream fis) throws Exception{
    //mOut.println("---- Inside readBoundaryLength ----<br>");
    StringBuffer sb = new StringBuffer();
    byte[] b = new byte[1];
    int counter=0;
    while(true){
    try{
    fis.read(b);
    counter++;
    //mOut.println("RB "+counter+"="+b[0]+"<br>");
    sb.append( new String(b));
    //if('\r'==b[0])
    if(13==b[0]){
    fis.read(b);
    sb.append( new String(b));
    //mOut.println("RB next="+b[0]+"<br>");
    break;
    }catch(IOException e){
    e.printStackTrace();
    //mOut.println("----Counter before return="+counter+" STR="+sb.toString()+"----<br>");
    b = null;
    //mOut.println("---- End readBoundaryLength ----<br>");
    return counter+1;
    private int readUntilBody(BufferedInputStream fis) throws Exception{
    byte[] b = new byte[1];
    mime_counter=0;
    int counter = 0;
    StringBuffer sb = new StringBuffer();
    while(true){
    try{
    fis.read(b);
    sb.append(new String(b));
    mime_counter++;
    //mOut.println("RUntilB "+mime_counter+"="+b[0]+"<br>");
    //if('\r'==b[0])
    if(13==b[0])
    counter++;
    if(counter == 2){
    fis.read(b);
    sb.append(new String(b));
    //mOut.println("RUntilB counter=2 "+mime_counter+"="+b[0]+"<br>");
    break;
    }catch(IOException e){
    e.printStackTrace();
    b = null;
    //mOut.println("RUntilB="+sb.toString()+"<br>");
    return mime_counter;
    private int getContentLength(){
    return request.getContentLength();
    private String readContentDisposition(BufferedInputStream fis) throws Exception{
    byte[] b = new byte[1];
    disp_counter=0;
    StringBuffer sb = new StringBuffer();
    while(true){
    try{
    fis.read(b);
    disp_counter++;
    sb.append(new String(b));
    //mOut.println("ReadCD "+disp_counter+"="+b[0]+"<br>");
    //if('\r'==b[0])
    if(13==b[0]){
    for(int i=1; i < 2; i++){
    sb.append(new String(b));
    fis.read(b);
    //mOut.println("ReadCD before break="+b[0]+"<br>");
    break;
    }catch(IOException e){
    e.printStackTrace();
    //mOut.println("----disp_counter before return="+disp_counter+" STR="+sb.toString()+"----<br>");
    b=null;
    disp_counter += 1;
    return sb.toString();
    private String readNumberOfBytes(BufferedInputStream bis, int count) throws Exception{
    byte[] b = new byte[count];
    byte[] tmp = new byte[count];
    int offset = 0;
    int icount = count;
    int i=0;
    String tmpStr = null;
    try{
    while((i = bis.read(b,0,icount)) != -1){
    System.arraycopy(b,0,tmp,offset,i);
    tmpStr = new String( tmp );
    //mOut.println( "*****"+tmpStr );
    if(icount - i > 0) {
    icount = count - i;
    offset +=i;
    continue;
    else
    break;
    }catch(IOException e){
    e.printStackTrace();
    //for (i=0; i<b.length; i++)
    // mOut.println("AC"+i+"="+b+"<br>");
    return tmpStr;
    public String parseFile( ) throws Exception {
    int len = readAll(bis);
    mOut.println("total len="+len+"<br>");
    //in the first phase, throw away the request parameters that are not required
    //in the second phase, grab the required stuff
    int reallength;
    int mod = 0;
    int div = 0;
    //get rid of the unwanted request content
    reallength = getRealContentLength();//this is the orig line
    //mOut.println( "reallength is " + reallength +"<br>");
    //get rid of boundary and content disp header.
    //int bound_len = readBoundaryLength(bis);
    //String content_disp = readContentDisposition(bis);
    //mOut.println( "Xbound_len" + bound_len +"<br>");
    //mOut.println( "xcontent_disp" + content_disp +"<br>");
    //now we are at partnos,qty
    //int body = readUntilBody(bis);
    if(reallength < 2048){
    currentLine += readNumberOfBytes(bis,reallength);
    else{
    div = reallength / 2048;//buffer default size
    mod = reallength % 2048;
    mOut.println("div ="+div+" mod="+mod+"<br>");
    for(int i=0; i < div; i++)
    currentLine += readNumberOfBytes(bis,2048);
    if(mod != 0)
    currentLine += readNumberOfBytes(bis,mod);
    //mOut.println( "currentLine" + currentLine );
    //ExtractPartNumberAndQuantity();
    //mOut.println("total length="+currentLine.length()+"<br>");
    int lastInd = currentLine.lastIndexOf('\r');
    //mOut.println("lastInd="+lastInd+"<br>");
    lastInd = currentLine.lastIndexOf('\r',lastInd-1);
    //mOut.println("lastInd="+lastInd+"<br>");
    currentLine= currentLine.substring(0,lastInd);
    //mOut.println( "currentLine="+currentLine+"<br>" );
    return currentLine;
    %>
    <%
    out.println(" request length="+request.getContentLength()+"<br>");
    setInputStream(request,out);
    String allLines = parseFile();
    out.println("************** Parsing string starts <br>");
    StringBuffer sb = new StringBuffer();
    sb.append( (char)13 );
    sb.append( (char)10 );
    StringTokenizer st = new StringTokenizer( allLines,sb.toString());
    String line = null;
    // skip the first line as this is header...
    if( st.hasMoreTokens() )
    line = st.nextToken();
    while( st.hasMoreTokens() )
    line = st.nextToken();
    out.println(line+"<br>");
    out.flush();
    %>

    err..
    <%!
    private BufferedInputStream bis = null;
    int MAX_LINES = 2000;
    private String currentLine = "";
    //private String[] PartNumber;
    //private String[] Quantity;
    public int disp_counter = 0;
    public int mime_counter = 0;
    public int boundary_counter = 0;
    private String content_diposition = null;
    private HttpServletRequest request;
    private javax.servlet.jsp.JspWriter mOut;
    that's the problem, most likely.... the <%! part to hold all the variables. Particularly coudl've been a problem if you have multple requests at the same time..

  • I am getting this error while file uploading

    Hi!
    I am getting this error while file uploading,I can't find any solution.
    SRVE0026E: [Servlet Error]-[org.apache.commons.fileupload.FileUpload: method setSizeMax(I)V not found]: javax.servlet.ServletException: org.apache.commons.fileupload.FileUpload: method setSizeMax(I)V not found
    at com.honeywell.sdm.base.controller.SDMActionServlet.service(SDMActionServlet.java:75)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
    at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
    at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
    at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
    at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:983)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:564)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
    at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
    at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
    at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
    at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:116)
    at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
    at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
    at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
    at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
    at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
    Please help me.I have attached the bean,action ,jsp pages
    uploadInfo.jsp
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <html:html>
    <HEAD>
    <script>
    function submitting(){
    document.uploadForm.operation.value = "uploadOrgAdj";
    document.uploadForm.action = "/uploadRecAction.do";
    document.uploadForm.submit();
    </script>
    </HEAD>
    <body>
    <html:form action="/uploadRecAction" method="post" enctype="multipart/form-data">
    Select the .xls File to upload data
    <html:file property="fileName"></html:file>
    <html:hidden property="operation" value=""/>
    <html:button property="btn" value="Submit" onclick="submitting()"></html:button>
    </html:form>
    </body>
    </html:html>
    uploadAdjForm :
    import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.ActionError;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.upload.FormFile;
    public class uploadAdjForm extends ActionForm{
    private FormFile fileName;
    * @return
    public FormFile getFileName() {
    System.out.println("getFileName"+fileName);
    return fileName;
    * @param string
    public void setFileName(FormFile string) {
    System.out.println("setileNmame"+string);
    fileName = string;
    Action:
    public class uploadFinancialAdjAction extends DispatchAction{
    public org.apache.struts.action.ActionForward uploadOrgAdj(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Exception {
    String sForward = "UploadInfo";
    HttpSession session = request.getSession();
    String sStartIndex = null;
    String sEndIndex = null;
    try
    uploadFinancialAdjForm UploadForm=(uploadFinancialAdjForm)form;
    System.out.println(UploadForm.getFileName().getContentType().toString());
    String file=UploadForm.getFileName().toString();
    uploadFinancialAdjManager businessManager = new uploadFinancialAdjManager();
    ArrayList fileName = new ArrayList(); fileName = businessManager.getOrgAdjDetails(file);
    boolean isMultipart = FileUpload.isMultipartContent(request);
    if(isMultipart){
    // Create a new file upload handler
    DiskFileUpload upload = new DiskFileUpload();
    // Parse the request
    List items = upload.parseRequest(request);
    //Process the uploaded items
    Iterator iter = items.iterator();
    while (iter.hasNext()) {
    FileItem item = (FileItem) iter.next();
    if (item.isFormField()) {
    //processFormField(item);
    if(item.getFieldName().equalsIgnoreCase("txtStartIndex")){
    sStartIndex = item.getString();
    else if(item.getFieldName().equalsIgnoreCase("txtEndIndex")){
    sEndIndex = item.getString();
    uploadFinancialAdjForm UploadForm=(uploadFinancialAdjForm)form;
    String file=UploadForm.getFileName().toString();
    uploadFinancialAdjManager businessManager = new uploadFinancialAdjManager();
    ArrayList fileName = new ArrayList();
    fileName = businessManager.getOrgAdjDetails(file);
    }else{
    if(item.getName()!=null && !item.getName().toUpperCase().endsWith(".XLS")){
    throw new Exception("Please browse an excel file and Upload");
    session.setAttribute("fileItem",item);
    }//end of while
    session.setAttribute("startIndex",sStartIndex);
    session.setAttribute("endIndex",sEndIndex);
    request.setAttribute("FileUploadStatus","true");
    else{
    throw new Exception("Error:Form is not multipart");
    catch(Exception e)
    System.out.println(e);
    return mapping.findForward(sForward);
    }

    Plz answer for my question

  • File upload....How to find the user entered any file or not

    Hi Team,
    I am working on with file upload UI.
    Some times without clicking on browse button, I mean without entering any file they are cliking on upload button, which is giving the exception.
    I know there is no action for UI element, Then how to resolve this?
    I just control the user, not to press the upload button without entering any file name there?
    How to resolve this?
    regards,
    Bala

    Hi,
    This code will solve ur problem.
    public void onActionUploadFile(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionUploadFile(ServerEvent)
        IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute(IPrivateFileUploadDownloadView.IContextElement.FILE_RESOURCE);
        IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType)attributeInfo.getModifiableSimpleType();
        IPrivateFileUploadDownloadView.IContextElement element = wdContext.currentContextElement();
        if(element.getFileResource() !=null)
             try
                  String mimeType = binaryType.getMimeType().toString();
                  byte[] file = element.getFileResource();
                  //element.s
                  wdComponentAPI.getMessageManager().reportMessage(IMessageFileUploadDownloadComp.SF__UPLOAD,new Object[] {binaryType.getFileName()},false);
             catch(Exception e)
                  throw new WDRuntimeException(e);
        else
              wdComponentAPI.getMessageManager().reportMessage(IMessageFileUploadDownloadComp.NO__FILE,new Object[] {" "},true);
        //@@end
    Here "fileresource" is context attribute name
    Regards,
    Sunaina Reddy T

  • Illustrator CC 2014 "Exception in file" error with linked images

    It appears some images are showing "Exception in file" error dialog boxes.
    If I resave the image in Photoshop or link it to a different image the error disappears.
    Happened with:
    - old design files linked to old images
    - image that was dragged from Mac Mail
    - linked to JPG provided from other users
    Does not happen with:
    - images created recently with Photoshop CC or CC 2014
    Here is the error:
    Has anyone else seen this and/or found a solution?
    This is an error on a new Mac Pro with brand new install of all software. No older versions of cc installed. Just CC 2014.

    That's a good idea. Unfortunately, same problem if I move the image to desktop or same folder as file.
    If I resave the file (JPG in this case) the error disappears.
    I understand this can be the solution, but given this issue had not happened before, it's interesting it is happening with CC 2014.
    Attached is the image in question. Note that this is not the only image. It has happened with older design files that were made from older versions of cc or before cc.
    I'm not sure if the uploader will recreate the JPG so I'll compress the file and is available here if anyone would like to test.
    Dropbox - photo 2.JPG.zip

  • 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, ...

Maybe you are looking for