title: JSP and SPRING Boot : Generate CSV file from JSON input?
body: <p>I did some research but could not find how to solve this. I want to give the possibility to export to CSV some records from my database when a user click on "Export Records withoud mailId" on clien side. What is the best way to achieve this? In my research I find out that people use only Servlets as examples but for me I dont use Servlets.</p>
  
  <p>This is my controller:</p>
  
  <pre><code> @RequestMapping(value = "/eblnotif/exportMailId", method = RequestMethod.POST, produces = "application/json")
          public @ResponseBody List&lt;EblNotifResource&gt; exportMailIdCsv(@RequestBody Filters filters)
                  throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException,
                  SecurityException, IOException {
  
              List&lt;EblNotif&gt; eblnotif_list = accountSservice.exportMailIdCsv(filters);
  
              List&lt;EblNotifResource&gt; eblnotifres = new ArrayList&lt;&gt;();
  
              for (EblNotif eblNotif : eblnotif_list) {
                  EblNotifResource eblres = new EblNotifResource();
                  eblres.setFormName(eblNotif.getFormName());
                  eblres.setSendingDate(eblNotif.getSendingDate());
                  eblres.setMode(eblNotif.getMode());
                  eblres.setLanguage(eblNotif.getLanguage());
                  eblres.setGpart(eblNotif.getGpart());
                  eblres.setEmail(eblNotif.getEmail());
                  eblres.setMailId(eblNotif.getMailId());
                  eblnotifres.add(eblres);
              }
              return eblnotifres;
      }
  }
  </code></pre>
  
  <p>And gives back to the client (JSP) this json format:</p>
  
  <pre><code> [
     {
        "formName":"FormName1",
        "mode":"S",
        "language":"F",
        "sendingDate":"2017-04-03",
        "gpart":"555",
        "email":"",
        "mailId":"96318"
     },
     {
        "formName":"FormName2",
        "mode":"S",
        "language":"F",
        "sendingDate":"2017-04-03",
        "gpart":"444",
        "email":"",
        "mailId":"96325"
     }
  ]
  </code></pre>
  
  <p>The desired output in the csv will be something like:</p>
  
  <pre><code>formName;mode;language;sendingDate;gpart;email;mailId
  FormName1;S;F;2017-04-03;555;testing@test;96318
  FormName2;S;F;2017-04-03;444;testing@test;96325
  </code></pre>