[gradebook2-dev] submit file grades, writing to response

Michael Wenk mjwenk at ucdavis.edu
Wed Mar 16 10:36:24 PDT 2011


We had this problem as well.  The way I solved it was not pretty.  Oh
and its jersey that gets a bit overprotective of the response object,
not GWT.  In 1.3.0 we went away from using a servlet and instead are
using REST via jersey for this.  What happens is jersey feels rather
strongly that it should be handling the response, and what ends up
happening is it hijacks the response if its not committed.   So what I
did is just commit the response after I use it.  Jersey still hates it
and logs an exception, but it is just sour grapes on the part of
jersey and becomes one more bit of log spam in the catalina.out.

Here's the method I made to commit the response:

        private void commitResponse(HttpServletResponse r)
        {
                // NOT really sure if it would be a good idea to try
to commit a response that had already been committed.
                if (!r.isCommitted())
                {
                        try
                        {
                                r.getWriter().flush();
                                r.getWriter().close();
                        }
                        catch (IOException ioe)
                        {
                                log.error("Caught IO exception while
committing response", ioe);
                        }
                }
        }

And then every place I manipulate the response, I call commitResponse
on it . If anyone can think of a better way, I'm definitely up to hear
it.

I think the permanent solution is to move away from using the
request/response like this.  My idea was to have some kind of action
system where submitFinalGrade returns an action object that the client
deals with, either by default or by some kind of client side
injection.  I'm unsure how feasible this is, as I'm unsure how
injection works client side, tho I understand gin can do it.

Mike

On Wed, Mar 16, 2011 at 10:17 AM, John Bush <john.bush at rsmart.com> wrote:
> We were attempting to cause a file download to occur when clicking the
> submit final grade option by implementing submitFinalGrade() in an
> InstitutionalAdvisor.  It appears GWT does not like writing to the response
> or redirecting.  Error attached.  Googling around I can see this is a common
> problem.
>
> So my question is how to deal with this without having to modify the gb2
> tool.  My first idea is to simply write the file into CHS set the
> appropriate permissions, and just train instructors on where the export file
> goes.  I welcome other ideas if you guys have any.
>
> java.lang.
> IllegalStateException
>     at
> org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:419)
>     at
> javax.servlet.http.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:118)
>     at
> javax.servlet.http.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:118)
>     at
> com.sun.jersey.spi.container.servlet.WebComponent$Writer.finish(WebComponent.java:254)
>     at
> com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:237)
>     at
> com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1029)
>     at
> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:941)
>     at
> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:932)
>     at
> com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:384)
>     at
> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:451)
>     at
> org.sakaiproject.gradebook.gwt.server.RestServlet.service(RestServlet.java:50)
>     at
> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:632)
>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
>     at
> org.springframework.web.servlet.mvc.ServletWrappingController.handleRequestInternal(ServletWrappingController.java:174)
>     at
> org.sakaiproject.gradebook.gwt.server.ServletWrappingController.handleRequestInternal(ServletWrappingController.java:132)
>     at
> org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
>
> --
> John Bush
> 602-490-0470
>
> _______________________________________________
> gradebook2-dev mailing list
> gradebook2-dev at collab.sakaiproject.org
> http://collab.sakaiproject.org/mailman/listinfo/gradebook2-dev
>
>



-- 
Michael Wenk
mjwenk at ucdavis.edu


More information about the gradebook2-dev mailing list