Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 227
  • Last Modified:

UniversalFileWrite Error

I am running jdk1.1 on a NN(4.04) Browser.  I am trying to write a file out on the server dynamically within my java applet.  I am using the fileoutputstream and dataoutputstream utilities.  The code is as follows:

private FileOutputStream fout;
private DataOutputStream ostream;
public htmlObj(String title)
{
  try
  {
     fout = new                                         FileOutputStream("http://bds867/trs/"+title+".html");
      ostream = new DataOutputStream(fout);
  }catch(Exception e)
  {
      System.out.println("Error " + e);
  }

}

And the error I keep getting is:

# Security Exception:
checkwrite:http://bds867/trs/TEST_HTML_FILE.html
Error netscape.security.AppletSecurityException: security.checkwrite:
http://bds867/trs/TEST_HTML_FILE.html
#  UniversalFileWrite privilege not enabled: Modifying files stored in your computer

I think it means that I'm trying to write something on the client.  But I'm not.  Can anybody help me???


Joanna
0
jcora
Asked:
jcora
1 Solution
 
bogamoCommented:
As far as Java is concerned here, you are trying to write to a file called http://.... on the client machine...

I'm not sure you can write to a URL like that at all, however, you can easily read a URL.  The following code snippet should show you how to read a URL.


try {
     URL u = new URL("http://someserver/whatever.html");
} catch (MalformedURLException e){System.out.println("Error");}

InputStream is = u.openStream();

 then play with the inputstream all you want.

If you need to write something to the server, there are two decent methods which I have used in the past.  My preferred option is to have a java Application running on the server machine listening at a specified port.  Have the java application take care of writing the file.

The second and probably more standard approach would be to write a CGI script on the server, then post the content to this script.

Either option will require the use of Sockets......

Hope this helps,

-Geoff


0
 
jcoraAuthor Commented:
To tell you the truth, what I'm trying to do is print out the contents of a grid component and the only way I can see of doing that is by writing an html file with the table holding the contents, having the client read that html file, and then have the client print it with the utility provided on the browser.  Do you have any other sugestions?

Joanna
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now