on 11-15-2011 1:05 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"
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.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.