How to read a file using servlet

hi ,
i've to read a file using servlet ,
should read the file using servlet and display it in JSP,Could anybody get me how can i do it .
Shiva

To do that you need to get the response output stream and write yur file contents to that.
response.setContentType(mimeType); //Set the mime type for the response
ServletOutputStream sos = resp.getOutputStream();
sos.write(bytes from your file input stream);
sos.close();

Similar Messages

  • How to read HTML files using UTL_FILE

    Hello Friends,
    How to read HTML files using UTL_FILE package ? According
    to Oracle documentation UTL_FILE can read or write OS Text Files.
    Thanx in advance..
    Adi

    HI Hareesh,
    i have gone through that blog.
    i tried it...but i am getting mapping error  no receiver determination fond because there are so  many excel files.
    my data is available on sharedString.xml but also it is in not same order.
    i have no clue how to handle this part form the blog.
    "This way our mapping will receive all data from the sheet in an XML format. The only thing that's left is to create an XSD file from the XML file we received in order to be able to use it in the mapping and as our Service Interface and we can proceed with mapping. As you can see from the sheet.xml files all the data is placed with column name and row number so it's not that difficult to map it to an table type format using the Message Mapping only (no java, abap mapping required)."

  • How to read pdf file using file adapter

    Hi..
        How to read pdf file using file adapter?
    regards
    Arun

    Hi
    This may help you
    /people/sap.user72/blog/2005/07/27/xi-generate-pdf-file-out-of-file-adapter
    /people/alessandro.guarneri/blog/2007/02/21/sap-xi-acting-as-a-huge-file-mover
    ---Ram

  • How to read pdf files using java.io package classes

    Dear All,
    I have a certain requirement that i should read and write PDF files at runtime. With normal java file IO reading is not working. Can any one suggest me how to proceed probably with sample code block
    Thanks in advance.

    hi I also have the pbm. to read pdf file using JAVA
    can any body help meWhy is it so difficult to read the thread you posted in? They say: java.io is pointless, use iText. So why don't you?
    or also I want to read a binary encoded data into
    ascii,
    can anybody give me a hint how to do it.Depends on what you mean with "binary encoding". ASCII's binary encoding, too, basically.

  • How to read 835 files using ssis

    Hello Everyone,
    It is possible read 835 files using ssis.
    Please share your suggestions on this.
    Regards,
    Vaishu

    Hi Vaishu,
    None of the canned (standard) SSIS tasks let you do so.
    But if you can buy http://www.cozyroc.com/ssis/edi-source (I am not anyhow affiliated with CozyRoc) it states it can read ERA (AKA 835) files. CozyRoc lets you run it for free in Dev.
    If there will be a decision not to buy then you can simply crate a transformation out of several manipulations or by creating a custom SSIS component or some other programming methods need to be used.
    PS: Again, I just know CozyRoc quality of components is awesome, but I do not make any profit from referring to it.
    Arthur My Blog

  • How to get XML file using servlets that XI sent to my J2EE appl?

    Hi All!
    I have a scenario like XI sends xml file to j2ee application. In my J2EE application my servlet receives this xml. Will the xml file be in my HTTPServletRequest object? if so how to get that file from Request object.
    Please help me its urgent, Any code help is highly appreciated.
    My xml file will be like this:
    <ns0:Http_Message_Type_Demo
    xmlns:ns0="http://abcdemo.com">
    <Name>ABC</Name>
    <RollNo>123</RollNo>
    <Address>a-4</Address>
    </ns0:Http_Message_Type_Demo>
    somebody should help me!please
    Thanks

    Hi,
    You can use HTTPServletRequest object to get the XML payload.
    BufferedReader reader = request.getReader(); //gets XML payload
    String line = reader.readLine(); // to read the XML payload line by line
    (request is the HTTPServletRequest object)
    Regards,
    Uma

  • How to read SGML files using Java

    I've got a text categorisation test collection called Reuters-21578 for my Information Retrieval project. It is distributed in 22 files. Each of the first 21 files (reut2-000.sgm through reut2-020.sgm) contains 1000 documents, while the last (reut2-021.sgm) contains 578 documents. The files are in SGML format. Each of the 22 files begins with a document type declaration line:
    <!DOCTYPE lewis SYSTEM "lewis.dtd"> The DTD file lewis.dtd is included in the distribution. Following the document type declaration line are individual Reuters articles marked up with SGML tags.
    My questions is how to write a java program to read those 21578 documents or transform them into 21578 seperated text files.

    I guess I missed something. What is Renes link?. The
    parser stuff isn't really what I'm looking for. I'm
    a new at and just learning java and I just want to
    know the easiest way to read a SGML file. Should I
    use a buffered Reader with a Pushback Input Stream?Hang on.....you want to just read the file without intelligently extracting the SGML data contained within and so have no need of a parser?
    Well, in that case, its just text.....so just use BufferedReader or whatever to read the text data. If I understand you correctly, all you really wanted to ask was "how do I read a text file?"

  • How to read any file using external tables.

    Hi folks,
    I have written an application that reads a series of csv files using external tables which works fine as long as I specify each file name in the directory i.e.......
    CREATE TABLE gb_test
    (file_name varchar2(10),
    rec_date date
    rec_name VARCHAR2(20),
    rec_age number,
    ORGANIZATION EXTERNAL
    TYPE ORACLE_LOADER
    DEFAULT DIRECTORY GB_TEST
    ACCESS PARAMETERS
    RECORDS DELIMITED BY NEWLINE
    FIELDS TERMINATED BY ','
    LOCATION ('data1.csv','data2.csv','data3.csv','data4.csv')
    PARALLEL 5
    REJECT LIMIT 20000;
    However I have discovered that I may not know the name of the files to be processed prior to the program being run so just want to read any file regardless of it's name (although it will always be a .csv file).
    Is there a way to ensure that you don't need to specify the files to be read in the LOCATION part of the syntax.
    Thanks in advance.
    Graham.

    Right, I have now completed this, however it's currently only working as SYS as opposed to any user, however here is a detail of the scenario and the steps required in case any of you guys need in the future ......
    The problem was I needed to search for csv files on my hard-drive. These files would be stored in a series of directories (a through to z), so I needed a way to read all 26 directories and process all files in these directories.
    The problem was, prior to running the program, the user would remove all the files in the directories and insert new ones, but it was never known how many he would decide to do each time.
    Solution: I created a table called stock_data_directories as follows ...
    create table stock_data_directories(sdd_rec_no number,
    sdd_table_name varchar2(50),
    sdd_directory_name varchar2(50),
    sdd_directory_path varchar2(100));
    Then inserted 26 records like ...
    insert into stock_data_directories(sdd_rec_no,sdd_table_name,sdd_directory_name,sdd_directory_path)
    values(1,'rawdata_a','KPOLLOCKA','C:\KPOLLOCK\A')
    insert into stock_data_directories(sdd_rec_no,sdd_table_name,sdd_directory_name,sdd_directory_path)
    values(2,'rawdata_b','KPOLLOCKB','C:\KPOLLOCK\B');
    etc...etc...
    Then created 26 DIRECTORIES E.G.
    CREATE OR REPLACE DIRECTORY KPOLLOCKA AS 'C:\KPOLLOCK\A';
    CREATE OR REPLACE DIRECTORY KPOLLOCKB AS 'C:\KPOLLOCK\B';
    Then created 26 external tables like the following ...
    CREATE TABLE rawdata_a
    (stock varchar2(1000),
    stock_date varchar2(10),
    stock_open VARCHAR2(20),
    stock_high varchar2(20),
    stock_low varchar2(20),
    stock_close VARCHAR2(30),
    stock_qty varchar2(20) )
    ORGANIZATION EXTERNAL
    TYPE ORACLE_LOADER
    DEFAULT DIRECTORY KPOLLOCKA
    ACCESS PARAMETERS
    RECORDS DELIMITED BY NEWLINE
    FIELDS TERMINATED BY ','
    LOCATION ('AA.csv')
    PARALLEL 5
    REJECT LIMIT 20000
    This basically says in directory rawdata_a it currently has 1 file called AA.csv.
    Then wrote a procedure as follows ...
    procedure p_process_files(pv_return_message OUT varchar2)is
    cursor c_get_stock_data_directories is
    select distinct sdd_directory_path,
    sdd_table_name
    from stock_data_directories
    order by sdd_table_name;
    vv_return_message varchar2(1000);
    begin
    -- here get the files for each directory
    for r_get_stock_directories in c_get_stock_data_directories loop
    p_build_external_table(r_get_stock_directories.sdd_directory_path,
         r_get_stock_directories.sdd_table_name,
         vv_return_message);
    end loop;
    end;
    then wrote a procedure called p_build_external_table as follows ...
    procedure p_build_external_table(pv_directory_path IN stock_data_directories.sdd_directory_path%type, -- e.g. 'C:\kpollock\A\
    pv_table_name IN stock_data_directories.sdd_table_name%type, -- e.g. rawdata_a
    pv_return_message OUT varchar2) is
    vv_pattern VARCHAR2(1024);
    ns VARCHAR2(1024);
    vv_file_name varchar2(4000);
    vv_start_string varchar2(1) := '''';
    vv_end_string varchar2(3) := ''',';
    vn_counter number := 0;
    vv_err varchar2(2000);
    BEGIN
    vv_pattern := pv_directory_path||'*';
    SYS.DBMS_BACKUP_RESTORE.searchFiles(vv_pattern, ns);
    FOR each_file IN (SELECT FNAME_KRBMSFT AS name FROM X$KRBMSFT) LOOP
    if each_file.name like '%.CSV' then
    vv_file_name := vv_file_name||vv_start_string||substr(each_file.name,instr(each_file.name,'\',1,3)+1)||vv_end_string;
         vn_counter := vn_counter + 1;
    end if;
    END LOOP;
    vv_file_name := substr(vv_file_name,1,length(vv_file_name)-1); -- remove final , from string
    execute immediate 'alter table '||pv_table_name||' location('||vv_file_name||')';
    pv_return_message := 'Successfully changed '||pv_table_name||' at '||pv_directory_path||' to now have '||to_char(vn_counter)||' directories';
    exception
    when others then
    vv_err := sqlerrm;
    pv_return_message := ' Error found updating directories. Error = '||vv_err;
    END;
    This reads every file in the directory and appends it to a list, so if it finds A.csv and ABC.csv, then using the dynamic sql, it alters the location to now read 'a.csv','abc.csv',
    It ignores all other file extentions.

  • How to download a file using servlet

    I have a problem about downloading a file using a servlet.
    Anybody can help me?
    Thanks

    I am assuming that you want to write a servlet that, when invoked by a user (for instance, through a URL link), will download a file using the "save as" dialog (on Windows, for example) in the user's browser.
    In such a case, all you need to do is get the OutputStream from the response object, set the proper MIME type header, and write the file. Here is an (untested, not even compiled) skeleton.
    public class MyServlet extends HttpServlet {
    protected void doGet (HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException {
    ServletOutputStream out = resp.getOutputStream ();
    resp.setContentType ("application/x-foobar");
    while (/* whatever */) {
    In this loop, you generate your "file's" data.
    You can compute it on the fly, pull it from a database,
    read it from a "real" file, or any other means you can dream up.
    The sample line below just writes some of the data (for example,
    a byte array) to the user's browser via the output stream out.
    out.write (data);
    out.flush ();
    Go to http://java.sun.com/j2ee/sdk_1.3/techdocs/api/index.html
    for the JavaDoc on the classes used.
    Cheers!
    Jerry Oberle

  • How to read .XLSX files using org.apache.poi.ss.usermodel.* classes

    Hello,
    I want to read in excel files to a JTable. I was able to read in .xls files, but have problems reading .xlsx files. Maybe there is something i need to add to the following code:
    FileInputStream iStream = new FileInputStream(newFile);
    POIFSFileSystem fs = new POIFSFileSystem(iStream);
    Workbook wb1 = WorkbookFactory.create(fs);
    Sheet sheet = wb1.getSheetAt(0);       // get the first sheet data
    // Iterate over each row in the sheet
      Iterator rows = sheet.rowIterator();
       while(rows.hasNext()) {
          Row row = (Row) rows.next();
          .............The compiler is complaining about the 3rd line: Workbook wb1 = WorkbookFactory.create(fs);
    Thanks.

    @ejp:
    I quite agree with you. It's a runtime exception -
    org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF)I've tried searching before coming here to ask. HSSF processes .xls files only, XSSF processes .xlsx files only while SS is supposed to read both .xls and .xlsx files. Maybe there's anyone that has used it before who can help out.
    Thanks

  • How to read .doc files using jakarta POI api......

    Hi all,
    I've googled a lot on reading the file contents of an MS word file. I couldn't get a solution yet. Can you please give some sample codes for using the POI api for extracting only the text contents from an MS word file.
    Thanks and Regards,

    whenever i click the folders, it's taking
    to the internal folders. but there's no
    option to download the whole package.Thats because you're looking at a tool which displays the contents of an svn repository through a web site.
    What you need is a subversion client (the repository is a subversion repository).
    There are several easy to use clients available:
    Here's two:
    1) subclipse: If you use eclipse. Dammed great tool IMHO. http://subclipse.tigris.org/
    2) tortoise svn http://tortoisesvn.tigris.org/
    When you've got a client, you'll need to give it a repository URL from which to check out.
    For the POI project, that URL is http://svn.apache.org/repos/asf/jakarta/poi/trunk/
    ~D

  • How to read word files using java

    Reding text files is prity simple. But when i tried to read msword file I could do it.
    Can any one discuss how to do it
    Thanks

    Sorry this is not a reply but in fact i need the solution for that as i am in an urgency of that can you post that to to me if u have got it, I need it for my project

  • How to read Attachments files using POP

    Hello Every One
    I am wondering that, is there any tool available that reads Attachments files from the Email.
    I have POP tool that allows me to read regular Text message, but what if I want to read some files from the attachments.
    Any help is appreciated
    Thank you
    Amit

    Hi Amit,
    I have found a LV program that reads a .txt attachment from an email in this discussion forum posted.  I hope this helps.
    Regards,
    Nadim
    Applications Engineering
    National Instruments

  • How to read XML file using Automatic ref No

    I need to get the data from the xml file using Automatic reference No.I am a beginner .help me out

    Hi Parthipan,
    An easy way to get started with using XML in LabVIEW is a toolkit called EasyXML -- it's a product from JKI that I helped create
    Thanks,
    -Jim

  • How to read xlsx files using file sender adapter in PI7.11

    Hi All,
    i have scenario where i need to read the xlsx file and convert it into idoc.
    i have gone through the few bolgs
    but not got proper result to read the xlsx file.
    please guide me how can i achieve this scenario using standard way(like standard adapter modules,graphical mapping).
    i saw in some blogs using API....
    but i am not aware of the process of develop custom modules in PI.
    please if there is any step by step process document to develop custom module for adapters.
    thanks in advance.
    mahesh

    HI Hareesh,
    i have gone through that blog.
    i tried it...but i am getting mapping error  no receiver determination fond because there are so  many excel files.
    my data is available on sharedString.xml but also it is in not same order.
    i have no clue how to handle this part form the blog.
    "This way our mapping will receive all data from the sheet in an XML format. The only thing that's left is to create an XSD file from the XML file we received in order to be able to use it in the mapping and as our Service Interface and we can proceed with mapping. As you can see from the sheet.xml files all the data is placed with column name and row number so it's not that difficult to map it to an table type format using the Message Mapping only (no java, abap mapping required)."

Maybe you are looking for

  • IT 2001 shows wrong value

    Daily working hour is 9hrs (1 hour unpaid break), so actually it's 8hrs. but when i mark 9-1pm leave (4hrs), it shows 0.44 days leave instead of 0.50 days. What could be the reason? in wsr i tried with 9 hr and 8 hr also, but no changes.

  • Legal person

    Hi Gurus, I wanted to know is there a standard SAP functionality that if there is change in legal person in infotype 0001 then a organisation reassignment action cannot be performed. If no, where can the settings be done, as I am not able to perform

  • Cancelation of profroma invoice

    Dear All My user has used the VF04 and generated proforma invoices twice for STO. I have tried in VF11 but i am getting message saying Pro forma invoice cannot be cancelled. I have tried with VF02 and shift+f5 it is showing canel message but the regi

  • What do I do with a 5s that doesn't work

    What do I do with a new 5s that simply doesn't work?  This is the 3rd new 5s I've had in the past 5 weeks, and I haven't had one work yet.  This is obvously not a hardware problem, which I'm sure makes it harder to solve, but at this point I'm left w

  • Unable to Edit songs due to copyright

    Songs that have been put into my itunes went in all messed up...when I click get info to edit the songs, I'm either not able to change it, or I make the corrections but then when I hit OK, it doesn't make the changes...I called apple and they said it