commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From christopher.alexan...@novartis.com
Subject [fileupload] ServletFileUpload#isMultipartContent(HttpServletRequest) Always Evals to False
Date Thu, 06 Jan 2011 20:48:13 GMT
Hi all,

Dev Stack: [Java 1.6, Netbeans 6.9, WinXP, Glassfish 3.0.1]

I have created a filter to handle file uploads, however the function 
ServletFileUpload.isMultipartContent(HttpServletRequest) constantly 
evaluates to false - regardless what I do. Help would be appreciated! Here 
is the code...

Html:

<h:form enctype="multipart/form-data" method="POST" 
accept="application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document"

prependId="false">
                  <div id="app_input">
                      <fieldset>
                          <ul>
                              <li>
                                  <label for="">DTS Document 
File:</label><input type="text" id="fileName" class="file_input_textbox" 
readonly="readonly" />
                                                                <div 
class="file_input_div">
 <input type="button" value="Browse..." class="file_input_button" />
 <input type="file" class="file_input_hidden" onchange="javascript: 
document.getElementById('fileName').value = this.value" />
 <input id="upload_type" name="upload_type" type="hidden" 
value="#{cc.attrs.upload_type}" />
 <input id="uuid" name="uuid" type="hidden" value="#{cc.attrs.uuid}" />
                                                                </div>
                              </li>
                          </ul>
                      </fieldset>
                  </div>
                  <div id="app_input_nav">
                      <table cellpadding="0" cellspacing="0" border="0">
                          <tr>
                              <td id="app_input_nav_button" align="left" 
style="width:375px">
                                  <p:commandButton 
actionListener="#{template_New.onClose}" update="main_content_region" 
value="Close" />
                              </td>
                              <td id="app_input_nav_button" align="right" 
style="width:375px">
                                  <p:commandButton type="button" 
onclick="cdDTSDocUpload.show()" value="Next &raquo;" />
                              </td>
                          </tr>
                      </table>
                  </div>
              </h:form>

Filter:

package Nova.OTM.DTS.Filters;

import Novartis.OTM.DTS.UI.CCs.Helpers.FileUploadInfo;
import Novartis.OTM.DTS.UI.enumFileUploadType;
import java.io.File;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import javax.faces.context.FacesContext;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;

@WebFilter(filterName="FileUploadFilter", urlPatterns={"/*"})
public class FileUploadFilter implements Filter {
        @Override
        public void doFilter(ServletRequest request, ServletResponse 
response, FilterChain chain) throws IOException, ServletException {
                System.out.print("FileUploadFilter invoked.");
                        HttpServletRequest httpRequest = 
(HttpServletRequest) request;
                        if 
(ServletFileUpload.isMultipartContent(httpRequest)) {
                        ... Process...  // Never enters here!
                }
                chain.doFilter(request, response);
                        System.out.print("FileUploadFilter exited.");
}

Kind regards,

Chris
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message