0

Can any one help me on the following issue. I have index.html file in that

<td><input type="file" id="testsuitepath1" value="testpath"></td>

By using the above line I am able to browse files from my local system path instead of server path. So ,in Servlets is there any way to access the files by clicking on browse button in the server location.

Raja Ram
  • 109
  • 4
  • 11

2 Answers2

0

No, not by default. A web server, at least in part, does what you want - it serves files from the server side. But by default it doesn't let you just browse any file nor see all of the files on the server side. You could write a servlet to do this but you need to be careful to not all the client to access sensitive files.

stdunbar
  • 16,263
  • 11
  • 31
  • 53
  • So can you please suggest me how to write the servlet to access only a particular folder from a sever – Raja Ram Nov 07 '17 at 17:41
  • I found a small example [here](https://www.journaldev.com/1964/servlet-upload-file-download-example). But it could turn into much more if you needed. – stdunbar Nov 07 '17 at 21:51
0

The .html works at client side. That's why you are able to browse files from local system.

A servlet is delpoyed at server side , So a servlet can access files/resources stored in the web-app that is deployed on that server. This is called accessing relative resources.

Moreover, If you want to access the files from the server via browse button then, you should have the access to the network location where the web-app is deployed.
Later, in the filename(browse window) you can search the path of the server.
e.g: \\web-app\file1.jpg

Personally. I think you have a bad software design issue.

Rohit Gaikwad
  • 3,677
  • 3
  • 17
  • 40