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

  • Compressing rendered jsp pages

    Hi,

    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
    Code:
      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,

    Jørgen
    Last edited by jbang; Dec 30th, 2005, 04:00 PM.

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

    Bob

    Comment


    • #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.

      /Jørgen

      Comment


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

        Code:
        	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?

        /Jørgen

        Comment


        • #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,
          Jørgen

          Comment

          Working...
          X