1

First of all a greeting and thanks in advance.

The reason for my creating this thread is because of an error that it generates when trying to load a file with

what I want is to capture a file, regardless of its extension, send it to the controller and then convert it to bytearray to store it in a postgre sql database.

<div class="row">
              <div class=" text-mini col-lg-12 col-md-6 col-xs-6">
                <h:form enctype="multipart/form-data">
                <h:panelGrid columns="2">
                    <h:outputLabel value="Cargar archivo" for="fileUpload" />
                    <h:inputFile value="#{fileUploadFormBean.fileUpload}" id="fileUpload" />
                    <h:commandButton value="Cargar"/>
                </h:panelGrid>
            </h:form> 
           </div>
             </div>

             <div class="row">
              <div class="col-lg-12">
               <h:panelGrid rendered="#{not empty(fileUploadFormBean.fileUpload)}" columns="2"  >
                  
                  <h:outputText value="fileName:" />
                  <h:outputText value="#{fileUploadFormBean.fileUpload.submittedFileName}" />
                  <h:outputText value="contentType:" />
                  <h:outputText value="#{fileUploadFormBean.fileUpload.contentType}" />
                  <h:outputText value="size:" />
                  <h:outputText value="#{fileUploadFormBean.fileUpload.size}" />
               </h:panelGrid>
              </div>
             </div>

package com.esmero.cl.mvno.ticketin.controller;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.servlet.http.Part;


@ManagedBean(name = "filecontroller")
@ViewScoped
public class UpLoadFileController implements Serializable{
 private static final long serialVersionUID = 1L;


     private Part fileUpload;

     /**
      * Creates a new instance of FileUploadFormBean
      */
     public UpLoadFileController() {
     }

     public Part getFileUpload() {
         return fileUpload;
     }

     public void setFileUpload(Part fileUpload) {
         this.fileUpload = fileUpload;
     }

}
 

enter image description here enter image description here

  • For now, I'm only interested in being able to send the file to the controller. but this error generates me javax.servlet.ServletException: UT010016: Not a multi part request io.undertow.servlet.spec.HttpServletRequestImpl.loadParts(HttpServletRequestImpl.java:518) io.undertow.servlet.spec.HttpServletRequestImpl.getParts(HttpServletRequestImpl.java:469) com.sun.faces.renderkit.html_basic.FileRenderer.decode(FileRenderer.java:91) javax.faces.component.UIComponentBase.decode(UIComponentBase.java:832) – Víctor Eduardo Duque Rosales Mar 01 '19 at 16:08
  • [See this question](https://stackoverflow.com/questions/27677397/how-to-upload-file-using-jsf-2-2-hinputfile-where-is-the-saved-file) – Jitendra Kumar Mar 02 '19 at 10:39

0 Answers0