cancel
Showing results for 
Search instead for 
Did you mean: 

Wrilte a file and get the URL to it

Former Member
0 Kudos

I want to be able to write a file in a Web Dynpro view and get the URL to that file for display in the IFrame of another view.

What I've tired without success is:

String filename = "temp_" + (new Date()).getTime() + ".html";

File file = new File(filename);

PrintWriter output = new PrintWriter(new FileWriter(file));

output.println("<html><body>This is a test</body></html>");

String fileURL = WDURLGenerator.getAbsoluteWebResourceURL(filename);

....

I was hoping that the last line would give me a URL to reference the file that was created, but apparently it does not.

I guess what I want to do is create a File in a platform independant way, find out where that file is located and get a publically accessible URL to it to display it.

Has anyone done anything like that who can point me in the right direction?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I think I'm getting closer, though still not quite working:


    	String filepath = WDURLGenerator.getPublicResourcePath("testing.html");
    	File file = new File(filepath);
    	PrintWriter output = new PrintWriter(new FileWriter(file));
    	output.println("<html><body><h1>This is a test</h1></body></html>");
    	output.flush();
    	output.close();
    	String url = WDURLGenerator.getWebResourceURLForPath(filepath);
    	wdContext.currentContextElement().setChartFilename(url);
    	wdComponentAPI.getMessageManager().reportSuccess("PublicResourcePath " + filepath);
	wdComponentAPI.getMessageManager().reportSuccess("WebResourceURLForPath " + url);

My output from this is:

PublicResourcePath .\temp\webdynpro\public\local\Workflow\webdynpro\testing.html

WebResourceURLForPath ../../../resources/temp/webdynpro/public/local/Workflow/webdynpro/testing.html

I get a resource not found (404) when I try to load an IFrame with the url ../../../resources/temp/webdynpro/public/local/Workflow/webdynpro/testing.html

Former Member
0 Kudos

Hi,

Try this code:

String filepath = WDURLGenerator.getPublicResourcePath("testing.html");
File file = new File(filepath);
PrintWriter output = new PrintWriter(new FileWriter(file));
output.println("<html><body><h1>This is a test</h1></body></html>");
output.flush();
output.close();
String url = WDURLGenerator.getWebResourceURLForPath(filepath);
wdContext.currentContextElement().setChartFilename(filepath);

Regards,

Satyajit.

Answers (0)