You cannot upload a file and update / redirect. I will try to explain the reasons. The flow of requests is shown here: 
where the yellow circle is your controller. When you return the name of the view, the front controller looks for the appropriate view template (just jsp, tiles, or others, depending on the view resolution configured), receives a response and writes the generated html code (or not html).
In your case, you do the following:
response.getOutputStream().write(baos.toByteArray()); response.getOutputStream().close(); response.getOutputStream().flush();
After this action, spring will not be able to open the response and write an updated page (because you are doing this earlier). Thus, you can change your method signature to:
public void exportToXML(HttpServletResponse response, Model model, @ModelAttribute(FILTER_FORM) ScreenModel form, BindingResult result, OutputStream out, HttpSession session) throws IOException {
and delete the last "return VIEW_NAME". Nothing will change.
yname source share