Skip to main content

[JIRA] Commented: (SERVLET_SPEC-66) Need way to track progress of requests; proposal included

  • From: "beamerblvd (JIRA)" <jira-no-reply@...>
  • To: issues@...
  • Subject: [JIRA] Commented: (SERVLET_SPEC-66) Need way to track progress of requests; proposal included
  • Date: Mon, 11 Mar 2013 13:36:53 +0000 (GMT+00:00)
  • Auto-submitted: auto-generated


    [ 
http://java.net/jira/browse/SERVLET_SPEC-66?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=358133#action_358133
 ] 

beamerblvd commented on SERVLET_SPEC-66:
----------------------------------------

I know this suggestion is pushing the line for Servlet 3.1, but I think it's 
a big improvement worth consideration. If there's anything I can do to help, 
I'm willing to drop whatever I'm working on to make it happen. I'm hoping 
there's time for just one more thing for Servlet 3.1.

If it comes to choosing between this and issue #67, 67 can definitely wait 
until 3.next, because it has a workaround. This issue, unfortunately, *does 
not have a workaround*.

> Need way to track progress of requests; proposal included
> ---------------------------------------------------------
>
>                 Key: SERVLET_SPEC-66
>                 URL: http://java.net/jira/browse/SERVLET_SPEC-66
>             Project: servlet-spec
>          Issue Type: Improvement
>         Environment: n/a
>            Reporter: beamerblvd
>   Original Estimate: 2 hours
>  Remaining Estimate: 2 hours
>
> Servlet 3.0 added multipart request processing to, in part, make handling 
> file uploads easier (and easier it did make it). Before 3.0, many users 
> used Commons FileUpload to accomplish this task. However, 3.0's multipart 
> processing did not, unfortunately, completely eliminate the need for 
> FileUpload. One of the major features lacking is the ability to track the 
> progress of a large request.
> This feature is sometimes called "file upload progress," but that name is 
> misleading. It's actually "request progress," and it's the ability to 
> measure and periodically report the number of bytes actually received 
> versus the number of bytes indicated in the "Content-Length" header. As I 
> propose below, I believe this should be relatively easy to add to the 
> servlet spec, relatively easy to implement, and quite easy to use.
> As proposed, this is independent of protocol (not strictly tied to 
> HTTP/multipart/Content-Length). That could be changed, but I think this 
> makes sense.
> First, create a new interface:
> {code:title=ServletRequestProgressListener}
> package javax.servlet;
> public interface ServletRequestProgressListener
> {
>     /**
>      * Called whenever the number of bytes read changes, at least every 64 
> kilobytes.
>      *
>      * @param bytesRead The number of bytes that have been read so far, at 
> least 0
>      * @param bytesExpected The number of bytes expected to be read, -1 if 
> unknown
>      * @param itemsRead The number of items (parts in an HTTP multipart) 
> processed so far
>      */
>     void update(long bytesRead, long bytesExpected, int itemsRead);
>     /**
>      * Called whenever the request has ended, either by being canceled or 
> completed, 
>      * normally or abnormally.
>      */
>     void destroy();
> }
> {code}
> Next, add a method to {{ServletRequest}}:
> {code:title=ServletRequest}
> ...
>     /**
>      * Attaches a progress listener to this request. Progress listeners 
> must be attached in
>      * a filter, before the request gets to the Servlet, in order to be 
> effective.
>      * 
>      * @param progressListener The progress listener to update when the 
> bytes read increases
>      * @throws UnsupportedOperationException if the protocol does not 
> support progress listeners
>      */
>     void setProgressListener(ServletRequestProgressListener 
> progressListener);
> ...
> {code}
> Because the listener can be a source of performance problems, containers 
> would only be required to call {{update}} (1) when first attached, and (2) 
> every 64 kilobytes. Containers may call it more often, but do not have to. 
> As proposed, I estimate 30 minutes to create the proposed interfaces and 
> 1.5 hours to update the servlet specification documentation. Should only 
> take 2-3 hours to add to the Tomcat implementation based on my examination 
> of the code. Can't speak for the other implementations.
> Using multipart as the primary example, since multipart processing is 
> completed before the Servlet gets the request, the listener would have to 
> be attached in a filter. A typical use case would be to create a listener 
> and add it to a session so that it can later be queried by some Ajax call:
> {code:title=Psuedo-Code}
> ...
>     public void doFilter(ServletRequest request, ServletResponse response, 
> FilterChain chain)
>     {
>         if(request-is-large)
>         {
>             MyProgressListener listener = new MyProgressListener(request);
>             request.getSession().addAttribute("progressListener", listener);
>             request.setProgressListener(listener);
>         }
>     }
> ...
> {code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://java.net/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


[JIRA] Created: (SERVLET_SPEC-66) Need way to track progress of requests; proposal included

beamerblvd (JIRA) 03/10/2013

[JIRA] Commented: (SERVLET_SPEC-66) Need way to track progress of requests; proposal included

beamerblvd (JIRA) 03/10/2013

[JIRA] Issue Comment Edited: (SERVLET_SPEC-66) Need way to track progress of requests; proposal included

beamerblvd (JIRA) 03/10/2013

[JIRA] Issue Comment Edited: (SERVLET_SPEC-66) Need way to track progress of requests; proposal included

beamerblvd (JIRA) 03/10/2013

[JIRA] Commented: (SERVLET_SPEC-66) Need way to track progress of requests; proposal included

Eugene Chung (JIRA) 03/11/2013

[JIRA] Commented: (SERVLET_SPEC-66) Need way to track progress of requests; proposal included

beamerblvd (JIRA) 03/11/2013

[JIRA] Commented: (SERVLET_SPEC-66) Need way to track progress of requests; proposal included

beamerblvd (JIRA) 03/11/2013

[JIRA] Commented: (SERVLET_SPEC-66) Need way to track progress of requests; proposal included

beamerblvd (JIRA) 03/11/2013
 
 
Close
loading
Please Confirm
Close