Fileaccess.httpUploadBean doesn't upload file in Jdevelper 9.0.3

Hi,
I am using Jdevelper 9.0.3 to develop a jsp Based File Upload Utility.
I have attached Liberary "JSP RUNTIME" which reffers to "ojsp.jar","ojsputil.jar","oc4j.jar","servlet.jar","ojc.jar".
while running the code for file upload, file doesn't get uploaded. I am not getting any exceptions too.
But the same pease of code with same liberary "JSP RUNTIME" is working absolutly fine(Uploading File), when i am running it using Jdeveloper10.1.2, and This is Strange to me.Actualy i need to use Jdeveloper9.0.3 only.Please let me know if any patch is required to apply in Jdeveloper9.0.3.
Please find the code below and help.
fileaccess.properties
fileaccess.basedir = C:/
fileUpload.jsp
<html><body>
<form name = "formname" action="beanUploadExample.jsp" method=POST ENCTYPE="multipart/form-data" />
<br>MailID: <INPUT TYPE="text" NAME="strMailId" />
<br> File to upload: <INPUT TYPE="FILE" NAME="File" SIZE="50" MAXLENGTH="120" >
<br><INPUT TYPE="Submit" NAME="Submit" VALUE="Send" >
<INPUT type="reset" name="reset" value = "Cancel">
</form>
</body></html>
beanUploadExample.jsp
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page language="java"
import="java.util.*,java.io.*, oracle.jsp.webutil.fileaccess.*" %>
<html><body>
<SCRIPT language="JavaScript">
function formAction()
if (document.upForm.forward.value == "true")
{//tOMORROW PASS THE FILE NAME WITH ACTION PARAM
//alert("Submit");
document.upForm.action = "uploadco"
document.upForm.submit();
</SCRIPT>
<Form name="upForm" method ="post" > <!--action ="beanUploadExample.jsp" >-->
<%
String userdir = "Test";
String strFlag = "";
String strFileName ="";
String strDirName ="";
String strAbsoluteName ="";
%>
<jsp:useBean id="upbean"
class="oracle.jsp.webutil.fileaccess.HttpUploadBean" >
<jsp:setProperty name="upbean" property="destination" value="<%=userdir%"/>
</jsp:useBean>
<%
try{
upbean.setBaseDir(application, request);
String str = upbean.getDestination();
// application.getServletContextName();
//out.println("The Servlet Context is "+strContext) ;
out.println("The value of Destination is "+str) ;
upbean.upload(request);
String name = upbean.getParameter("strMailId");
out.println("name-----:::::: "+name) ;
String strDestType = upbean.getDestinationType();
out.println("strDestType-----:::::: "+strDestType) ;
Enumeration fileNames = upbean.getFileNames();
while (fileNames.hasMoreElements()) {
strFlag = "true";
strFileName = (String)fileNames.nextElement();
out.println("strFileName File Name Is:::::"+strFileName);
strAbsoluteName = strFileName.substring(4,strFileName.length());
catch(IOException ex)
out.println("IOException is =="+ex.toString());
catch(Exception ex)
out.println("IOException is =="+ex.toString());
%>
<table width = 50% align="center" >
<tr>
<td align ="center"><input type = "Button" name ="Submit" value="Ok" onclick="formAction()" ></td></tr></table>
</Form>
</body></html>

Hi,
I am using Jdevelper 9.0.3 to develop a jsp Based File Upload Utility.
I have attached Liberary "JSP RUNTIME" which reffers to "ojsp.jar","ojsputil.jar","oc4j.jar","servlet.jar","ojc.jar".
while running the code for file upload, file doesn't get uploaded. I am not getting any exceptions too.
But the same pease of code with same liberary "JSP RUNTIME" is working absolutly fine(Uploading File), when i am running it using Jdeveloper10.1.2, and This is Strange to me.Actualy i need to use Jdeveloper9.0.3 only.Please let me know if any patch is required to apply in Jdeveloper9.0.3.
Please find the code below and help.
fileaccess.properties
fileaccess.basedir = C:/
fileUpload.jsp
<html><body>
<form name = "formname" action="beanUploadExample.jsp" method=POST ENCTYPE="multipart/form-data" />
<br>MailID: <INPUT TYPE="text" NAME="strMailId" />
<br> File to upload: <INPUT TYPE="FILE" NAME="File" SIZE="50" MAXLENGTH="120" >
<br><INPUT TYPE="Submit" NAME="Submit" VALUE="Send" >
<INPUT type="reset" name="reset" value = "Cancel">
</form>
</body></html>
beanUploadExample.jsp
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page language="java"
import="java.util.*,java.io.*, oracle.jsp.webutil.fileaccess.*" %>
<html><body>
<SCRIPT language="JavaScript">
function formAction()
if (document.upForm.forward.value == "true")
{//tOMORROW PASS THE FILE NAME WITH ACTION PARAM
//alert("Submit");
document.upForm.action = "uploadco"
document.upForm.submit();
</SCRIPT>
<Form name="upForm" method ="post" > <!--action ="beanUploadExample.jsp" >-->
<%
String userdir = "Test";
String strFlag = "";
String strFileName ="";
String strDirName ="";
String strAbsoluteName ="";
%>
<jsp:useBean id="upbean"
class="oracle.jsp.webutil.fileaccess.HttpUploadBean" >
<jsp:setProperty name="upbean" property="destination" value="<%=userdir%"/>
</jsp:useBean>
<%
try{
upbean.setBaseDir(application, request);
String str = upbean.getDestination();
// application.getServletContextName();
//out.println("The Servlet Context is "+strContext) ;
out.println("The value of Destination is "+str) ;
upbean.upload(request);
String name = upbean.getParameter("strMailId");
out.println("name-----:::::: "+name) ;
String strDestType = upbean.getDestinationType();
out.println("strDestType-----:::::: "+strDestType) ;
Enumeration fileNames = upbean.getFileNames();
while (fileNames.hasMoreElements()) {
strFlag = "true";
strFileName = (String)fileNames.nextElement();
out.println("strFileName File Name Is:::::"+strFileName);
strAbsoluteName = strFileName.substring(4,strFileName.length());
catch(IOException ex)
out.println("IOException is =="+ex.toString());
catch(Exception ex)
out.println("IOException is =="+ex.toString());
%>
<table width = 50% align="center" >
<tr>
<td align ="center"><input type = "Button" name ="Submit" value="Ok" onclick="formAction()" ></td></tr></table>
</Form>
</body></html>

Similar Messages

  • File Upload in UNIX Problem in using fileaccess.HttpUploadBean

    Hi,
    Some one please help me on File uploading in UNIX using fileaccess.HttpUploadBean.
    My program is working fine for windows , but when i am running same profram to upload the file in Unix Environment it is giving exception.
    fileaccess.properties for UNIX.
    fileaccess.basedir = /usr
    Under /usr i have tmp directory, and in my beanUploadExample.jsp i have defined userdir = "tmp"; but while uploading it throws "IOException = tmp is not a directory". tmp is a existing directory under /usr and i am having write permission into it.
    Please help me on this.
    Thanks in advance

    Avoid Multipost
    http://forum.java.sun.com/thread.jspa?threadID=5216365

  • Fileaccess.HttpUploadBean not uploading file in DataBase Table

    Hi,
    I am using fileaccess.HttpUploadBean to upload the txt file in the specified database table.i have followed all the guidelines given in Oracle JSP Tag Libraries and Utilities Reference Guide. But i am not be able to upload the file into Database Table
    I have created a table
    CREATE TABLE FLK_CLOB_TEST (
    FILE_ID NUMBER (5),
    FILE_DATA CLOB,
    FILE_NAME VARCHAR2 (50),
    FILE_PREFIX VARCHAR2 (50) ) ;
    uploadfile.jsp
    <html><body>
    <form name = "formname" action="beanUploadDataBase.jsp" method=POST ENCTYPE="multipart/form-data" />
    <br>MailID: <INPUT TYPE="text" NAME="strMailId" />
    <br> File to upload: <INPUT TYPE="FILE" NAME="File" SIZE="50" MAXLENGTH="120" >
    <br><INPUT TYPE="Submit" NAME="Submit" VALUE="Send" >
    <INPUT type="reset" name="reset" value = "Cancel">
    </form>
    </body></html>
    beanUploadDataBase.jsp , which is having upload code.
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page language="java"
    import="java.util.*,java.io.*,java.sql.*, oracle.jsp.webutil.fileaccess.*" %>
    <html><body>
    <Form name="upForm" method ="post" > <!--action ="beanUploadExample.jsp" >-->
    <%
    Connection conn;
    FlkOracleDBCon objDBHelper;
    objDBHelper = FlkOracleDBCon.getInstance();
    String userdir = "test";
    String strFlag = "";
    String strFileName ="";
    String strDirName ="";
    String strAbsoluteName ="";
    //MultipartRequest multi = null;
    String _PageMode = "";//"CREATE";
    %>
    <jsp:useBean id="upbean"
    class="oracle.jsp.webutil.fileaccess.HttpUploadBean" >
    <jsp:setProperty name="upbean" property="destination" value="<%=userdir%>"/>
    </jsp:useBean>
    <%
    try{
    conn = objDBHelper.getConnection();
    out.println("Connection Value is :"+conn);
    if (conn !=null)
    // upbean.setDestination("test");
    upbean.setDestinationType("database");
    upbean.setConnection(conn);
    upbean.setOverwrite(false);
    upbean.setFileType("character");
    upbean.setTable("FLK_CLOB_TEST");
    upbean.setPrefixColumn("File_Prefix");
    upbean.setFileNameColumn("File_Name");
    upbean.setDataColumn("File_Data");
    //upbean.setBaseDir(application, request);
    String str = upbean.getDestination();
    out.println("The value of Destination is "+str) ;
    upbean.upload(request);
    String filename = upbean.getFileNameColumn();
    String strTable = upbean.getTable();
    String strPrefix = upbean.getPrefixColumn();
    String name = "";
    conn.commit();
    out.println("filename-----:::::: "+filename+":::");
    out.println("File Prefix-----:::::: "+strPrefix+":::");
    out.println("DataBase Table Name-----:::::: "+strTable+":::");
    Enumeration fileNames = upbean.getFileNames();
    while (fileNames.hasMoreElements()) {
    strFlag = "true";
    strFileName = (String)fileNames.nextElement();
    out.println("strFileName File Name Is:::::"+strFileName);
    strAbsoluteName = strFileName.substring(4,strFileName.length());
    catch(IOException ex)
    out.println("IOException is =="+ex.toString());
    catch(SQLException ex)
    out.println("IOException is =="+ex.toString());
    catch(Exception ex)
    out.println("IOException is =="+ex.toString());
    %>
    This is not uploading file or any other information into database table called FLK_CLOB_TEST.
    Please help me on this.

    I get the same error when i try to load the same data but from Oracle Table
    11872     12108     RUN-050406     11/14/2011 4:38:44 PM     Data flow <DF_TB_Generalità> received a bad system message. Message text from the child process is
    11872     12108     RUN-050406     11/14/2011 4:38:44 PM     
    <￀ ==========================================================
    when i load data from SAP extractors or SAP tables i don't have problem.
    Regards
    Bilal

  • EExternal hard drive (WD Elements) doesn't show uploaded files on MBP

    I have uploaded files onto my WD Elements hard drive (2 TB) but they don't show on my late-2013 Macbook Pro 15" running on Mavericks (version 10.9.4). How can I access them without losing anything?

    Make sure the format is ExFAT, because Mac OS X doesn't read NTFS unless you have a utility to read the HDD you have. I own a WD Elements 2TB portable hard drive and I had to format and partition the little thing for my rMBP 13 for storage and Time Machine.

  • How to specify the directory in which we want to store the uploaded files

    Hello !!
    I am using apache commonfile upload for uploading my files.I followed the user guide and tried to run a program,but my problem is I am not able to understand as to how to mention the directory in which the uploaded file will be saved..My code is given below :
    package r;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import org.apache.commons.fileupload.*;
    import org.apache.commons.fileupload.servlet.*;
    import org.apache.commons.fileupload.disk.*;
    import org.apache.commons.io.*;
    import java.lang.Exception;
    public class fileupload extends HttpServlet
         public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException
                   // Check that we have a file upload request
                  boolean isMultipart = ServletFileUpload.isMultipartContent(request);
                 System.out.println(isMultipart);
                 if (ServletFileUpload.isMultipartContent(request))
                 // Create a factory for disk-based file items
                   FileItemFactory factory = new DiskFileItemFactory();
                   // Create a new file upload handler
                   ServletFileUpload upload = new ServletFileUpload(factory);
                   // Parse the request
                   try {
                               List items= upload.parseRequest(request);               
                             Iterator iter = items.iterator();
                             while (iter.hasNext())
                                   FileItem item = (FileItem) iter.next();                    
                                 if (item.isFormField()) //NORMAL FORM FIELD
                                 String name = item.getFieldName();
                                  String value = item.getString();
                                  System.out.println(value);                                                             
                                  else
                                 String fileName = item.getName();
                                 System.out.println(fileName);
                                    String contentType = item.getContentType();
                                  File saveTo = new File("/info/upload_files/myFile.jpeg");
                             try
                                       item.write(saveTo);
                                       System.out.println("File written" );                    
                             catch(Exception e)
                                         System.out.println("File not written");
                                   // InputStream fs= item.getInputStream();                    
                                   fileName = FilenameUtils.getName(fileName);
                                    System.out.println(fileName);
                        }//end of try
              catch (Exception e) { }
         public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
                 doGet(request,response);
    The problem is that the control doesn't reach the try statement and I get " File not written" on the console because it enters catch everytime..Please tell me how the path to the directory should be given...Rest of the code is working fine

    No, the problem is that when an Exception is thrown, you ignore it completely and throw away all the information associated with it. That leaves you to guess at what the problem is. So instead of answering your guess at a good question, I'm going to suggest that in all of your catch blocks you put this code:e.printStackTrace();Then you can look at the output in the log file and see what the problem is. Start from there.

  • After choosing a jpg for upload, the "Upload File" button on the organization's receiving site of does not respond. The second problem: it's impossible to highlight more that one file at a time.

    Clicking the first file, holding down shift and clicking the last file doesn't work. I've tried all manner of command, control, shift combos without success.  This one-at-a-time attachment problem also happens in web mail.  Are these two issues related?  Thanks for non-techie solutions for both issues.  I have Safari 5.0.6 (5533.22.3) and Leopard.

    Thanks for your response.  I do have javascript turned on (not java).  To answer your question,
    I was trying to upload 3 jpgs to the submissions page of a visual arts website. I could only highlight one jpg at a time in the "Choose File" option, and then the "Upload File" button of the submissions page would not respond.
    It's an ongoing problem with this site (I'm the only one with this issue and there are a lot of submissions). I have to send the images as email attachements to the administrator of the site.  When doing this via webmail, I still the one attachment at a time problem, but the images get to the administrator.  Thanks for helping.

  • Problems uploading files to various web browsers

    I'm having huge problems with uploading files to various browsers on my MacBook Pro (running Mac Lion OS X 10.7.5)
    My default web browser is Google Chrome but I have tried Firefox, Safari and Mail, too, and they're all presenting the same problem.
    The problem is that whenever I try to attach a document to an email in Gmail or upload a photo/file to any website - it just doesn't play ball. The web browser then becomes totally unresponsive (not loading new tabs etc.) and I have to Force Quit and start the application running again. When I tried this in Mail, the application actually crashed.
    I've figured out a way to get round the problem in Gmail - creating documents in Google Drive or simply dragging documents into the email - but I'm starting an online course soon and I really need to be able to upload documents, files, images etc.
    So far I have tried:
    Updating the software on my Mac
    Updating Google Chrome
    Uninstalling and reinstalling Google Chrome
    Signing in and out of Google Chrome
    Deleting all browser history on Google Chrome
    I've also figured out that it's not my firewall as I had an unrelated problem with that and it was taken down for around 24 hours to be fixed - I tried again to upload files in this 24 hour window and encountered the same problems.
    I'm also having problems with my Windows for Mac - whenever I try to Save or Save As in Word - the programme becomes completely unresponsive, parts of the toolbars at the top white out and I have to Force Quit - hence, why I started using Google Drive to create documents. When I try and Save or Save As in Excel or Powerpoint, these programmes crash too.
    I don't know if these problems are related, but I thought it best to bring it up just in case.
    Can anyone help me?!

    In answer to my own question, in case anyone has the same issue, the problem turned out to be that my hard drive is failing.
    If anyone has the same problem, back up all your data to an external device immediately (trying to run a computer on a failing hard drive is like trying to run on a broken leg, so I'm told) and take your mac to get a new hard drive - should cost around £100.

  • I need to upload file from my computer to website, when I click browse to look at which documents I want it does nothing.

    I need to upload file to quicken loans I click the blue button that says Browser on it so I can search what documents to upload it doesn't open the folders to look for the documents to select.

    Hi there. you have '''search.conduit''' set up as your '''about:newtab''' page.
    This could be add-ware. Is this what you want?
    '''[https://addons.mozilla.org/en-US/firefox/addon/searchreset/ Mozilla Search Reset]''' {web link}
    This add-on is very simple: on installation, it backs up
    and then resets your search preferences and home page
    to their default values, and then uninstalls itself. This
    affects the search bar, URL bar searches, and the home
    page.

  • Unable to upload files via admin & FTP

    I've been trying to upload files to this site, but it keeps on bringing errors. It worked fine 20 minutes ago. Now the FTP doesn't upload and the Admin File Manager brings back errors on upload as well. Anyone know what's going on? The system status gives all green dots about all servers and doesn't say anything about disabled FTP or File Upload: http://status.businesscatalyst.com/

    There was scheduled maintenance today. But the status page doesn't have anything about what is going on. The last update was three hours ago saying hotpatch deployment was competed.

  • Upload file PL\SQL

    Hi,
    I'm writing a web application using PL\SQL procedure.
    I've got one problem, how can I upload file in the database blob field?
    I've found some articles (like this: http://www.acs.ilstu.edu/docs/oracle9ias/web.902/a90855/feature.htm
    ) that present this example,but its doesn't work:
    -----------------------------FILE.HTML----------------------------------------------------------
    <html>
    <head>
    <title>test upload</title>
    </head>
    <body>
    <FORM      enctype="multipart/form-data"
    action="pls/mydad/write_info"
    method="POST">
    <p>Author's Name:<INPUT type="text" name="who">
    <p>Description:<INPUT type="text" name="description"><br>
    <p>File to upload:<INPUT type="file" name="file"><br>
    <p><INPUT type="submit">
    </FORM>
    </body>
    </html>
    ----------------------------------PROC PL\SQL---------------------------------------------
    procedure write_info (
    who in varchar2,
    description in varchar2,
    file in varchar2) as
    begin
    insert into myTable values (who, description, file);
    htp.htmlopen;
    htp.headopen;
    htp.title('File Uploaded');
    htp.headclose;
    htp.bodyopen;
    htp.header(1, 'Upload Status');
    htp.print('Uploaded ' || file || ' successfully');
    htp.bodyclose;
    htp.htmlclose;
    end;
    --------------------------------------------END-----------------------------------------------
    Any ideas?

    Re: Upload file through PL\SQL Webpage

  • Upload file without asking user for the file

    Hi,
    I need to upload a file to server, but from my code, not using the file upload from page.
    I have created a xml file and I need to upload to server when user open a web browser (without asking user to select a file).
    How do I proceed??, or what kind of libraries do I must use?
    thanks

    davisote wrote:
    Hi,
    thanks for answer.
    Let me try to explain again (I think its very simple).Simple, yes. But not very thorough.
    I have developed a web application using JSF.So all the code is running on the server, right? There are no Applets, Applications or WebStart applications involved. Right?
    My application has a splash screen where I show data. I have developed a bean to connect to my database (sql server), extract this data and create an xml (using DOM) file like:
    <news>
    <simplenews id="1"> Value </simplenews>
    </news>And that bean runs ... where? Server again?
    (important step) Once I have created the xml file in my bean I want to upload to the server to a place like /WEB-INF/news.
    If the code is running on the server, then "uploading" is the wrong term, as there's nowhere to upload to, since you're already on the server.
    This may sound like nit-picking, but you're sending us on a wrong trail with this phrase.
    Once the file is on the server with another bean I read the xml fileWhy don't you simply store it in the application scope and let everyone access it from there? It doesn't sound as if the XML is huge.
    As you can see I haven't a web page where to show an upload file componetYou also don't want to "upload" anything from the client, from the sound of it.
    You simply want to transfer data between to server-side components, if I understood you correctly.

  • Upload file without user action.

    Hi,
    Here is my requirement: I need to upload file ( text / excel file ) from local PC without user interaction.
    I try using file_upload element and I set visible property as none ( so user doesn't see this element ) but I don't know how to get the file data. I only can set the file_name and mime_type property.
    Please help me how to get this file data. Or how to upload file from local PC without file_upload element.
    Regards,

    Hi Jatra.
    I guess there are several function modules you can use. Try this : UPLOAD_FILES.
    Maybe you can solve your issue with it. Otherwise search the Abap Forum on how to upload files from PC to WAS.
    Cheers,
    Sascha

  • Problem using "UPLOAD FILE" behavior, in localhost Works fine, in my production server doesnt

    Hi
    I have been working with a form that uses a "upload file", in my localhost computer works very well BUT in my production server doesnt, the thing is that there is no error messager .. so i cant guess the problem, i already check permissions in my folder that contains the files and all is with Write permissions.
    Can you help me pleasE??
    thanks in advance

    Most likely a permissions issue. Check your production server to see if both the IUSR_[Machine Name] and ASPNET users have read/write/delete permissions on 1. the folder you'll be uploading images to AND 2. the includes\common\lib\file_upload\temp folder (if this doesn't exist, create it manually).
    These settings are necessary in order for the ADDT file upload server behavior to function properly.

  • MULTIPLE UPLOAD file problem

    Hello,
    I have a problem with multiple upload file tool.
    Because my server need, in order to upload files in its folders, to be logged only with ftp user (that is unique).
    Now, I need that when I upload a file its name will be stored on db table "file_name". But in order to put data in database i have tobe logged also with user that is allowed to access on mysql db.
    So I understand that I should nedd to types of authentication at the same time...
    I think it depends on my type of hosting that is windows, and there is not the possibility to change CHMOD, so the error when I try to upload a file is that the folder has not write permissions...
    Any suggestions?
    Thanks a lot
    ascaro231
    Italy

    Hi ascaro231,
    wow, that is one bag of problems on the remote side :-(
    to be logged only with ftp user
    although PHP itself provides native FTP functions
    (e.g. for uploading files and also changing folder & file permissions), ADDT´s file upload features don´t support this protocol
    and there is not the possibility to change CHMOD
    CHMOD *will* have to be supported by your host, because this is how ADDT changes folder & file permissions.
    Well, to me it seems that your host doesn´t provide some very basic and truly common-standard PHP settings -- and honestly, disabling the regular PHP file upload features is ridiculous.
    Any suggestions?
    go for a better host -- this is just inacceptable.
    Are you hosting with "Aruba" BTW ? They have both Windows and Linux hostings, and AFAIK it´s possible to switch the hosting type.
    Cheers,
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • Upload file component in JSF 1.2

    Hi,
    I am developing an application with JSF 1.2 . I am using a custom component made with Apache Commons FileUpload 1.2.1 API which purpose is to upload files. This component work only if the form data is encoded with the “multipart/form-data” encoding instead of the usual “application x-www-form-urlencoded” encoding. From what I know JSF 1.2 doesn't handle this type of encoding. To overcome this issue, I install a servlet filter that intercepts a file upload and turns uploaded files into request attributes. The problem is that when the form data is encoded with the “multipart/form-data” encoding no characters are encoded. I have other JSF components in this form and in them I put different international characters which are lost when the form is submit because they are not encoded.
    Can somebody help me with this issue ?

    I have a filter
    import java.io.File;
    import java.io.IOException;
    import java.util.Collections;
    import java.util.Enumeration;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletRequestWrapper;
    import org.apache.commons.fileupload.FileItem;
    import org.apache.commons.fileupload.FileUploadException;
    import org.apache.commons.fileupload.disk.DiskFileItemFactory;
    import org.apache.commons.fileupload.servlet.ServletFileUpload;
    public class UploadFilter implements Filter {
    private int sizeThreshold = -1;
    private String repositoryPath;
    public void init(FilterConfig config) throws ServletException {
    repositoryPath = config.getInitParameter(
    "com.corejsf.UploadFilter.repositoryPath");
    try {
    String paramValue = config.getInitParameter(
    "com.corejsf.UploadFilter.sizeThreshold");
    if (paramValue != null)
    sizeThreshold = Integer.parseInt(paramValue);
    catch (NumberFormatException ex) {
    ServletException servletEx = new ServletException();
    servletEx.initCause(ex);
    throw servletEx;
    public void destroy() {
    public void doFilter(ServletRequest request,
    ServletResponse response, FilterChain chain)
    throws IOException, ServletException {
    if (!(request instanceof HttpServletRequest)) {
    chain.doFilter(request, response);
    return;
    HttpServletRequest httpRequest = (HttpServletRequest) request;
    boolean isMultipartContent
    = ServletFileUpload.isMultipartContent(httpRequest);
    if (!isMultipartContent) {
    chain.doFilter(request, response);
    return;
    DiskFileItemFactory factory = new DiskFileItemFactory();
    if (sizeThreshold >= 0)
    factory.setSizeThreshold(sizeThreshold);
    if (repositoryPath != null)
    factory.setRepository(new File(repositoryPath));
    ServletFileUpload upload = new ServletFileUpload(factory);
    try {
    List<FileItem> items = (List<FileItem>) upload.parseRequest(httpRequest);
    final Map<String, String[]> map = new HashMap<String, String[]>();
    for (FileItem item : items) {
    String str = item.getString();
    if (item.isFormField())
    map.put(item.getFieldName(), new String[] { str });
    else
    httpRequest.setAttribute(item.getFieldName(), item);
    chain.doFilter(new
    HttpServletRequestWrapper(httpRequest) {
    public Map<String, String[]> getParameterMap() {
    return map;
    // busywork follows ... should have been part of the wrapper
    public String[] getParameterValues(String name) {
    Map<String, String[]> map = getParameterMap();
    return (String[]) map.get(name);
    public String getParameter(String name) {
    String[] params = getParameterValues(name);
    if (params == null) return null;
    return params[0];
    public Enumeration<String> getParameterNames() {
    Map<String, String[]> map = getParameterMap();
    return Collections.enumeration(map.keySet());
    }, response);
    } catch (FileUploadException ex) {
    ServletException servletEx = new ServletException();
    servletEx.initCause(ex);
    throw servletEx;
    a render
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.UnsupportedEncodingException;
    import javax.el.ValueExpression;
    import javax.faces.FacesException;
    import javax.faces.component.EditableValueHolder;
    import javax.faces.component.UIComponent;
    import javax.faces.context.ExternalContext;
    import javax.faces.context.FacesContext;
    import javax.faces.context.ResponseWriter;
    import javax.faces.render.Renderer;
    import javax.servlet.ServletContext;
    import javax.servlet.http.HttpServletRequest;
    import org.apache.commons.fileupload.FileItem;
    public class UploadRenderer extends Renderer {
    public void encodeBegin(FacesContext context, UIComponent component)
    throws IOException {
    if (!component.isRendered()) return;
    ResponseWriter writer = context.getResponseWriter();
    String clientId = component.getClientId(context);
    writer.startElement("input", component);
    writer.writeAttribute("type", "file", "type");
    writer.writeAttribute("name", clientId, "clientId");
    writer.endElement("input");
    writer.flush();
    public void decode(FacesContext context, UIComponent component) {
    ExternalContext external = context.getExternalContext();
    HttpServletRequest request = (HttpServletRequest) external.getRequest();
    String clientId = component.getClientId(context);
    FileItem item = (FileItem) request.getAttribute(clientId);
    Object newValue;
    ValueExpression valueExpr = component.getValueExpression("value");
    if (valueExpr != null) {
    Class valueType = valueExpr.getType(context.getELContext());
    if (valueType == byte[].class) {
    newValue = item.get();
    else if (valueType == InputStream.class) {
    try {
    newValue = item.getInputStream();
    } catch (IOException ex) {
    throw new FacesException(ex);
    else {
    String encoding = request.getCharacterEncoding();
    if (encoding != null)
    try {
    newValue = item.getString(encoding);
    } catch (UnsupportedEncodingException ex) {
    newValue = item.getString();
    else
    newValue = item.getString();
    ((EditableValueHolder) component).setSubmittedValue(newValue);
    ((EditableValueHolder) component).setValid(true);
    Object target = component.getAttributes().get("target");
    if (target != null) {
    File file;
    if (target instanceof File)
    file = (File) target;
    else {
    ServletContext servletContext
    = (ServletContext) external.getContext();
    String realPath = servletContext.getRealPath(target.toString());
    file = new File(realPath);
    try { // ugh--write is declared with "throws Exception"
    item.write(file);
    } catch (Exception ex) {
    throw new FacesException(ex);
    and a simple tag handler it is nothing special.
    This code is taken from an example in the book Core JavaServer Faces Second Edition 2007

Maybe you are looking for