0

I want generate a CSV-File within a JSP file.

It works fine and it gets his parameters from URL, so there is just one problem: it just wont break the line to fill a new row.

Here is my code:

<jsp:scriptlet>
            response.setHeader("Content-Disposition", "attachment; 
            filename=exam.csv");
            String line = request.getParameter("line");
            String data = request.getParameter("data");
            String example = line + "\r\n" + data;
            pageContext.setAttribute("example", example);
    </jsp:scriptlet>
    <c:out value="${example}" escapeXml="false" />

As long as it was hardcoded, everything was fine. Now it just want to break the line. Thanks for any answers.

sickzz1
  • 29
  • 2
  • 7
  • You should start by checking [How do I get a platform-dependent new line character?](http://stackoverflow.com/q/207947/4391450). What changed to make the code fail ? Also, you should see `Servlet` instead of `jsp:scriptlet`, in general, jsp is only for the GUI. – AxelH May 17 '17 at 09:44
  • Just the variables didn't got their values from an external parameter. I just hardcoded it, like "String line = "Hello, its me!". – sickzz1 May 17 '17 at 09:59

0 Answers0