Reputation: 586
I am trying to send a folder's content as String[]
but I have some problem with paths. In hosted mode the following code works fine:
File dir= new File("folder-in-webcontents-dir");
String contents=dir.list();
return contents;
This snippet is executed in the server side implementation of an RPC call.
When this project is deployed in glassfish after using logging I see that .getabsolutefilepath()
returns something like c:\glassfish\glassfish\domains\domain1\CONFIG(??)\folder-in-webcontents-dir
.
How can I then point to this specific folder?
Upvotes: 0
Views: 333
Reputation: 1575
Use:
File file = new File("/folder-in-webcontents-dir");
String contents=dir.list();
Return contents;
Upvotes: 1
Reputation: 10190
You can use this code on the server side (on your RPC)
String URL = getServletContext().getRealPath("/folder-in-webcontents-dir");
File dir = new File(URL);
return dir.list();
Upvotes: 2