This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 :)
 
Greenhorn
Posts: 22
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Lokesh Dulla
Greenhorn
Posts: 22
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 128
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't listen to Steve. Just read this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic