• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get the browsed file path into controller bean using JSF icefaces  RSS feed

lee chan
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I've a requirement as,

1) Need to browse a file from my local system/machine
2) Path of the file from which I browsed need to be stored in a variable in controllerbean.

This thing I've done as below,

<ice:inputFile id="inputFileName" width="600" autoUpload="true" value="#{fileAccessDataBean.inputFileName}"

/** variable to hold inputFileName. */
private String inputFileName;

* @return the inputFileName
public String getInputFileName() {
return inputFileName;

* @param inputFileName the inputFileName to set
public void setInputFileName(String inputFileName) {
this.inputFileName = inputFileName;

public class FileAccessControllerBean {

/** latest file uploaded by client. */
private FileInfo currentFile;

FileAccessDataBean fileAccessDataBean = new FileAccessDataBean();

* This method is for gettingsetting browse.
* @param event ActionEvent
public void browse(ActionEvent event) {
InputFile inputFile = (InputFile) event.getSource();
String filePath = null;

LOG.debug("XXX Getting File Info into currentFile..." + inputFile);

currentFile = inputFile.getFileInfo();

LOG.info("XXX current File Name... " + currentFile.getFileName());
filePath = inputFile.getFileInfo().getPhysicalPath();
LOG.info("XXX physical path... " + filePath);


File file = currentFile.getFile();
filePath = file.getAbsolutePath();
LOG.info("XXX absolute path.. " + filePath);


Browsed file location: C:\Documents and Settings\personInfo.xml

XXX Getting File Info into currentFile... personInfo.xml
XXX current File Name... personInfo.xml
XXX physical path File Name... U:\glassfish.frontend\domains\..\..\personInfo.xml
XXX absolute path.. U:\glassfish.frontend\domains\..\..\personInfo.xml

in the above two logs I'm getting serverpath of the file.. But I want exact browsed path that is C:\Documents and Settings\personInfo.xml

how can I get the path? Is there any other way to browse the file and get the path of the file into controllerbean?

PLEASE HELP ME OUT It's very urgent requirement for me.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!