0

I am having the Servlet web application which have upload functionality.

I am checking one condition that file name should contain .csv. If it having .csv the process continues otherwise I am displaying error screen.

But, the issue is it is working fine in my system(Local) but in test environment I am getting the error screen. So I want to see the actual path where the file is uploaded.

So please suggest me how to get the path where file is uploaded. I can print it in log and I will able to find the solution for the above issue.

In Short, How to get the file path when the file is uploaded?(Servlet/Java).

Ex: c:/Project/Upload/... etc
Vivek Singh
  • 2,047
  • 11
  • 24
Nat
  • 67
  • 4
  • 12
  • Show us what you have done so far? The code that works and the tests that fail. – Raf Dec 08 '15 at 09:39
  • Did you check this http://stackoverflow.com/questions/31857302/how-to-retrieve-full-path-of-uploaded-file-in-jsp-java – Rockstar Dec 08 '15 at 09:41
  • @Raf Yes. It got failed in test. So I want to see the full path where it is uploaded. – Nat Dec 08 '15 at 09:45
  • that's in server location mnt//testfile. I want the path where the file stored in my computer – Nat Dec 08 '15 at 10:38

1 Answers1

0

Have you tried this?

File.getAbsolutePath()

Or maybe you don't have the file? To find the path to your war file that has been deployed onto the server, you can do something like this:

URL url = getClass().getClassLoader().getResource("a_file_in_your_resources_folder_.txt");
whistling_marmot
  • 3,561
  • 3
  • 25
  • 39
  • Can you provide me the exact line of code what I need to do? – Nat Dec 08 '15 at 10:36
  • Its not working. Is it possible to get the file location which is stored in my computer via servlet program – Nat Dec 08 '15 at 10:47