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 7490053

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:30:37+00:00 2026-05-29T15:30:37+00:00

I followed this tutorial for uploading a file in my JSF2 application. The application

  • 0

I followed this tutorial for uploading a file in my JSF2 application.
The application works fine but I am unhappy with one aspect.
While rebuilding the request, the File sent via request is saved somewhere on the disk.

Even though the file is saved I need to rename the file with a name which is available after entering the Managed Bean containing the action method.

Therefore I decided to create a new file with de desired name, copy the already saved file, and then delete the unneeded one.

private File uploadFile;
//...
try {
    BufferedWriter bw = new BufferedWriter(new FileWriter(newFile));
    BufferedReader br = new BufferedReader(new FileReader(uploadFile));

    String line = "";
    while ((line = br.readLine()) != null){
        bw.write(line);
    }
} catch (Exception e){}

The new file appears in the desired location but this error is thrown when I’m trying to open the file: “Invalid or unsupported PNG file”

These are my questions:

  1. Is there a better way to solve this problem?
  2. Is this solution the best way to upload a picture? Is there a reason to save the file before the business logic when there may be need to resize the picture or the desired name is not available yet.

LE:
I know abot this tutorial as well but I’m trying to do this mojarra only.

  • 0 0 Answers
  • 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

Sidebar

Related Questions

I followed this tutorial for uploading a file in my JSF2 application. The application
I've followed this tutorial: http://anandhansubbiah.com/blog/writing-your-first-android-application/ , but no matter what I do, and what
I've followed this tutorial but when I try to run the application I get
I've followed this tutorial and it works fine: http://www.dynamicdrive.com/style/csslibrary/item/css-popup-image-viewer/ However my problem is that
I've followed this otherwise excellent tutorial on getting Xen working with Ubuntu but am
I followed this tutorial: http://codeigniter.com/wiki/Internationalization_and_the_Template_Parser_Class/ The controller that loads the language is this one:
I followed this tutorial (official documentation for symfony 1.4). The project is created but
I followed this tutorial to create a popup bar (similar to the one at
I have followed this tutorial to configure apn_on_rails but I am getting the following
I followed this tutorial in order to create a jQuery Horizontal Accordion. It works

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.