Take the 2-minute tour ×
String fileToBeRead = "C:/Documents and Settings/Developer/Desktop/Anand exmps/Anand.xls";

I have completed a java program in which the location of a file is assigned to a string as above.

But what actually is required is, the end user should select the location of file in a JSP form that is developed using <input type="file" name="file"/> tag for file selection.

My query here is how can I make the location of the file that the user selects in the JSP form to be passed to the JAVA program that I have written already.

Gimme some ideas regarding the same. Thanks in advance. Since am a beginner in Java, elaborate answers will really help in my procedings.

share|improve this question
It's a standalone Java program, not something running on your application server? –  Rodney Gitzel Sep 9 '10 at 20:14
Yes its a standalone program. Not running on server –  LGAP Sep 9 '10 at 20:15
Duplicate of To pass the path of the uploaded file to the Java program Answer is still: you can't. Read the answer and the links in the answer once again to understand why not. –  BalusC Sep 9 '10 at 21:41
add comment

1 Answer

up vote 1 down vote accepted

The input field's file type is not guaranteed to pass the entire path. In fact, IE is the only browser that does.

The file input is intended to upload the entire file to the server, not to give you the file's path.

share|improve this answer
yeah.. what can be done ?? what are all the possibilities? –  LGAP Sep 9 '10 at 20:41
add comment

Your Answer


