Announcement Announcement Module
No announcement yet.
Progress bar in Spring Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Progress bar in Spring

    Hi All,

    I need to implement a progress bar for file uploading. I have downloaded code for this in ajax but it is showing some errors. I Kept the lines bold in which i am getting errors.
    The errors are:
    1. prepareFileupload(String) is undefined for AjaxFileUploadMultipartResolver
    2. MultipartParsingResult can not be resolved or is not a type
    parseFileItems(List,String) is undefined for the type AjaxFileUploadMultipartResolver

    I think there might some code missed.
    can anybody please tell me the solution for my problem?

    * Copyright 2002-2005 the original author or authors.
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.

    package com.hillert.upload.web.ajax;

    import java.util.List;

    import javax.servlet.ServletContext;
    import javax.servlet.http.HttpServletRequest;

    import org.apache.commons.fileupload.FileItemFactory;
    import org.apache.commons.fileupload.FileUpload;
    import org.apache.commons.fileupload.FileUploadBase;
    import org.apache.commons.fileupload.FileUploadException;
    import org.apache.commons.fileupload.servlet.ServletFileU pload;
    import org.springframework.web.multipart.MaxUploadSizeExc eededException;
    import org.springframework.web.multipart.MultipartExcepti on;
    import org.springframework.web.multipart.MultipartHttpSer vletRequest;
    import org.springframework.web.multipart.commons.CommonsM ultipartResolver;
    import ultipartHttpServletRequest;

    import be.telio.mediastore.ui.upload.MonitoredDiskFileIte mFactory;
    import be.telio.mediastore.ui.upload.UploadListener;

    * This class extends Spring's CommonsMultipartResolver (Spring 2.0 M4)
    * and overrides the resolveMultipart method. A few lines of code have
    * been added to that method.
    * @author Gunnar Hillert
    * @see org.springframework.web.multipart.commons.CommonsM ultipartResolver
    public class AjaxFileUploadMultipartResolver extends CommonsMultipartResolver {

    * Constructor.
    public AjaxFileUploadMultipartResolver() {

    * Constructor for standalone usage. Determines the servlet container's
    * temporary directory via the given ServletContext.
    * @param servletContext
    * the ServletContext to use
    public AjaxFileUploadMultipartResolver(ServletContext servletContext) {

    public MultipartHttpServletRequest resolveMultipart(
    HttpServletRequest request) throws MultipartException {
    String encoding = determineEncoding(request);
    FileUpload fileUpload1 =
    prepareFileUpload(encoding); //renamed fileUpload to fileUpload1

    // Beginn of added code
    UploadListener listener = new UploadListener(request, 30);
    FileItemFactory factory = new MonitoredDiskFileItemFactory(listener);
    ServletFileUpload fileUpload = new ServletFileUpload(factory);
    fileUpload.setHeaderEncoding(fileUpload1.getHeader Encoding());
    //end of added code

    try {
    List fileItems = ((ServletFileUpload) fileUpload)
    MultipartParsingResult parsingResult = parseFileItems(fileItems,

    return new DefaultMultipartHttpServletRequest(request,
    parsingResult.getMultipartFiles(), parsingResult
    } catch (FileUploadBase.SizeLimitExceededException ex) {
    throw new MaxUploadSizeExceededException(fileUpload.getSizeM ax(),
    } catch (FileUploadException ex) {
    throw new MultipartException(
    "Could not parse multipart servlet request", ex);


  • #2
    Which version of Spring are you using? The methods you mention are available in the 2.0 version of Spring. So I guess you are using 1.2.x or older.


    • #3
      Re:Progress bar in Spring

      I am using spring 1.2.8. I will download Spring 2.0 and will try it. Thank you very much for your information.


      • #4
        This solution works form me: