Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

impossible to send back a CSV file containing more than 8000 chars

807589Oct 10 2008 — edited Oct 10 2008
Hello,
I work on an application using Spring and I try to write a String of around 19000 chars in a CSV file that I send back to the client with the method PrintWriter.write (response.getWriter().write) of the object HttpServletResponse. Here is the code :
public ModelAndView getViewdomainReport(HttpServletRequest request, HttpServletResponse response) throws Exception {
// domainString is a string containing around 19000 chars
String domainString = reportManagementService.getViewdomainReport(domainRows,domain);
String filename = domain.getDomainNameWithoutBlank()+".csv";
response.setContentType("text/csv");
response.getWriter().write(domainString);
response.setHeader("Content-Disposition", "attachment; filename=\""
	    		+ filename + "\"");
 return null;
}
 
The following thing is strange : when the String domainString has less than 8000 chars, the file CSV is sent back to the client with the appropriate name and I can open it with EXCEL. When I exceed 8000 chars, I cannot get the response with a CSV format, but the response is directly sent to the browser as a String (domainString) printed directly in the browser page with the URL /getViewdomainReport.htm. That is I exceed the capacity of a sent file with the method write. I think that the fact that it is sent in a CSV format has no importance. It would be the same with a html format or else. It is surely the size of the response which is limited. What can I do ? is it a buffer matter ? how can I get my 19000 chars in my CSV file so I can open it with EXCELL ?
If you can help me, thank you in advance

Comments

807589
Use response.getOutputStream() and flush the string there.
796440
Don't crosspost. It wastes people's time when they repeat each others' answers.

[http://forums.sun.com/thread.jspa?threadID=5338772&tstart=0]
[http://forums.sun.com/thread.jspa?threadID=5338771&tstart=0]
796440
ansat27 wrote:
Use response.getOutputStream() and flush the string there.
If flushing is the issue, then just flush the Writer. That propagates through to the underlying stream(s).
darrylburke
Please don't cross post. As your thread in New to Java has the largest number of replies, please continue in that thread.
[http://forums.sun.com/thread.jspa?threadID=5338772]

I'm locking this thread and the one you posted in Java Servlet.

db
1 - 4
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 7 2008
Added on Oct 10 2008
4 comments
103 views