File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to open a local folder from a html or jsp?

 
RajKumar Kanakaraj
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

I would like to know that, Can we open a local folder on the click on a link???
If yes, please share the code :)
 
d v lokesh venkata
Greenhorn
Posts: 16
Java Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you explain your requirement clearly like if you want to open the folder residing at client side or at server side
 
RajKumar Kanakaraj
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for a quick reply..:)

I need to open a folder in Server side.

Presently, The application is hosted in local machine.

where should i keep those folders so that i can access from the link.

Thanks for your support.
 
d v lokesh venkata
Greenhorn
Posts: 16
Java Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if the folder resides in the project folder in the server then you can get access to that folder using the below statement
File file=new File(request.getRealPath("Folder Name")+"\\"+file_name);
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Backslashes will only work on Windows. Avoid them.

What's the purpose of accessing this file? It's unlikely a File object is necessary.

And, be aware that getRealPath() will not work when an unexpanded war file is used for deployment.

We need more info on how the folders and files are to be used to give appropriate advice.
 
Raj Chila
Ranch Hand
Posts: 128
Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suggest also to use properties and refer to this in your code so that it can be easily configured for different environments.
 
RajKumar Kanakaraj
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys, Thanks for the valuable suggestions.

I am developing a webapp using Eclipse IDE.

My ultimate goal is to open a folder on a click on a link (can be a href)

Team can suggest me where to keep the folder and how can i open it from a jsp ?

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's still not clear what you mean by "open a folder" and whether the file system is on the client or the server.
 
RajKumar Kanakaraj
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

File system is on the server.

File system will be having few documents.

I want to access those documents from the application.

To access those documents i need to open the folder which contains the documents.

Now, I want to access this folder from a jsp..:)

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the folders and files are part of the web app, then if (and only if) the web app is not deployed as an unexpanded war file, you can simply use Java file I/O to discovers the files and folders in the controller. The getRealPath() can be used to find the relative paths within the web app.

Collect the information into collections and send to the JSP for display using JSTL and EL.

 
Li Qiangqiang
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am in China.so do not mind my poor English.
firstly,i have solved this question before.
there is a way:
1.open Tomcat install folder: ---%TOMCAT_HOME%\conf\server.xml
between :<host> </host> add
2.then start up Tomcat again, interhttp://localhost:8080/FolderTest/1.jsp
you can see , it is done
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic