Strange behavior while returning csv file from spring controller

Posted by Fanooos on Stack Overflow See other posts from Stack Overflow or by Fanooos
Published on 2010-12-29T09:48:24Z Indexed on 2010/12/29 10:54 UTC
Read the original article Hit count: 195

I working in a spring application which have an action method that returns a CSV file.

This action works fine but in some cases it throws a predefined exception (MyAppException).

I have another method that is annotated @ExceptionHandler(MyAppException.class)

In the exception handler method I return another csv file but with different contents.

The code that returns the csv file is almost the same in the two methods.

List<String[]> list= new ArrayList<String[]>();
list.add(new String[]{
   integrationRequestErrorLog.getErrorMessage(),
   Long.toString(integrationRequestErrorLog.getId()),
   Integer.toString(integrationRequestErrorLog.getErrorCode())
});
CSVWriter writer = new CSVWriter(response.getWriter(), ',');
writer.writeAll(list);
writer.close();

the difference between the two method is the list of contents.

In the first method the file is returned normally while in the exception handler method I have a strange behavior.

The exception handler method works fine with Opera browser while it gives me a 404 with FireFox.

Opera browser give me 404 also but it download the file while firefox does not?

Really I do not understand what is the difference here.

© Stack Overflow or respective owner

Related posts about java

Related posts about spring