Solved

UniversalFileWrite Error

Posted on 1998-01-14
2
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
bogamo earned 40 total points
ID: 1232206
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
ID: 1232207
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses

617 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