Announcement Announcement Module
No announcement yet.
Compressing rendered jsp pages Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Compressing rendered jsp pages


    I need some help with the following problem: The system I am working on is able to produce html reports. Sometimes these reports get rather large, so the users wish to get a zip-file containing the html report file.

    The reports are created with standard Spring MVC and JSP and in the controller I have something like
      protected ModelAndView onSubmit(HttpServletRequest request,   HttpServletResponse response,
                                      Object command, BindException errors) throws Exception {
            return new ModelAndView(getSuccessView(), "model", model);
    What I would like to do is from the controller to somehow
    • get the view to render the jsp producing the html
    • create a zip-file with the html report
    • write the contents of the zip-file and the appropriate contenttype into the response
    • and let the onSubmit method return null.

    So how do I render the jsp page from within the controller?

    Is there a more elegant way to solve this?

    Best regards from snowy Denmark,

    Last edited by jbang; Dec 30th, 2005, 03:00 PM.

  • #2
    If the problem is just download time, then you should just be able to enable mod_gzip - - or if you're unlucky enough to be using IIS, the MS equivalent (assuming there is one).



    • #3
      Actually it is part of the requirements on this assignment and I guess the problem is not download time (I have already enabled compression in my Tomcat setup) but that the users would like to have this feature to be able to archive reports.



      • #4
        The DispatcherServlet class has a method which will let me render the jsp page:

        	protected void render(ModelAndView mv, HttpServletRequest request, HttpServletResponse response)
        The DispatcherServlet is defined in the web.xml file, but how do I gain access to the DispatcherServlet object from my controller so that I can call the method mentioned above?



        • #5
          Still haven't solved it yet... :-(

          I thought about using another approach: The HandlerInterceptor has a afterCompletion method which might be useful. Maybe I could add my own HandlerInterceptor that will take the contents of the response, compress it and update the response with zip-file, but I am not sure if you can actually change the response object in the afterCompletion method?

          Comments? Alternative solutions?

          Best regards,