0

I have an application that I deploy in Tomcat. When I run app it generate static data (js, css, html etc) for report with html report page and put it in user.home directory. After that I want to redirect to that html report page. I've tried to redirect with ModelAndView, RedirectView, "redirect:/" and etc. but all browsers show me ERR_UNSAFE_REDIRECT since I can't open external file from browser for security reasons. So how can I open that page from my app? Thank you in advance.

@GetMapping("/reports")
    public ModelAndView getReportsView() {
        return new ModelAndView("redirect:" + "C:/Users/…/html-reports/overview-tags.html");
    }
  • You can't. You need to generate the report and stream it via the HttpServletResponse instance you can specify as a method argument. https://stackoverflow.com/questions/27741283/return-file-from-spring-controller-having-outputstream – Alan Hay Jul 17 '19 at 07:53
  • Possible duplicate of [Downloading a file from spring controllers](https://stackoverflow.com/questions/5673260/downloading-a-file-from-spring-controllers) – Alan Hay Jul 17 '19 at 07:55
  • Thanks, it helps to copy that page in httpServletResponse but now I faced with problem how to show that page using static resources (as js and css styles, fonts etc) because page generated with that static data and when I copied through the stream I move only html! – pgsnikable Jul 17 '19 at 08:27

1 Answers1

0

Finally i solve my problem with Apache HTTPD server. In spring controller I redirect to Apache http server that configured to show static data in folder