JSF RI 1.0 File Uploads mit Multipart Filter

Hi there,
I already posted my problem - I need support for a basic file upload. My requirement is, that I want to access teh file data in a Managed Bean method and then decice what to to with it.
I decided to use Jason Hunters Multipart Filter, that comes with the oreilly servlet jar file. My problem with the following code is, that the upload() method is never called. I think the filter is not invoked, but I don't know why. Could anyone please see, if I am on the right track?
First, here is my web.xml with the filter:
     <!-- OReilly MultiPart Filter - by Jason Hunter -->
     <!-- JSF RI 1.0 cannot handle MutliPart Requests -->
<filter>
<filter-name>multipartFilter</filter-name>
<filter-class>com.oreilly.servlet.MultipartFilter</filter-class>
<!-- we do not specify a special directory, the servlet containers tmp directory is used
<init-param>
<param-name>uploadDir</param-name>
<param-value>/tmp</param-value>
</init-param>
-->
</filter>
<filter-mapping>
<filter-name>multipartFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
--> this code comes at the end of my web.xml, so after the jsf cotnroller servlet is configured, etc.
in my jsp page, I got this form:
<h:form enctype="multipart/form-data">
<table width="100%" border="1" cellspacing="2" cellpadding="2">
<tr>
<td width="25%" align="right">Bild</td>
<td width="75%"><input type="file" name="file"></td>
</tr>
<tr>
<td> </td>
<td><h:commandButton id="upload" action="#{uploadBean.upload}" value="#{messages.uploadFile}"/>
     </td>
</tr>
</table>
</h:form>
--> the file upload is done with a normal html tag, because there is no jsf tag for it.
then, here us may upload() method in the managed bean:
(the upload method is never called... why???? )
     public String upload()
          log.debug("entering upload()...");
          // Files can be read if the request class is MultipartWrapper
          // Init params to MultipartWrapper control the upload handling
          HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
          if (request instanceof MultipartWrapper)
               log.debug("The MultiPart Filter recognized the mulitpart request.");
                    // Cast the request to a MultipartWrapper
                    MultipartWrapper multi = (MultipartWrapper) request;
                    // Show which files we received
                    Enumeration files = multi.getFileNames();
                    while (files.hasMoreElements())
                         String name = (String) files.nextElement();
                         String filename = multi.getFilesystemName(name);
                         String type = multi.getContentType(name);
                         File f = multi.getFile(name);
                         log.debug("name: " + name);
                         log.debug("filename: " + filename);
                         log.debug("type: " + type);
                         if (f != null)
                              log.debug("length: " + f.length());
          return "upload";
THANX! it would be great to get this sample running!

