This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to select and open a file using jsp?

 
Seema Shetty
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need the code to select a file from the specified directory by browsing for that file(html file) and to open it on the internet explorer.
Or I want to know how I can achieve this using some of the api or javascript in jsp?
Thanks in advance
Seeema
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The thread below has the code to select the directory using JFileChooser: http://www.javaranch.com/ubb/Forum33/HTML/001305.html
Once you have the file you can either "execute" the file and let the MIME type direct what browser gets opened:
Process p = Runtime.getRuntime().exec(f); //opens with whatever application the user has specified for that extension type
or you can NAME the browser and hope that the user has the application and that it is in the path:
String runThis = "\"" + "ie.exe " + f + "\""; //create the command in quotes
Runtime.getRuntime().exec(runThis);
[This message has been edited by Cindy Glass (edited April 23, 2001).]
 
Seema Shetty
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Cindy,
I tried to execute the code which is here.But it gives me application error when it tries to open the file.Why is that so?
Thanks
Seema
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which code did you try? and can you show us your version of it?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic