Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6737037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:12:04+00:00 2026-05-26T11:12:04+00:00

I’m using JSF 2.1 with JSP files. I tried to use JSF 2.1 with

  • 0

I’m using JSF 2.1 with JSP files. I tried to use JSF 2.1 with Facelet files, but didn’t get Tomahawk (MyFaces extension) to work.

I’m trying to upload a file using Tomahawk. My form looks like follows:

<f:view>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>FILE UPLOAD</title>
    </head>
    <body>
        <fieldset>
            <h:form enctype="multipart/form-data">
                <t:inputFileUpload value="#{fileUploadBean.upFile}"
                                   size="25"
                                   required="true" /><br/>
                <h:commandButton value="Validar" action="#{fileUploadBean.upload}" />
            </h:form>
        </fieldset>
    </body>
</html>
</f:view>

and my bean is (as I’m using JSF 2.1, I don’t need to use faces-config.xml and I use annotations):

import java.io.IOException;
import java.io.InputStream;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import org.apache.myfaces.custom.fileupload.UploadedFile;

/**
 *
 * @author federico.martinez
 */
@ManagedBean
@RequestScoped
public class FileUploadBean {

    private UploadedFile upFile;

    public UploadedFile getUpFile(){
        return upFile;
    }

    public void setUpFile(UploadedFile upFile){
        this.upFile = upFile;
    }

    public String upload(){
        InputStream is = null;
        try {
            is = upFile.getInputStream();
            long size = upFile.getSize();
            byte[] buffer = new byte[(int)size];
            is.read(buffer,0,(int)size);
            is.close();
            System.out.println("File Upload Successful.");
            return "processing-file";
        } catch (IOException ex) {
            Logger.getLogger(FileUploadBean.class.getName()).log(Level.SEVERE, null, ex);
            return "error-lf";
        } finally {
            try {
                is.close();
            } catch (IOException ex) {
                Logger.getLogger(FileUploadBean.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }  
}

Well that’s it, but finally the problem is when I click on h:commandButton, it doesn’t do anything. It seems like the method “upload” from my bean isn’t working or something. what am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:12:04+00:00Added an answer on May 26, 2026 at 11:12 am

    As stated in the Tomahawk documentation, you need to register ExtensionsFilter in web.xml. It’s the one responsible for parsing multipart/form-data requests and converting the multipart form data parts to normal request parameters and attributes, so that the FacesServlet can continue using them. If you don’t register the ExtensionsFilter, then the FacesServlet can’t do anything because there are no request parameters in order to determine the model values to be updated and actions to be invoked.

    See also:

    • JSF 2.0 File upload – A mini tutorial.

    Unrelated to the concrete problem, you should really consider using Facelets instead of JSP. It offers so many advantages over JSP, such as templating, composite components and ajax support.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.