1. #1
    Sencha User
    Join Date
    Dec 2012
    Location
    India
    Posts
    8
    Vote Rating
    0
    tanujkhanna9 is on a distinguished road

      0  

    Default Unanswered: ExtJs 4 need to read Response Stream to create CSV file

    Unanswered: ExtJs 4 need to read Response Stream to create CSV file


    Hi
    I have created an AJAX Request of Post Nature.

    Servlet code accepts the Post request and processes it. doPost() method writes the csv File to the responseStream .

    This response should have been handled by the browser but when it reaches the success function of AjaxRequest, I just find my csv text embedded in an object.

    Following below is the code:

    UI Side
    Ext.Ajax.request({
    ur;:'ExportCsvServlet',
    method:'POST',
    params:{"test":"testParam"},
    success:function(response){
    console.log('we are success')'
    },
    failure:function(response){
    console.log('we are failure')'
    }
    });


    Servlet Code

    doPost(request,response){

    response.setHeader("Contet-type","text/csv");
    response.setHeader("Content-Disposition","attachment; filename=test.csv");
    PrintWriter writer = response.getWriter();
    writer.append("a,b,c");
    writer.flush();
    writer.close();
    }

    Please suggest how to make sure, the file is downloaded ??? any ideas,

  2. #2
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    Answers
    124
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

Thread Participants: 1

Tags for this Thread