Hello!
I have a photo which I store in MSSQL db as a BLOB so it looks like:
| |
| Photo |
| |
-----------------------+
| c:\my.jpg | choose |
-----------------------+
where
<f:verbatim>
<input name="photo" id="photo" type="file">
</f:verbatim>
is rendered into standard choose file dialog (unfortunately I can't change it).
So when user click "choose" it's able to select local file (a picture).
Then in textbox (input) appear the path (of course it can write it directly).
A click to the picture
a) launch javascript:
onclick="document.getElementById('photo').name='#{DatosPersonalesForm.foto}';"
that change image value (file name) so I could know which file to look for later:
<h:graphicImage value="#{DatosPersonalesForm.foto}" ...
b) after this id calls the actionListener:
<h:commandLink actionListener="#{DatosPersonalesForm.uploadPhoto}" ...
In DatosPersonalesForm I have foto property (with get/set) which store foto
public String getFoto()
public void setFoto()
The problem is how to return foto: I put an image in a session and get it from another servlet (registred in web.xml) which intercepts /images/* and return ones from the session.
I tried use Base64 encoding to embedd images directly, but it works only in Mozilla (even it's html 4.01).
here is my full DatosPersonalesForm.class (with some additional crap):
public class DatosPersonalesForm implements Observer, Serializable
private int idCentro = 1;
private CurrentClient client;
private String foto;
//private String data;
private Abonado abonado;
private Persona persona;
private DireccionTableModel direcciones;
public DatosPersonalesForm()
abonado = new Abonado();
persona = new Persona();
direcciones = new DireccionTableModel();
public void setClient(CurrentClient client)
this.client = client;
client.addObserver(this);
public void setIdCentro(int idCentro)
this.idCentro = idCentro;
direcciones.setIdCentro(idCentro);
public void setIdAbonado(int idAbonado)
if (idAbonado > 0)
try
abonado = AbonadoDAO.load(idAbonado, idCentro);
persona = PersonaDAO.load(idAbonado, idCentro);
catch (Exception ex)
FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
else
abonado = new Abonado();
persona = new Persona();
direcciones.setIdPersona(idAbonado);
public Abonado getAbonado() { return abonado; }
public void setAbonado(Abonado abonado) { this.abonado = abonado; }
public Persona getPersona() { return persona;}
public void setPersona(Persona persona) { this.persona = persona; }
public DireccionTableModel getDirecciones() { return direcciones; }
public void setDirecciones(DireccionTableModel direcciones) { this.direcciones = direcciones; }
//public String getData() { return data; }
public String getFoto()
if (persona != null)
try
Imagenes imagenes = ImagenesDAO.load(persona.getIdImagen(), idCentro);
if (imagenes != null)
foto = "/images/" + putImage(imagenes.getImagen());
//data = Base64Encoder.encode(imagenes.getImagen());
catch (Exception ex)
foto = "/img/photo_unavailable.jpg";
FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
return foto;
public void setFoto(String foto) { this.foto = foto; }
public void uploadPhoto(ActionEvent e)
// for which person to upload???
if (persona != null)
HttpServletRequest r = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
if (r instanceof ServletRequestWrapper)
ServletRequest req = ((ServletRequestWrapper)r).getRequest();
if (req instanceof MultipartRequestWrapper)
MultipartRequestWrapper request = (MultipartRequestWrapper)req;
byte[] photo = (byte[])request.getFiles().get(foto);
if (photo != null)
try
BufferedImage original = ImageIO.read(new ByteArrayInputStream(photo));
if (original == null) // not an image?
return;
BufferedImage scaled = new BufferedImage(128, 160, BufferedImage.TYPE_INT_RGB);
Graphics g = (Graphics2D)scaled.getGraphics();
g.drawImage(original,0,0,128,160,null);
g.dispose();
ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
ImageIO.write(scaled, "jpg", out);
photo = out.toByteArray();
catch (IOException ex)
FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
return;
Imagenes imagenes = new Imagenes();
imagenes.setIdCentro(idCentro);
imagenes.setIdImagenes(persona.getIdImagen());
imagenes.setImagen(photo);
try
ImagenesDAO.save(imagenes);
catch (Exception ex)
FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
return;
putImage(imagenes.getImagen());
public String clear()
if (client != null)
client.setIdAbonado(0);
// must be mapped in faces-config.xml
return "clear";
public void save(ActionEvent e)
try
if (persona.getIdPersona() == 0)
abonado.setIdCentro(idCentro);
persona.setIdCentro(idCentro);
Connection con = DatasourceFactory.getConnection();
try
con.setAutoCommit(false);
PersonaDAO.create(con, persona);
abonado.setIdAbonado(persona.getIdPersona()); // idPersona == idAbonado is autoGenerated by database
AbonadoDAO.create(con, abonado);
con.commit();
catch(SQLException ex)
con.rollback();
persona.setIdPersona(0);
FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
finally { con.close(); }
// notify all about client change
if (client != null)
client.setIdAbonado(persona.getIdPersona());
else
Connection con = DatasourceFactory.getConnection();
try
con.setAutoCommit(false);
PersonaDAO.save(con, persona);
AbonadoDAO.save(con, abonado);
con.commit();
catch(SQLException ex)
con.rollback();
FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
finally { con.close(); }
catch (Exception ex)
FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
direcciones.save(e);
private String putImage(byte[] image)
String name;
HttpSession ses = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false);
if (ses != null)
name = "photo_" + String.valueOf(idCentro) + "_" + String.valueOf(persona.getIdPersona()) + ".jpg";
HashMap map = (HashMap)ses.getAttribute("ImageMap");
if (map == null)
map = new HashMap();
ses.setAttribute("ImageMap", map);
map.put(name, image);
else
name = null;
return name;
public void update(Observable o, Object arg)
if (o instanceof CurrentClient)
CurrentClient bean = (CurrentClient)o;
setIdAbonado(bean.getIdAbonado());
Cheers,
D.
P.S. I live in Spain so in Spanish it's foto :-) Sometimes I got crazy coz neither Spanish nor English are my native languages...
More... in MultipartRequestWrapper you can easy remove
public Object getAttribute(String name) method. It's my intention to map messages to request properties for easy access (like check if message exists to change style of some textfield in case of error). Do you know the better way???

Similar Messages

  • File Uploading with two command button

    Hi all,
    After a long I return back.
    I am having a JSP page with some mandatory fields and one attach document field.
    I am using JSF framework so for file upload i used the tag <t:inputfileupload>, for compulsion fields I used the attribute required = true.
    My problem is,
    If i attach the file and click attach button before filling mandatory fields the action method is not called. Only after filling the mandatory fields the action method is called. What may be the reason for this?
    Is there any example for file uploading with in form and it has two separate command buttons?

    DHURAI wrote:
    Hi all,
    After a long I return back.
    I am having a JSP page with some mandatory fields and one attach document field.
    I am using JSF framework so for file upload i used the tag <t:inputfileupload>, for compulsion fields I used the attribute required = true.
    My problem is,
    If i attach the file and click attach button before filling mandatory fields the action method is not called. Only after filling the mandatory fields the action method is called. What may be the reason for this?My guess: you get validation errors, but you don't have a <h:messages/> in your JSF page so you don't see the error yourself. If you check your log files it will most likely be mentioned there.

  • File Upload problem: JSF, IBM WPS and Portlet - Please HELP Vey Very Urgent

    I want to upload a file from the front end using JSF and Portlets deployed on IBM WebSphere Portal.
    I have used Apache's commons file upload functionality as the file upload provided in JSF doesnot work with portlets and the action event is not invoked If I keep enctype="multipart/form-data". So I included 3 forms in my Faces JSP file.
    1) h:form = For displyign error message on screen
    2) html:form = Include the enctype="multipart/form-data" and the input type file for uploading. And a submit button
    3) h:form: Here I have a command link which is remotely excuted on click of sumit button in my html form. This is to invoke the action event in the pagecode to get the bean value from the context.
    Now in the my doView method in the portlet, isMultipartContent(httpservletrequest) always returns null as the content type is text/html and not multipart. Onclick of the submit button in the the html form I am calling a javascript function which sets the __LINK_TARGET__ to the command link in the 3rd h:form which will call the page code.
    The problem here is action is invoked only when I return false from the above javascript else it will trigger for the first time and from second time onwards it will not invoke the action event in the pagecode method. Whent the javascript function returns false, the content type is always text/html. However if I return "true" from the javascript the content type is multipart/form-data, but the action is not triggered for the second time. So basically when the javascript functions returns true, for the first click everything works perfectly. When it returns false, the content type is text/html, but the action is invoked in the page code every time.
    Returning always true would solve my problem with the content type, but the action with the command link will not get invoked always as its some type of problem with h:commanLink :(.
    I guess I gave too much info. Heres my code stepby step.
    Can somebody please tell me , how I should also invoke the action in the page code and get the content type as "multipart/form-data" at the same time.
    1:
    ======================= Faces JSP File: BPSMacro.jsp ====================
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <meta name="GENERATOR" content="IBM Software Development Platform">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <%@taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
    <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%>
    <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@taglib uri="http://www.ibm.com/jsf/html_extended" prefix="hx"%>
    <%@taglib uri="/WEB-INF/tld/j4j.tld" prefix="j4j"%>
    <%@taglib uri="/WEB-INF/tld/core.tld" prefix="core"%>
    <%@page language="java" contentType="text/html; charset=ISO-8859-1"
         pageEncoding="ISO-8859-1" session="false"%>
    <portlet:defineObjects />
    <link rel="stylesheet" type="text/css"
         href='<%= renderResponse.encodeURL(renderRequest.getContextPath() + "/theme/stylesheet.css") %>'
         title="Style">
    <script type="text/javascript">
    function formSubmit() {
         var formName2 = document.getElementById("proxy_form_main_").title;
         var formName1 = document.getElementById("BPSMacroFormId").title;
         document.getElementById("__LINK_TARGET__").value = document.getElementById("proxy_HD_COMMAND_").title;
         document.getElementById(formName2).submit();
         return false;
    </script>
    <f:view>
         <hx:scriptCollector id="bpsMacroScriptCollector">
              <f:loadBundle var="bps" basename="bordereauprocessingsystem" />
              <table bgcolor="#FFF9C3">
                   <tr>
                        <td><h:form id="BPSMacroFormMain" styleClass="form">
                             <table class="tablemiddle" cellspacing="0" cellpadding="0">
                                  <tr>
                                       <td><h:messages layout="table" styleClass="errormessage"
                                                 id="ValidationErrorMsg" /> </td>
                                  </tr>
                             </table>
                             <j4j:idProxy id="proxy_form_main_0_" />
                        </h:form></td>
                   </tr>
                   <tr>
                        <td>
                        <form id="BPSMacroFormId" enctype="multipart/form-data">
                        <table bgcolor="#FFF9C3">
                             <tr>
                                  <td height="36" width="324">Worksheet <input type="file"
                                       name="upfile" /></td>
                             </tr>
                                  <tr>
                                       <td align="center" width="324"><input TYPE="submit"
                                       onclick="return formSubmit();" value="Upload">
                                  </td>
                             </tr>
                        </table>
                        </form>
                        </td>
                   </tr>
                   <tr>
                        <td>
                        <h:form id="BPSMacroFormMain2" styleClass="form">
                             <table cellspacing="2" cellpadding="2" class="tablemiddle">
                                  <tbody>
                                       <tr>
                                            <td colspan="2" align="center"><h:commandLink
                                                 styleClass="commandLink" id="lnkuserdelete"
                                                 action="#{pc_BPSMacro.doIdUpload1Action}">
                                                 <hx:graphicImageEx
                                                      styleClass="graphicImageEx" id="imgBtnCreateUser"
                                                      value="/theme/images/btnUpload.gif" style="border:0;cursor:pointer"></hx:graphicImageEx>
                                                 <j4j:idProxy id="proxy_HD_COMMAND_" />
                                            </h:commandLink></td>
                                            <h:inputHidden id="dtSize"
                                                 value="#{pc_BPSMacro.fileDetailsList.clicked}">
                                                 <j4j:idProxy id="proxy_clicked_" />
                                            </h:inputHidden>
                                       </tr>
                                  </tbody>
                             </table>
                             <j4j:idProxy id="proxy_form_main_" />
                        </h:form>
                   </td>
                   </tr>
              </table>
         </hx:scriptCollector>
    </f:view>
    ================== END: FACES JSP FILE: BPSMacro.jsp ========================
    2:
    =================== Action event in the Page Code: BPSMacro.java ============
    public String doIdUpload1Action() {
              System.out.println("PageCode");
              FacesContext context = FacesContext.getCurrentInstance();
              BPSMacroDetailsDataBean fileDetails = (BPSMacroDetailsDataBean)context.getApplication().createValueBinding("#{fileDetails}").getValue(context);
              BPSMacroListDataBean fileDetailsList = (BPSMacroListDataBean)context.getApplication().createValueBinding("#{fileDetailsList}").getValue(context);
              PortletSession sess = (PortletSession)context.getExternalContext().getSession(false);
              sess.setAttribute("BPS_MACRO_CONTEXT", context, PortletSession.APPLICATION_SCOPE);
              sess.setAttribute("BPS_MACRO_FILE_DETAILS", fileDetails, PortletSession.APPLICATION_SCOPE);
              sess.setAttribute("BPS_MACRO_FILE_LIST", fileDetailsList, PortletSession.APPLICATION_SCOPE);
              HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
              boolean isMultipart = ServletFileUpload.isMultipartContent(request);
              request.getContentType();
              return "gotoBPSMacro";
    ============== END Of Page Code Action event ==============================
    3:
    ============== doView() Portlet method ================================
    public void doView(RenderRequest arg0, RenderResponse arg1)
         throws PortletException, IOException {
              String METHOD_NAME = "doView(RenderRequest arg0, RenderResponse arg1)";
              Logger.debug(this.getClass(), METHOD_NAME, "Entering BPSMacroPortlet");
              FacesContext context = FacesContext.getCurrentInstance();      
              PortletSession sess1 = arg0.getPortletSession(true);
              BPSMacroDetailsDataBean fileDetails = new BPSMacroDetailsDataBean();
              BPSMacroListDataBean fileDetailsList = new BPSMacroListDataBean();
              context = (FacesContext)sess1.getAttribute("BPS_MACRO_CONTEXT", PortletSession.APPLICATION_SCOPE);
              if(context != null){
                   fileDetails = (BPSMacroDetailsDataBean)sess1.getAttribute("BPS_MACRO_FILE_DETAILS", PortletSession.APPLICATION_SCOPE);
                   fileDetailsList = (BPSMacroListDataBean)sess1.getAttribute("BPS_MACRO_FILE_LIST", PortletSession.APPLICATION_SCOPE);
              sess1.removeAttribute("BPS_MACRO_CONTEXT", PortletSession.APPLICATION_SCOPE);
              sess1.removeAttribute("BPS_MACRO_FILE_DETAILS", PortletSession.APPLICATION_SCOPE);
              sess1.removeAttribute("BPS_MACRO_FILE_LIST", PortletSession.APPLICATION_SCOPE);
              HttpServletRequest servletRequest = (HttpServletRequest)arg0;
              PortletRequest pReq = (PortletRequest)arg0;
              HttpServletResponse servletResponse= (HttpServletResponse)arg1;
              System.out.println("\n\n Content Type" + servletRequest.getContentType());
              try{
                   if(context != null){
              boolean isFileMultipart = ServletFileUpload.isMultipartContent(servletRequest);
              System.out.println("\nFILE TO BE UPLOADED IS MULTIPART ? " + isFileMultipart);
              if(isFileMultipart){
                   FileItemFactory factory = new DiskFileItemFactory();
                   ServletFileUpload upload = new ServletFileUpload(factory);
                   List items = upload.parseRequest(servletRequest);
                   Iterator iterator = items.iterator();
                   while (iterator.hasNext()) {
                        FileItem item = (FileItem) iterator.next();
                        InputStream iStream = item.getInputStream();
                        ByteArrayOutputStream ByteArrayOS = new ByteArrayOutputStream();
                        int sizeofFile =(int) item.getSize();
                        byte buffer[] = new byte[sizeofFile];
                        int bytesRead = 0;
                        while( (bytesRead = iStream.read(buffer, 0, sizeofFile)) != -1 )
                             ByteArrayOS.write( buffer, 0, bytesRead );
                        String data = new String( ByteArrayOS.toByteArray() );
                        int k = 0;
                        //Check if the file is Refund or Premium
                        int dynamicArraySize = 0;// = st2.countTokens() * 9;
                        dynamicArraySize = st2.countTokens() * 9;
                        if (!item.isFormField() ){
                             File cfile=new File(item.getName());
                             String fileName = "";
                             String separator = "\\";
                             int pos = item.getName().lastIndexOf(separator);
                             int pos2 = item.getName().lastIndexOf(".");
                             if(pos2>-1){
                                  fileName =item.getName().substring(pos+1, pos2);
                             }else{
                                  fileName =item.getName().substring(pos+1);
                             File fileToBeUploaded=new File("C:\\Sal\\BPS MACRO\\FileTransfer\\Desti", fileName);
                             item.write(fileToBeUploaded);
                             validate.displaySuccessMessage(context);
              }catch(Exception e){System.out.println(e);
              Logger.debug(this.getClass(), METHOD_NAME, "Leaving BPSMacroPortlet");
              super.doView(arg0, arg1);
    ==== END: doView method in the portle class. ================================
    Thanks.

    one more question. Is there a way where I can submit two forms ?
    Thats is submit 2nd form only when the first form is submitted.
    I tried this it works.
    function formSubmit(){
    document.form1.submit();
    alert();
    document.form2.submit();
    But If I dont put an alert(basically it disables the parent page) in between, only the second form is submitted.
    If I put a delay of say 3 seconds in between then it will throw a SOCKET CLOSED error in the code triggered due to first form submit.
    Thus disabling the paresnt page for a few seconds is reolving my problem.
    Any ideas ?
    Well Basically when the Alert pop's up the parent page "STALLS" and thus the form2 does not submit till I click on OK, Is there a way I can stall the browser/Parent JSP page using JAVA SCRIPT ??
    Edited by: hector on Oct 9, 2007 11:09 AM
    Edited by: hector on Oct 9, 2007 2:12 PM

  • File Uploading in JSF

    I am facing problem with File Uploding. :(( Could you please provide me some pointers for this.
    If possible detailed example is good for me as I am new to JSF
    I know how to use Jakartas File Upload Component. Can you provide me some pointers regarding this in JSF.
    Thanks
    Sudhakar

    I appretiate if you could point me out to the location of file upload component in the JSC. I know how to do it in servlets - just parse mime-multipart stream, but have no idea how to implement file upload/download in the JSC.
    Thank you for your help!

  • [JSF 2] File upload. Is this feature handled already?

    Hello,
    I need to allow a user to upload many files through the same form.
    This is what I would have done with Struts with this HTML code:
    <input type="file" name="file1" size="62" value="" />
    <input type="file" name="file2" size="62" value="" />
    <input type="file" name="file3" size="62" value="" />and the use of the org.apache.struts.upload.+FormFile+.
    However, I see no direct access to this feature through the JSF 2.0.
    no special <h:> tag.
    Reading old JSF code on the web, Tomahawk or Icefaces were used for this task.
    But today, Tomahawk doesn't support JSF 2, and Icefaces has an 2.0 Alpha 2 version that offers many features except File Upload that is still not working (for their update of the month of January: no updates since?).
    More than that, I was trapped few days ago by a strange behavior of JSF 2.0.
    Setting a "+multipart/form-data+" enctype to my form made JSF 2.0 loop on form validation, without ever submitting it.
    I am sure I didn't dreamed when it happened to me. And removing that enctype made the <h:form> returning to its default "+application/x-www-form-urlencoded+" enctype generation, and everything went fine then.
    But I know that attempting to upload files form a web page involve setting a "+multipart/form-data+" enctype on it... I feel doomed.
    All these questions make me return to you all, again. I wonder if you have succeed in using file upload with JSF 2.0 already.
    What mean do you use for that? Any component already exist that is compliant with JSF 2.0?
    Thanks for your help,
    Grunt.

    Are you aware that multi-part forms are not supported by Servlet implementations out of the box? You need to add a filter or manually invoked multi-part processing to support file uploads in any Servlet based solution.You're right. Until JSF 2 takes benefits from Servlet 3.0 who offers a getPart() function, a filter looks mandatory.
    Therefore, I tried the most advanced "faces" available for file upload: Primefaces 2.0.2, who provides a filter. However, it's not enough. The whole Primefaces solution for file uploading works chaotically. For me, it handles the multipart request well, but isn't able to join the listener the uploadFile tag defines, at submission time. I won't enter into details because this is not the good forum to discuss of that specific trouble of Primefaces. I did post my problem on Primefaces forum, and learned that this feature isn't working well yet.
    Icefaces doesn't offer the file uploading currently. Even its compatilibilty mode to version 1.8 is told (by the release note) not being able to handle file uploading yet.
    Richfaces just began its version 4.0.0 and is far from offering file uploading.
    If creating a working file upload was something possible yet, I can say for sure that any of these "faces" would had offered a working feature the sooner they could. But rather than that, I am reading ideas about some Mojarra 2 low level bugs that would disallow this feature to be implemented at the moment.
    It can't be only a story of a filter to write. That filter would have been written already hundred of times, else. A complete working solution would be shown everywhere.
    Currently, to summarize all, whatever a theorical reason is given, or a practical one (RFE missing, no time to write it, not a critical feature, or even unwished feature, depending of everyone thoughts in the previous replies to this post), file uploading is not available for JSF 2.0 by any existing way. No tier API or Faces is able to provide it, as it could be easily proven by the fact... that no samples are currently existing, working.
    Myself, but I might be alone believing it, I consider this missing feature like a JSF 2 flaw.
    I guess its a mojarra internal bug that disallows developers to provide a solution yet. This is not abnormal: JSF 2.0 has six months only, and can't work perfectly yet.
    But the more the correction of that feature will be delayed, and the more the developers will be in trouble, as nothing else is able to work in compatibility with JSF 2.0 (no existing working sample, I need to repeat it). And worst than that, this kind of flaw is one of those that in enterprise, at decision time, can makes JSF 2 discarded for another framework, less smart, but doing everything expected. It would be a shame, then.
    So, I think this problem should not be taken disdainfully. It's not a matter of "+You should only put a filter here+", "+It's not our work+", "+Please write our specs+", "+Wait, only wait, it will come for sure one day...+". Its more significant than that. It requires your study. The one of competent people like you are, and having goodwill. Because I understand that this is a problem that has been thrown away since a long time! But it is returning back to us like a boomerang at great speed.
    Among the features that JSF 2 offers and the ones that are currently under development, they are many, many of them, that will look secondary if at the end of all, file uploading isn't available.
    Regards,
    Grunt.

  • Error while during file upload in JSF

    Hi
    I do get this error while uploading a file in JSF .
    org.apache.myfaces.webapp.filter.MultipartRequestWrapper.parseRequest(MultipartRequestWrapper.java:134)
         at org.apache.myfaces.webapp.filter.MultipartRequestWrapper.getParameter(MultipartRequestWrapper.java:163)
         at javax.servlet.ServletRequestWrapper.getParameter(ServletRequestWrapper.java:157)
         at com.sun.faces.context.RequestParameterMap.get(ExternalContextImpl.java:673)
         at jsf.PagePhaseListener.afterPhase(PagePhaseListener.java:18)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:211)
    Can anybody wat i must do

    thanks....
    but that answer is not solve my question. Actually i want to know.. can we develope a custom tag in JSF for file upload......

  • File Upload Problem in JSF

    Hi all,
    I have a problem in file upload. I have a file upload third party component which uploads the file with the filter action depending on the url. My requirement is to trace the uploaded filename for addressing it with the database record. So I need the filename in my backing bean to store it in the database. Ho can i get the filename from view page to backing bean. Any Ideas and help please.
    Many thanx,
    vijaycanaan

    Mr BalusC,
    Yes Iam talking about a custom made upload component. The fileupload tutorials u send are good but my requirement is not meeting them. Among my requirements one is mutilple file uploads in the single view page. This is possible at present with my custom upload componet. Only if the problem gets solved. Any way once again please think on my problem and give your solution on it.
    Here is my problem:
    The problem is I have to access the components from view page which this kind of requirement possible in jsp by request parsing which results the key value pairs of the form components. This same thing/way I should get in backing bean from JSF view page.
    The solution I want may like as follows.
    Note this code is incorrect and wrong but for to understand my requirement.
    someobject.getComponentIdValue("clientID"); which returns a string value as d:\images\Tutle.jpg
    The clientID is upload file component' Id . In the request it may be the key associated with value as file complete path. By this kind of way my upload filter is able to get the orignal file. Ok i need this in my  backing bean to get the orignal filename to insert into the database. Please for this give the solution or reply.many thanx,
    vijaycanaan.

  • Useful Code of the Day:  Multipart Form File Upload

    So, you want to upload files to your web server, do ya? Well, I've seen this topic posted a few times in the last month or so and many of the response I've seen here haven't included definitive answers. Of course, the actual problems vary, but ultimately, a bunch of people want to do file upload from an applet or application to an existing file upload script (CGI, PHP, JSP, etc.) on a web server. And invariably, there are problems with formatting the HTTP request to get things working.
    Well, I had a need to do the same thing. I realize there are other solutions out there, such as some sample code that comes with Jakarta Commons Upload. But since we all like reusable code, and we also all seem to like reinventing wheels, here's my go at it: MultiPartFormOutputStream!
    MultiPartFormOutputStream is a specialized OutputStream-like class. You create your URLConnection to the server (a static method included can do this for a URL for you, as some of the settings, doInput and doOutput specifically, seem to confuse people). Then get the OutputStream from it and create a boundary string (a static method to create one is provided as well) and pass them to the constructor. Now you have a MultiPartFormOutputStream which you can use to write form fields like text fields, checkboxes, etc., as well as write file data (from Files, InputStreams or raw bytes).
    There are some convenience methods for writing primative type values as well as strings, but any higher level objects (aside from Files or InputStreams) aren't supported. (You can always serialize and pass the raw bytes.)
    Sample usage code is below. Also, any recommendations for improvement are requested. The code was tested with the Jakarta Struts.
    import java.io.*;
    import java.net.*;
    * <code>MultiPartFormOutputStream</code> is used to write
    * "multipart/form-data" to a <code>java.net.URLConnection</code> for
    * POSTing.  This is primarily for file uploading to HTTP servers. 
    * @since  JDK1.3
    public class MultiPartFormOutputStream {
          * The line end characters. 
         private static final String NEWLINE = "\r\n";
          * The boundary prefix. 
         private static final String PREFIX = "--";
          * The output stream to write to. 
         private DataOutputStream out = null;
          * The multipart boundary string. 
         private String boundary = null;
          * Creates a new <code>MultiPartFormOutputStream</code> object using
          * the specified output stream and boundary.  The boundary is required
          * to be created before using this method, as described in the
          * description for the <code>getContentType(String)</code> method. 
          * The boundary is only checked for <code>null</code> or empty string,
          * but it is recommended to be at least 6 characters.  (Or use the
          * static createBoundary() method to create one.)
          * @param  os        the output stream
          * @param  boundary  the boundary
          * @see  #createBoundary()
          * @see  #getContentType(String)
         public MultiPartFormOutputStream(OutputStream os, String boundary) {
              if(os == null) {
                   throw new IllegalArgumentException("Output stream is required.");
              if(boundary == null || boundary.length() == 0) {
                   throw new IllegalArgumentException("Boundary stream is required.");
              this.out = new DataOutputStream(os);
              this.boundary = boundary;
          * Writes an boolean field value. 
          * @param  name   the field name (required)
          * @param  value  the field value
          * @throws  java.io.IOException  on input/output errors
         public void writeField(String name, boolean value)
                   throws java.io.IOException {
              writeField(name, new Boolean(value).toString());
          * Writes an double field value. 
          * @param  name   the field name (required)
          * @param  value  the field value
          * @throws  java.io.IOException  on input/output errors
         public void writeField(String name, double value)
                   throws java.io.IOException {
              writeField(name, Double.toString(value));
          * Writes an float field value. 
          * @param  name   the field name (required)
          * @param  value  the field value
          * @throws  java.io.IOException  on input/output errors
         public void writeField(String name, float value)
                   throws java.io.IOException {
              writeField(name, Float.toString(value));
          * Writes an long field value. 
          * @param  name   the field name (required)
          * @param  value  the field value
          * @throws  java.io.IOException  on input/output errors
         public void writeField(String name, long value)
                   throws java.io.IOException {
              writeField(name, Long.toString(value));
          * Writes an int field value. 
          * @param  name   the field name (required)
          * @param  value  the field value
          * @throws  java.io.IOException  on input/output errors
         public void writeField(String name, int value)
                   throws java.io.IOException {
              writeField(name, Integer.toString(value));
          * Writes an short field value. 
          * @param  name   the field name (required)
          * @param  value  the field value
          * @throws  java.io.IOException  on input/output errors
         public void writeField(String name, short value)
                   throws java.io.IOException {
              writeField(name, Short.toString(value));
          * Writes an char field value. 
          * @param  name   the field name (required)
          * @param  value  the field value
          * @throws  java.io.IOException  on input/output errors
         public void writeField(String name, char value)
                   throws java.io.IOException {
              writeField(name, new Character(value).toString());
          * Writes an string field value.  If the value is null, an empty string
          * is sent (""). 
          * @param  name   the field name (required)
          * @param  value  the field value
          * @throws  java.io.IOException  on input/output errors
         public void writeField(String name, String value)
                   throws java.io.IOException {
              if(name == null) {
                   throw new IllegalArgumentException("Name cannot be null or empty.");
              if(value == null) {
                   value = "";
              --boundary\r\n
              Content-Disposition: form-data; name="<fieldName>"\r\n
              \r\n
              <value>\r\n
              // write boundary
              out.writeBytes(PREFIX);
              out.writeBytes(boundary);
              out.writeBytes(NEWLINE);
              // write content header
              out.writeBytes("Content-Disposition: form-data; name=\"" + name + "\"");
              out.writeBytes(NEWLINE);
              out.writeBytes(NEWLINE);
              // write content
              out.writeBytes(value);
              out.writeBytes(NEWLINE);
              out.flush();
          * Writes a file's contents.  If the file is null, does not exists, or
          * is a directory, a <code>java.lang.IllegalArgumentException</code>
          * will be thrown. 
          * @param  name      the field name
          * @param  mimeType  the file content type (optional, recommended)
          * @param  file      the file (the file must exist)
          * @throws  java.io.IOException  on input/output errors
         public void writeFile(String name, String mimeType, File file)
                   throws java.io.IOException {
              if(file == null) {
                   throw new IllegalArgumentException("File cannot be null.");
              if(!file.exists()) {
                   throw new IllegalArgumentException("File does not exist.");
              if(file.isDirectory()) {
                   throw new IllegalArgumentException("File cannot be a directory.");
              writeFile(name, mimeType, file.getCanonicalPath(), new FileInputStream(file));
          * Writes a input stream's contents.  If the input stream is null, a
          * <code>java.lang.IllegalArgumentException</code> will be thrown. 
          * @param  name      the field name
          * @param  mimeType  the file content type (optional, recommended)
          * @param  fileName  the file name (required)
          * @param  is        the input stream
          * @throws  java.io.IOException  on input/output errors
         public void writeFile(String name, String mimeType,
                   String fileName, InputStream is)
                   throws java.io.IOException {
              if(is == null) {
                   throw new IllegalArgumentException("Input stream cannot be null.");
              if(fileName == null || fileName.length() == 0) {
                   throw new IllegalArgumentException("File name cannot be null or empty.");
              --boundary\r\n
              Content-Disposition: form-data; name="<fieldName>"; filename="<filename>"\r\n
              Content-Type: <mime-type>\r\n
              \r\n
              <file-data>\r\n
              // write boundary
              out.writeBytes(PREFIX);
              out.writeBytes(boundary);
              out.writeBytes(NEWLINE);
              // write content header
              out.writeBytes("Content-Disposition: form-data; name=\"" + name +
                   "\"; filename=\"" + fileName + "\"");
              out.writeBytes(NEWLINE);
              if(mimeType != null) {
                   out.writeBytes("Content-Type: " + mimeType);
                   out.writeBytes(NEWLINE);
              out.writeBytes(NEWLINE);
              // write content
              byte[] data = new byte[1024];
              int r = 0;
              while((r = is.read(data, 0, data.length)) != -1) {
                   out.write(data, 0, r);
              // close input stream, but ignore any possible exception for it
              try {
                   is.close();
              } catch(Exception e) {}
              out.writeBytes(NEWLINE);
              out.flush();
          * Writes the given bytes.  The bytes are assumed to be the contents
          * of a file, and will be sent as such.  If the data is null, a
          * <code>java.lang.IllegalArgumentException</code> will be thrown. 
          * @param  name      the field name
          * @param  mimeType  the file content type (optional, recommended)
          * @param  fileName  the file name (required)
          * @param  data      the file data
          * @throws  java.io.IOException  on input/output errors
         public void writeFile(String name, String mimeType,
                   String fileName, byte[] data)
                   throws java.io.IOException {
              if(data == null) {
                   throw new IllegalArgumentException("Data cannot be null.");
              if(fileName == null || fileName.length() == 0) {
                   throw new IllegalArgumentException("File name cannot be null or empty.");
              --boundary\r\n
              Content-Disposition: form-data; name="<fieldName>"; filename="<filename>"\r\n
              Content-Type: <mime-type>\r\n
              \r\n
              <file-data>\r\n
              // write boundary
              out.writeBytes(PREFIX);
              out.writeBytes(boundary);
              out.writeBytes(NEWLINE);
              // write content header
              out.writeBytes("Content-Disposition: form-data; name=\"" + name +
                   "\"; filename=\"" + fileName + "\"");
              out.writeBytes(NEWLINE);
              if(mimeType != null) {
                   out.writeBytes("Content-Type: " + mimeType);
                   out.writeBytes(NEWLINE);
              out.writeBytes(NEWLINE);
              // write content
              out.write(data, 0, data.length);
              out.writeBytes(NEWLINE);
              out.flush();
          * Flushes the stream.  Actually, this method does nothing, as the only
          * write methods are highly specialized and automatically flush. 
          * @throws  java.io.IOException  on input/output errors
         public void flush() throws java.io.IOException {
              // out.flush();
          * Closes the stream.  <br />
          * <br />
          * <b>NOTE:</b> This method <b>MUST</b> be called to finalize the
          * multipart stream.
          * @throws  java.io.IOException  on input/output errors
         public void close() throws java.io.IOException {
              // write final boundary
              out.writeBytes(PREFIX);
              out.writeBytes(boundary);
              out.writeBytes(PREFIX);
              out.writeBytes(NEWLINE);
              out.flush();
              out.close();
          * Gets the multipart boundary string being used by this stream. 
          * @return  the boundary
         public String getBoundary() {
              return this.boundary;
          * Creates a new <code>java.net.URLConnection</code> object from the
          * specified <code>java.net.URL</code>.  This is a convenience method
          * which will set the <code>doInput</code>, <code>doOutput</code>,
          * <code>useCaches</code> and <code>defaultUseCaches</code> fields to
          * the appropriate settings in the correct order. 
          * @return  a <code>java.net.URLConnection</code> object for the URL
          * @throws  java.io.IOException  on input/output errors
         public static URLConnection createConnection(URL url)
                   throws java.io.IOException {
              URLConnection urlConn = url.openConnection();
              if(urlConn instanceof HttpURLConnection) {
                   HttpURLConnection httpConn = (HttpURLConnection)urlConn;
                   httpConn.setRequestMethod("POST");
              urlConn.setDoInput(true);
              urlConn.setDoOutput(true);
              urlConn.setUseCaches(false);
              urlConn.setDefaultUseCaches(false);
              return urlConn;
          * Creates a multipart boundary string by concatenating 20 hyphens (-)
          * and the hexadecimal (base-16) representation of the current time in
          * milliseconds. 
          * @return  a multipart boundary string
          * @see  #getContentType(String)
         public static String createBoundary() {
              return "--------------------" +
                   Long.toString(System.currentTimeMillis(), 16);
          * Gets the content type string suitable for the
          * <code>java.net.URLConnection</code> which includes the multipart
          * boundary string.  <br />
          * <br />
          * This method is static because, due to the nature of the
          * <code>java.net.URLConnection</code> class, once the output stream
          * for the connection is acquired, it's too late to set the content
          * type (or any other request parameter).  So one has to create a
          * multipart boundary string first before using this class, such as
          * with the <code>createBoundary()</code> method. 
          * @param  boundary  the boundary string
          * @return  the content type string
          * @see  #createBoundary()
         public static String getContentType(String boundary) {
              return "multipart/form-data; boundary=" + boundary;
    }Usage: (try/catch left out to shorten the post a bit)
    URL url = new URL("http://www.domain.com/webems/upload.do");
    // create a boundary string
    String boundary = MultiPartFormOutputStream.createBoundary();
    URLConnection urlConn = MultiPartFormOutputStream.createConnection(url);
    urlConn.setRequestProperty("Accept", "*/*");
    urlConn.setRequestProperty("Content-Type",
         MultiPartFormOutputStream.getContentType(boundary));
    // set some other request headers...
    urlConn.setRequestProperty("Connection", "Keep-Alive");
    urlConn.setRequestProperty("Cache-Control", "no-cache");
    // no need to connect cuz getOutputStream() does it
    MultiPartFormOutputStream out =
         new MultiPartFormOutputStream(urlConn.getOutputStream(), boundary);
    // write a text field element
    out.writeField("myText", "text field text");
    // upload a file
    out.writeFile("myFile", "text/plain", new File("C:\\test.txt"));
    // can also write bytes directly
    //out.writeFile("myFile", "text/plain", "C:\\test.txt",
    //     "This is some file text.".getBytes("ASCII"));
    out.close();
    // read response from server
    BufferedReader in = new BufferedReader(
         new InputStreamReader(urlConn.getInputStream()));
    String line = "";
    while((line = in.readLine()) != null) {
          System.out.println(line);
    in.close();------
    "Useful Code of the Day" is supplied by the person who posted this message. This code is not guaranteed by any warranty whatsoever. The code is free to use and modify as you see fit. The code was tested and worked for the author. If anyone else has some useful code, feel free to post it under this heading.

    I have a weird problem here. I'm using the Java POST (slightly altered for my purposes) mechanism but the receiving script doesn't receive any form variables (neither files nor regular form fields). If I try using the same receiving script with a regular upload form, it works. Because I've been pulling my hair out, I even went so far as to analyze the ip-packets. I can see that the file is actually sent through the Java POST mecahnism. Anybody any ideas. Here's the ip-packet of the failing upload:
    ----- Hypertext Transfer Protocol -----
    HTTP: POST /fotoxs/upload.cfm HTTP/1.1
    HTTP: Connection: Keep-Alive
    HTTP: Content-Type: multipart/form-data; boundary=-----------------------------fb2649be18
    HTTP: User-Agent: Mozilla/4.7 [en] (WinNT; U)
    HTTP: Accept-Language: en-us
    HTTP: Accept-Encoding: gzip, deflate
    HTTP: Accept: image/gif, image/jpeg, image/pjpeg, */*
    HTTP: CACHE-CONTROL: no-cache
    HTTP: Host: newmarc
    HTTP: Content-Length: 15511
    ----- Hypertext Transfer Protocol -----
    HTTP: -----------------------------fb2649be18
    HTTP: Content-Disposition: form-data; name="uploadFile"; filename="out.jpg"
    HTTP: Content-Type: image/jpeg
    HTTP: Data
    ....[data packets]
    The one that works (from the regular post) is as follows:
    ----- Hypertext Transfer Protocol -----
    HTTP: POST /fotoxs/upload.cfm HTTP/1.1
    HTTP: Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-gsarcade-launch, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
    HTTP: Referer: http://localhost:8500/fotoxs/test.cfm
    HTTP: Accept-Language: nl
    HTTP: Content-Type: multipart/form-data; boundary=---------------------------7d41961f201c0
    HTTP: Accept-Encoding: gzip, deflate
    HTTP: User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
    HTTP: Host: newmarc
    HTTP: Content-Length: 59022
    HTTP: Connection: Keep-Alive
    HTTP: Cache-Control: no-cache
    ----- Hypertext Transfer Protocol -----
    HTTP: -----------------------------7d41961f201c0
    HTTP: Content-Disposition: form-data; name="FiletoUpload"; filename="D:\My Documents\My Pictures\fotomarc.jpg"
    HTTP: Content-Type: image/pjpeg
    HTTP: Data
    ----- Hypertext Transfer Protocol -----
    HTTP: HTTP/1.1 100 Continue
    HTTP: Server: Microsoft-IIS/5.0
    HTTP: Date: Sun, 07 Mar 2004 17:14:41 GMT
    ....[data packets]
    One detail worth mentioning is that I don't read a file from harddisk, I'm streaming it directly to the connection outputstream from an image compression utility. But I can see the data in the ip-packets, and even if that somehow didn't work right, it doesn't explaing the fact that the receiving scripts reports no form fields whatsoever.
    Thanks,
    Marc

  • Multipart form (file upload) processing in providers

    Hello,
    Just want to find out if anyone has successfully implemented a file upload mechanism within a Portal channel.
    According to the Provider API (http://docs.sun.com/source/816-6428-10/com/sun/portal/providers/Provider.html), the wrapped request/response objects do not support several methods that are essential to process file uploads, namely "getContentLength" and "getInputStream". I am currently trying to use the Apache commons-fileupload utility which uses those methods to process file uploads. This is also the case for another popular file upload utility from servlets.com.
    Does anyone have any info/explanation regarding this limitation in Portal Server 6, and any workarounds to this issue. One workaround is to have a window popup that interacts directly with an external webapp.
    Any ideas/suggestions will be appreciated, thanks in advance.
    jeff

    Hi Jeff,
    The Sun ONE Portal Server DesktopServlet does not have the ability to process a request with the content encoding type of multipart/form-data. DesktopServlet does not pass the input stream for the request on to the Provider.
    To accomplish handling of multipart/form-data type requests, it is necessary to create a companion servlet or JSP that process the multipart/form-data. This servlet can then pass control back to the Portal channel. The data from the file can be shared between the servlet and the provider by using static Java members or by storing the data in a back-end database and then passing a reference to the data over to the provider.
    Sanjeev

  • File upload program by jsf

    I am doing one file upload program using
    <af:inputFile label="File to Upload" columns="90"
    value="#{FileProcessor.uploadedFile}"/>
    component..
    in Jdeveloper 11g i am getting the correct result,
    but when i'm tryin to run it in Jdeveloper jdevstudio10131 it is giving this error.
    java.io.EOFException: Per-request disk space limits exceeded. at oracle.adfinternal.view.faces.webapp.UploadedFileImpl.loadFile(UploadedFileImpl.java:187) at
    i want this file upload application to run in ecplise..but there it is not working..do i need so some to import some jar files??
    tomat 5.0 i'm using there..
    Or is there any otherway to upload file using jsf component which should work in eclipse-tomcat enviornment also..
    please help
    thanks

    Mr BalusC,
    Yes Iam talking about a custom made upload component. The fileupload tutorials u send are good but my requirement is not meeting them. Among my requirements one is mutilple file uploads in the single view page. This is possible at present with my custom upload componet. Only if the problem gets solved. Any way once again please think on my problem and give your solution on it.
    Here is my problem:
    The problem is I have to access the components from view page which this kind of requirement possible in jsp by request parsing which results the key value pairs of the form components. This same thing/way I should get in backing bean from JSF view page.
    The solution I want may like as follows.
    Note this code is incorrect and wrong but for to understand my requirement.
    someobject.getComponentIdValue("clientID"); which returns a string value as d:\images\Tutle.jpg
    The clientID is upload file component' Id . In the request it may be the key associated with value as file complete path. By this kind of way my upload filter is able to get the orignal file. Ok i need this in my  backing bean to get the orignal filename to insert into the database. Please for this give the solution or reply.many thanx,
    vijaycanaan.

  • File Upload with jsp & MultiPart

    Hi all,
    i've got a problem uploading a file from a multipart form.
    The file is correctly uploaded and i can open it, but I can't get the file name,
    In multipart.jsp fileName print out a null.
    Below the code. Can someone telle me where the error is?
    Thank's
    Kalvin
    this is the first page:
    prova.jsp:
    <form name="frmUp" action="multipart.jsp" method="POST" enctype="multipart/form-data">
    <input type="file" name="file"><br>
    <input type="submit">
    </form>
    multipart.jsp:
    <%
    String fileName = request.getParameter("nomeFile");
    String pathFile = "/myPath/";
    InputStream is = request.getInputStream();
    out.println("File name:"+fileName+"<br>");
    UploadFile uf = new UploadFile(pathFile, fileName);
    if (uf.upload(is))
         out.println("OK<br>");
    else
         out.println("NO OK <br>");
    %>

    you have to get the filename from UploadFile object probably. You definitely can't get it from request cuz multipart forms are handled specially. If it saves the file properly, then it's probably assuming a null filename means to use the name as it was uploaded, but UploadFile should be able to give you a File object for where the file was put.

  • JSF Calendar/ File Upload

    Can any one of you suggest me any tutorial about Calendar function? How to add the calendar component into Studio Creator? Highly appreciate your help.
    Also, I need help on File upload.

    Thanks for the information. But I have a question on Calendar component . I want the Calendar component to be open when user wants to enter a date. Otherwie it looks akward in a page to keep the component visible all the time. How do I do that? What I am thinking is, i want to make this small and upon clicking it will open the calendar and select date. Thanks for your help in advance.
    About Fileupload
    Do I have to copy any jar file from MyFaces. I am using SUN Studio Creator. Do I have to import anything?

  • Threading problem during File Upload with Apache faces upload tag

    First I am going to tell you "My Understanding of how JSF Apache Upload works, Correct me if i am wrong".
    1) Restores View (to show Input box and Browse button to facilitate users to select a file for upload)
    2) Translates Request Parameters to Component Values (Creates equivalent components to update them with request values).
    3) Validates Input(Checks to see whether the User has input the correct file)
    4) Updates Backing Bean or Model to reflect the values.
    5) Renders response to user.
    I am uploading huge files of sizes 400MB and above with the help of JSF apache extensions tag
    <h:form id="uploadForm" enctype="multipart/form-data">
    <x:inputFileUpload style="height:20px;" id="upload" value="#{backingbean.fileContents}" storage="file" size="50" />
    </h:form>
    In the backing bean
    private UploadedFile fileContents;
         public UploadedFile getFileContents() {
              return fileContents;
         public void setFileContents(UploadedFile fileContents) {
              System.out.println("File being uploaded...");
              this.fileContents = fileContents;
    Since, the file size is so huge, I am using temp folder to use for the apache tag instead of memory.
    In web.xml i am using like this
    <filter>
    <filter-name>ExtensionsFilter</filter-name>
    <filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>
    <init-param>
    <param-name>uploadMaxFileSize</param-name>
    <param-value>600m</param-value>
    </init-param>
    <init-param>
    <param-name>uploadThresholdSize</param-name>
    <param-value>10m</param-value>
    </init-param>
         <init-param>
    <param-name>uploadRepositoryPath</param-name>
    <param-value>/uploadfolder/</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>ExtensionsFilter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>
    The upload process is working perfectly fine.
    Now coming to the problem:
    Suppose one user is logging into the application & uploading say 400MB of files.
    Until these files are linked to the model objects as my understanding of step 2, if second user tries to open the application he gets stuck with the loading page.
    The page gets loaded only after the request files are linked to the component values(Step 2 above) and updates the backing bean's values.
    I don't see any error in the logs. User is getting stuck. The user is getting stuck only when uploading the files. The other operations like searching are not blocking any other activities performed by the user.
    Server used: IBM Application Server V6.0. CPU is normal, memory usage is normal.

    Dear friend,
    i am also trying to upload using the common file upload.
    when try to run the file error is coming
    can give some suggestion.
    can i use if concurrent user file upload at a time

  • JSF(2.1 & 2.2) upload problem Weblogic 12.1.1

    Hi all.
    I'm trying to configure an upload element with JSF, running on Weblogic 12.1.1.
    I tried this both with JSF 2.1 (custom component, custom filter) and the new h:inputFile tag in JSF 2.2
    And with both implementations I'm getting the same error from Weblogic: weblogic.servlet.utils.fileupload.SizeException: The field myElementId exceeds its maximum permitted  size of 0 characters
    I already found where the problem is coming from: Weblogic seems to ignore the max-file-size setting(part of the multipart-config tag) in the web.xml
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
       <multipart-config>
            <location>/tmp</location>
            <max-file-size>20848820</max-file-size>
            <max-request-size>418018841</max-request-size>
            <file-size-threshold>1048576</file-size-threshold>
          </multipart-config>
      </servlet>
    Without the <multipart-config> part, nothing happened when clicking the upload button. So Weblogic is using the multipart-config tag, but not the max-file-size tag.
    On Glashfish it all works fine. So the configuration seems to be OK. And the problem seems to be Weblogic related.
    Finally, to doublecheck, we modified the FacesServlet class (JSF 2.2, org.apache.myfaces 2.2.0-SNAPSHOT version) itself with the @MultipartConfig annotation
    @MultipartConfig(maxFileSize = 10485760L)
    public final class FacesServlet implements Servlet
    And this worked!
    so finally my question :-)
    How can I set the maxFileSize on Weblogic in a 'normal' way?  Am I missing something? Is there maybe a weblogic.xml setting for this?
    Thanks,
    Jorden

    problem seems to be solved by using the com,sun.faces 2.2.2 version

  • Problem with File Uploads

    Hello all. Has anybody successfully got the UploadFilter classes -- as listed in Hortsmann and Geary's "Core JSF" -- going?
    Everytime I submit a multipart form, I am not redirected to the appropriate next page (as specified in the navigation cases) . I have definitely set up the UploadFilter correctly, and any multipart form requests are getting parsed and uploaded into the correct directory. The only problem is that the resulting page isn't the one specified in faces-config.xml -- it's the original upload page.
    If I get rid of the multipart/form-data encoding for the form, it works "okay" (in the sense that the file upload no longer works, but the behaviour matches the navigation cases).
    I'm beginning to wonder whether the fact the form is a multipart form means that the submit button's action -- which is set to "submit", matching a value in faces-config.xml -- isn't being correctly parsed. Are there any "gotchas" I should be aware of in these cirumstances?

    Hi diritchie,
    perhaps that thread helps you.
    http://forum.java.sun.com/thread.jsp?forum=427&thread=473135
    There are posts of some clazzes, to enable upload.
    the clazzes are using Jakarta Commons FileUpload
    btw. in MyFaces there is allready an upload-component.
    Regards,
    Matthias

Maybe you are looking for

  • How to set up use of relative URLs for a BSP application

    Dear all, I need to access a BSP application through our external portal. This is failing because generated URLs are absolute URLs (they mention physical server name, not known of course on the internet) where they should be relative URLs (they use e

  • Very slow project "updating" - Is this unavoidable?

    Hello, we're migrating a fairly large application to BEA and having problems with long wait times when the project is rebuilt using Workshop. The project uses servlets/xsl, entity beans and session beans and connects to around 100 database tables. We

  • Not able to see slide show in MSPowerpoint 2011 for mac

    Hi, I am using MS office2011 for mac in my new macbook pro. I need to work more in ppt for my presentations, but i am not able to play sildeshow and my screen goes blank and system also hangs. I need to restart my system everytime in attempt to see s

  • My Effects Pallete is totally empty HELP (Mac)

    I just installed Photoshop Elements 6, and for some reason, there is nothing in my effects pallete, even when I click the tabs. I can't get to layer styles or anything. The files are on my computer and I have found them in Finder, but for some reason

  • Web AS - ERP 2005 ECC 5.0/6.0 training

    Hi experts! I am in urgent need to get training for installation and configuration for ERP 2005 ECC 5.0 or 6.0. Can any one recommend a training course to me? I am looking for a training course that will give me insight and experiense with installing