Solved

UniversalFileWrite Error

Posted on 1998-01-14
2
216 Views
Last Modified: 2008-02-01
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
Comment
Question by:jcora
2 Comments
 
LVL 1

Accepted Solution

by:
bogamo earned 40 total points
Comment Utility
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
 

Author Comment

by:jcora
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now