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 8199377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:09:22+00:00 2026-06-07T06:09:22+00:00

Below is what I have in jsf 2.0 <tr> <th width=19% align=left><h:outputLabel value=Photo /></th>

  • 0

Below is what I have in jsf 2.0

<tr>
    <th width="19%" align="left"><h:outputLabel value="Photo" /></th>
    <th width="2%">:</th>
    <td width="19%"><h:inputText value="#{PersonalInformationDataBean.photo}" size="80" id="photo" readonly="true"/> 
    <input type="file" name="pathPhoto" onchange="alert('you changed me...'+window.document.patentForm.pathPhoto.value);window.document.patentForm.photo.value=window.document.patentForm.pathPhoto.value"/></td>
</tr>

When I click on button Choose File and select some file, I get different path.

Chrome & Safari

I get path name as C:\fakepath\jobs_dubizzle.rtf. I always get output as C:\fakepath\FileName irrespective of any location.

Mozilla Firefox

It gives me full path perfectly.

Any idea why I am getting like this? (Different behavior across browsers.) And how to overcome? I need full path of that file so that I can use same path for storing the path in MySQL data.


Update 1

What I wanted to do is when I submit the form, I want that file to get uploaded in mysql data. Right now I would be selecting images. To upload images, I would be using code as provided here.

As you see, I would be needing full path for statement below.

File image = new File("C:/image.jpg");

That is why, I was curious to get full path of the selected file.

Any idea to get this?

  • 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-06-07T06:09:24+00:00Added an answer on June 7, 2026 at 6:09 am

    In a web application, you wouldn’t want to rely on locating a file on the server. The best you can do is store at the root of application and retrieve like this:

    ExternalContext external = FacesContext.getCurrentInstance().getExternalContext();
    ServletContext servletContext = (ServletContext) external.getContext();
    InputStream is = servletContext.getResourceAsStream("image.jpg");
    

    But Ideally if you are using JSF and have Servlet 3.0 container, I suggest you to use File Upload written by BalusC in his blog which can be found here.

    If you do not have Servlet 3.0, then you can use the File Upload example written in Core JavaServer Faces textbook. You can download the source code from the author’s site it is located in ch13 directory.

    And you can do whatever you wish to do like saving to database in the action method when you submit the form using any of the above components.

    Alternatively, if you can use libraries like PrimeFaces, they have a nice file upload component which you can use out of the box.

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

Sidebar

Related Questions

In my JSF file I have below at the start. <h:form><h:commandLink value=Create New Staff
Below I have table - Company id name value year 1 IBM 10 2011
I have the jsf code and css code below. I'm having trouble getting the
I have some JSF code that currently works (as shown below), and I need
I have a JSF webapp throwing an exception (see below) when I'm trying to
I have the following authentication form in JSF running on Glassfish 3: <h:messages globalOnly=true
I have a JSF page with two forms (pseudo-code below). First form is for
I have a JSF datatable like this one: <h:form id=productsBox> <h:dataTable var=product value=#{categoriesBean.category.products} id=productsTable>
In the code below (jsf page), i have some hotel info in display:table rows
I have created a page using JSF 2.0. Below is what I have <h:dataTable

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.