cancel
Showing results for 
Search instead for 
Did you mean: 

Correct file location on server

Former Member
0 Kudos

Hi,

I would like to read a file from a local server or a remote server.

What would be the proper URL if I had a JSP application that's going to read the file?

String location = "<specify the location in server>";
String file = wdContext.currentcontextelement.get<att1>;
String filename = location+file
File destinationFile = new file(filename);
fileOutputStream out = new fileOutputStream(destinationFile);

Something like "/usr/sap/SID/work/..." ?

Thanks and regards,

John

Accepted Solutions (1)

Accepted Solutions (1)

vijay_kumar49
Active Contributor
0 Kudos

Hi,

In webdynpro java, first file stores in server location then it reads from server.

Create a button with upload and write this code OnAction

Resource is the attribute name in context of type com.sap.ide.webdynpro.uielementdefinitions.Resource, this attribute is for Resource property for Upload UI Element.

Then in OnAction of button

InputStream text = null;

int temp=0;

try{

File file = new File(wdContext.currentContextElement().getResource().getResourceName().toString());

}

String path = file.getAbsolutePath();

wdComponentAPI.getMessageManager().reportSuccess(path);

}catch(Exception e){

e.printStackTrace();

}

//@@end

}

By default it stores in location E:\usr\sap\CE7\J00\j2ee\cluster\server0\sample.jpg

Hope this is help full for u

Regards

Vijay

Former Member
0 Kudos

Hi Vijay,

Thanks for the reply.

How about reading existing application or trace logs?

How can you retrieve the absolute path to that dynamically?

Thanks,

John

vijay_kumar49
Active Contributor
0 Kudos

Hi,

By using this line String path = file.getAbsolutePath(); we can get server pathu2026

Can you tell me what exactly you want.

Hope this is help full for u

Regards

Vijay

Qualiture
Active Contributor
0 Kudos

If you need the absolute path of your current NW system, on NW 7.0 you could read the Java system properties:

String appHome = System.getProperty("application.home");
String basePath = appHome.substring(0, appHome.lastIndexOf("exe"));
String logPath = basPath + File.separator + "j2ee" + File.separator + "cluster" + File.separator + "server0" + File.separator + "log"

Former Member
0 Kudos

Webdynpro java can read files from three different sources. First, you can use an upload or download ui element, which are used by the user to upload/download files to their computer.

The second way is directly from the server. That means that the server can read a file. You can use the standar java libraries, in this url you can find a good example. (I think this is your case)

http://www.javapractices.com/topic/TopicAction.do?Id=42

The only thing you have to understand is that when the server reads the file, the windows (or unix) user that starts the web application services in the server, must have read and write rights to the folder you want to read. If, additionally, you create a "configuration table" in ecc to store the path to he file and read it with a function module, then you can change it at will.

The last option is to read a file stored inside the project. But I don't think that your question is about it.

I have done it successfully, you can use whatever libraries java gives you.

Answers (0)