Solved

UniversalFileWrite Error

Posted on 1998-01-14
2
217 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
basic hardware to learn oop advanced design patterns 3 88
allswap challenge 6 75
Java array passed to SQL where clause 23 61
Java / Linux and Regular Expressions 11 67
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

948 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

23 Experts available now in Live!

Get 1:1 Help Now