

Just check the servlet name in its definition.

To get uploading files work in JSF, it should at least be mapped on the servlet name of the FacesServlet, which may differ per environment.

It should filter multipart/form-data requests and make use of the commons-fileupload to parse the request. The commons-logging and commons-el JAR's are required by the core of the Tomahawk component library.Īfter adding the JAR's, open your web.xml and add the ExtensionsFilter to it. They contains a multipart/form-data parser and several I/O utilities respectively. The commons-fileupload and commons-io JAR's are required for the file upload. The Tomahawk JAR is the Tomahawk component library itself which under each contains the t:inputFileUpload component and the ExtensionsFilter. The version numbers doesn't matter that much, as long as you get the newest. Back to top Integrating Tomahawk in MojarraĪssuming that you already have a Mojarra environment, you just need to add at least the following JAR's to the classpath, e.g. But the MyFaces Tomahawk component library, which can also be integrated in Sun JSF Reference Implementation Mojarra, provides us the t:inputFileUpload component. Unfortunately the Sun JSF Reference Implementation Mojarra doesn't provide a component out of the box which renders a input type="file" field. As stated in the HTML specification you have to use the POST method and the enctype attribute of the form have to be set to "multipart/form-data". To browse and select a file for upload you basically need a HTML input type="file" field in the form. That will work only if the server as well as the client runs on the same machine and that wouldn't occur in real life. Entering/selecting the raw absolute file path in h:inputText and sending it to the server so that it can be used in a File object isn't going to work, as the server doesn't have access to the client's file system. Downloading files is made relatively easy using a FileServlet, but uploading files is a bit harder.
