on 2006 Aug 31 10:39 AM
Hello,
I want to read out a .csv-file and generate html-code dynmically with JSP in an EP6 Application. The problem is, that the csv-file cant be located or openend.
BTW if every knows a good tutorial or weblog for this, please post the link.
Its located in a par-archive under:
/>dist>files
I tried various methods, in the doContent mehtod or with JSP. Everytime same result.
Here part of the code I tried in the doContent():
public class CSV extends AbstractPortalComponent
{
public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
{
String strWRoot = request.getWebResourcePath();
String contentCSV="", line="";
String linesep = System.getProperty("line.separator");
File fileLoadCSV = new File(strWRoot+"/files/ma_infosysteme.csv");
boolean exCSV = fileLoadCSV.exists();
boolean reCSV = fileLoadCSV.canRead();
int a=0;
if(exCSV&&reCSV){
response.write("ok");
try {
BufferedReader inputCSV = new BufferedReader(new FileReader(fileLoadCSV));
while((line=inputCSV.readLine())!=null){
contentCSV=contentCSVlinelinesep;
a++;
}
inputCSV.close();
}
catch(IOException ioex){
System.out.println("Fehler");
}
}
else {
response.write("not ok");
};
response.write("<br>Wroot: "+strWRoot);
response.write("<br>File: "+fileLoadCSV);
response.write("<br>exists: "+exCSV);
response.write("<br>read: "+reCSV);
response.write("<br>Input: "+contentCSV);
}
}
The Output is:
not ok
Wroot: /irj/portalapps/DHTML
File: \irj\portalapps\DHTML\files\ma_infosysteme.csv
exists: false
read: false
Input:
So thanks to everyone who can give me a good hint.
Bye.
Request clarification before answering.
Without really looking too much into this it looks like the problem is with the way in which you are trying to open the file. I believe that when creating a File object you need to use a physical path. By using the getWebResourcePath() method you are retrieving the URL to this file and not the physical path name. There is another method (can't remember the exact name) called getPublicResourcePath() (or something similar) which will return the physical path to this file, i.e. c:\usr\sap\.....etc. If you try it this way it may well work
I hope this helps
D
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 13 | |
| 8 | |
| 7 | |
| 5 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.