How to get the file content after uploading file

Hello everyone!
I have a question. Anyone can provide an example code by jsp that getting the uploaded file content after user uploading a file?
Your help is highly appreciated!!!

My experience is you need to do it twice: first read it to a StringBuffer and readline. Then write the file to server. See the code below
MultipartParser parser = new MultipartParser(request, 10000000);
Part part = null;
FilePart filePart = null;
File uploadDir = new File("/Uploads/");
if (!uploadDir.exists()) {
uploadDir.mkdir();
while(true){
     part = parser.readNextPart();
     if(part == null)
          break;
     if(part instanceof FilePart){
          filePart = (FilePart)part;
          filename = filePart.getFilePath();
          //You can do one of the following option. Here is read line to a buffer and display to screen
//if (filename != null) {
          //Do not store the file to server machine.
//long size = filePart.writeTo(uploadDir);
// System.out.println("The number of bytes written is "+size);
          reader = new BufferedReader(new InputStreamReader(filePart.getInputStream()));          
          String newline=reader.readLine();
          if(newline!=null)     {     
          reconcileContent.append("<table border=\"1\"><tr><th>Destination ID</th><th>File ID</th><th>Rept Date</th><th>As of Date</th><th

Similar Messages

  • Getting the page content as pdf file

    Hi All,
    I have a use case like i need to get the page content as pdf file.
    For this i found xsl file and it's config under the following locations
    /libs/cq/config/rewriter/pdf/transformer-xslt --config of source
    /libs/wcm/core/content/pdf/page2fo.xsl -- xsl file location
    For custamising this functionality i copied both confing node and xsl file under "/apps" .In the Config file i changed source to refer xsl file under /apps.But it's not taking config changes.
    I have looked into http://cqblueprints.com/xwiki/bin/view/CQ+FAQ/How+can+I+configure+the+ PDF+rewriter
    there it's saying like we need to modify the com.day.cq.rewriter.xml.XSLTTransformer class. i am not getting how to modify it.
    I need this urgently
    Thanks,
    Chinna Yadlapalli.

    This script:
    http://indesignsecrets.com/zanelli-releases-multipageimporter-for-importing-both -pdf-and-indd-files.php
    answers all your questions.
    Peter

  • In Mac how to get the Full name of a file Programmatically?

    Hi Friends,
             I am doing one Mac application for displaying the contents of a file. I can able to get some information about the file by using this code below...
      NSDictionary *dict=[fileManager attributesOfItemAtPath:myPath error:nil];
    Now I want to get the some other informations also like Full Name, copyRight, version... So Please suggest me how to get the full name of a file Programmaticallly?

    Your question doesn't make sense.
    First off, if you are going to get the attributes of a file, you need its full name before you can do anything. So that's part one taken care of.
    This function returns a dictionary full of typical file information (type, size, mod dates, etc.) as well as some HFS data (creator code, type code) which, I strongly suspect, are not "pulled out of the file" but rather generated on the spot. (See NSFileManager for the full list of attribute keys.)
    The other items you hoped of retrieving are not part of the regular file system. Sure, a Truetype font has a copyright string and a version, but what about an HTML file? A PNG? A text file you just created?
    There simply are no standard functions to retrieve copyright and version.

  • How to get the absolute path of a file from the local disk given the file n

    how to get the absolute path of a file from the local disk given the file name

    // will look for the file at the current working directory
    // this is wherever you start the Java application (cound be C: and your
    // application is located in C:/myapp, but the working dir is C:/
    File file = new File("README.txt"); 
    if (file != null && file.exists())
        String absolutePath = file.getAbsolutePath();

  • How to save the RichTextBox Content in Text file

    hI ,
    I NEED TO SAVE THE RichTextBox Content in text file ? 

    If this IS a LabVIEW question, here's an example of how to load a rich text file (to help if you don't know how to get a rich text in LabVIEW).
    If you have a Rich Text Box, you can use the invoke method "SaveFile" to match the function you linked to.

  • How to determine the mimetype of an uploaded file (GUI_UPLOAD)?

    Hi everybody.
    I use method cl_gui_frontend_services=>gui_upload to upload files and save the binary data in the database. to preview the filetype (pdf, doc, jpg, ...) later i also need to store the mimetype.
    but how can I determine the mimetype of an uploaded file if several file extensions/formats are possible?
    thanks in advance for your help,
    Stefan

    call the function SKWF_MIMETYPE_OF_FILE_GET
    for this pass the filename , you will get the mime type.
    FILENAME                        C:\TEST.PDF  "pass this
    MIMETYPE                        application/pdf "you will get this
    FILENAME                        C:\TEST.JPG
    MIMETYPE                        image/jpeg
    FILENAME                        C:\TEST.DOC
    MIMETYPE                        application/msword

  • How to get the path of input type="file" tag

    -- im using <input type="file"> tag to get an input file from a local host, it returns only the filename but not the complete path of the filename,,,
    -- i need to know on how to get the compelete path /directory of the filename using <input type="file"> tag , or is there any other way to get an input file from a local host aside from <input type="file"> tag?
    thanks

    http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/input_file.asp?frame=true
    When a file is uploaded, the file name is also submitted. The path of the file is available only to the machine within the Local Machine security zone. The value property returns only the file name to machines outside the Local Machine security zone. See About URL Security Zones for more information on security zones.
    i need to know on how to get the compelete path /directory of the filename
    using <input type="file"> tag You can't. Its a security thing.
    is there any other way to get an input file from a local host aside from <input type="file"> tag?No. Not using just html.
    You could always go into activex components, but thats different again.
    Cheers,
    evnafets

  • How to get the Real Path of a file which is accessed  by URL?

    iam using tomcat6.0.
    I have a file xyz.xml at the top of the webapplication HFUSE which i can able to access by URL
    http://localhost:8080/HFUSE/xyz.xml
    My problem is how to get the realpath of the file "xyz.xml" for reading and writing purposes.
    I tried various things but i could not able to successfully solved the problem?
    1) File f = new File("/xyz.xml");
    print(f.getAbsolutePath()) ============== it is not fetching the file @ http://localhost:8080/HFUSE/xyz.xml rather it is creating a file
    at the root of the drive where eclipse is running.
    2) File f = new File("xyz.xml");============> this is also not working , it is creating the file xyz.xml in the eclipse directory ..................
    Can anyone please guide on this problem?

    RevertInIslam wrote:
    If you want your context root(i.e HFUSE)
    use this:
    request.getContextPath() //where request is HttpServletRequest object to get the needful path.
    e.g:
    File f = new File(request.getContextPath()+"/xyz.xml");//it will create the file inside HFUSE.
    Hope this helps.
    Regards
    BWrong. The File constructor expects an absolute filesystem path. The HttpServletRequest#getContextPath() doesn't return the absolute filesystem path, it only returns the relative path from the current context root. Use ServletContext#getRealPath() instead, it returns the absolute filesystem path for the given relative path from the current context root.
    File file = new File(servletContext.getRealPath("/"), "xyz.xml");

  • How to get the return message after running BD20 tranaction ?

    Hi Gurus,
    My requirement is to Post vendor invoice through ALE/IDOC ( Inbound IDOC ).
    - For that I had generated the IDOC using  Function module 'IDOC_INBOUND_WRITE_TO_DB '
    - Then I had processed that generated IDOC by calling the standard program rbdapp01(BD20-Tranaction ) using the below statment
    SUBMIT rbdapp01 WITH SELECTION-TABLE lt_seltab .
    Could any one suggest me how to get the report output of standard program (rbdapp01) to an internal table so that I dispaly as an seperated report like Posted Document number with messages or Error message
    Suggest me any Function module or any other standard program to process the IDOC so that I can fulfill my requirement.
    Regards
    Paul

    Use can read the IDOC status after processing...
    Eg.
      SELECT * FROM edidc INTO TABLE t_idoc_control_tmp
          FOR ALL ENTRIES IN t_update WHERE docnum = t_update-docnum.
    and then add your own logic IF SY_SUBRC EQ 0.
    I hope this will help you.
    Regards,
    Amey

  • How to get the encoding of a XML file ...

    Hi,
    How do you get the encoding of a XML file?
    For example,
    <?xml version="1.0" encoding="SJIS"?>
    I am trying to retrieve the above encoding="SJIS", but I can't seem to locate the API for doing so.
    Thanks in advance for any help,
    Eric

    Hi ddossot,
    Thanks for your suggestion.
    However, the xerces.jar file that comes with my old tomcat server is an old version and thus, the getEncoding method is not even present in the DocumentImpl class. The option to update to a newer version of tomcat and xerces is not available. What a pity... :-(
    Well, I just have to try to find a way around. Worst case scenario, parse the first line in the xml file myself.
    Regards,
    Eric

  • How to get the length of a audio file without play it ?

    Now I know a method to get the length of a audio file by play it:
    1 Create a Player, and add a ControllerListener
    2.Start the Player
    3.In the ControllerListener's controllerUpdate method, use getMediaTime() by receiving a EndOfMediaEvent
    However I think this method is not convenience, if I don't want to play it how I can get the length of the audio file?
    Is anyone can help me?Really thanks a lot !

    I got the answer here:
    http://forum.java.sun.com/thread.jspa?threadID=5149132&tstart=15
    I tried getDuration() before, but it always return a same time, I think maybe I didn't realize the player.

  • How to get the text content of an XMLElement

    Hi,
    Here is a XML sample:
    <toto attrib1="titi">tata</toto>
    We want to get the text content "tata".
    Using an XMLElement (from the class "oracle.xml.parser.v2.XMLElement) to manipulate the element "toto", when we use the getNodeValue method, we always retrieve "null".
    So, what is wrong in our procedure and how to resolve this problem?
    Thanks in advance for your help
    Bye

    You need to get the child nodes of the Element and iterate until you find a node of type Node.TEXT_NODE.
    Elements don't have text content, they instead contain text node children.
    Just remember, too, that they can also contain comments, processing instructions, etc., in addition to the text you are looking for:
    <toto><!-- a comment --><?pi?>Tata</toto>

  • How to get the actual path of a file present in the Web content folder

    I have a jasper file which is present inside the Web-Content folder of my project.
    I need to pass this file as an argument to the FileInputStream object. How can i give the actual path of the jasper file, since this project can be deployed anywhere else also.

    You may be able to use the getRealPath or getResource methods in ServletContext

  • How to get the actual data of a file held in IWDResource object?

    Hello,
    I am uploading a csv/excel file and writing it to the server using the FuleUpload UI and IWDResource Interface.
    I need to make some things on the data before I write it:
    1. count the number of columns are in the csv/excel file in each line.
    2. replace special characters in the file using replaceAll for example.
    My problem is how to access the data once it is stored in the IWDResource interface? All I have there is the read method which generated an InputStream object to read bytes from the file.
    Any ideas?
    Roy

    If you want to read cell level or row level data from excel you should use third party APIs. Apache POI provides such an API, you can use and read the excel documents. You can refer the POI API
    <a href="http://poi.apache.org/hssf/quick-guide.html#ReadWriteWorkbook">here</a>.
    And if you want to read the CSV file content do the following..
    FileInputStream fis=(FileInputStream)wdContext.currentContextElement().get<attribute anme>().read(false);
    byte in[]      = new byte[512];
    String csvData;
    StringBuffer csvBuffer = new StringBuffer();
    while(fis.read(in)>0)
    csvData = new String(in);
    csvBuffer.append(csvData);
    //now write the logic to validate the csv data.
    Regards
    Abhilash

  • How to get the "encoding" of a XML file using JDOM

    As in XML file, <?xml version="1.0" encoding="UTF-8" ?> indicates the encoding of this file
    while using JDOM to parse a XML file, how can I get the encoding type?
    thanx!!!

    What my program do is to get the encoding of XML files and convert them to UTF-8 encoding files, while I need this "encoding" information of the original XML document thus I can convert...
    After reading specifications and JDOM docs, the truth turns to be disappointed, no function is provided to get this information in JDOM level 2(the current released one), while it's promissed that this function will be provided in JDOM level API....
    Thanx all for your help and attention!!!

Maybe you are looking for

  • My ipod shuffle won't sync with itunes

    When i attempt to sync my shuffle with itunes, i get a msg (after a long wait) that says my ipod couldn't sync because itunes can't find recommened cd. my shuffle sync's with other computers/itunes and i have no probs in playing the music in itunes,

  • Time capsule Hard drive mounting

    With multable users logged on to a single laptop. Only one user can see time capsule Hard drive content .  you have to log other users off., or de-mount the time capsule of the other users. this seems not right. Why

  • The volume for "work folder" cannont be found

    In finder I am unable to open a folder that contains my work files. I get the above error message. Please help

  • Rename all files in a folder?

    At the end of everyday on a recent month-long trip, I dumped photos from a card into a folder on my desktop, and cleared the card for the next day's use. Now that I'm back home, I have photos in several folders with the same name (i.e. in folder Mond

  • Launching Elements 10

    How do I launch Elements 10 when it has downloaded successfully, but when i click on the desktop icon, the screen flashesto the Organizer  and then cuts out?  (I can access the organizer in an around about way through Premiere Elements, but this is a