Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Security Exception: checkwrite:FILENAME

Posted on 1998-08-26
3
Medium Priority
?
171 Views
Last Modified: 2013-12-29
I have my main code called "oracle_supply.java", it calls
Create_Html.java (class) like this:

if ("Create HTML".equals(s)){
         new Create_Htmls();
}

In Create_Htmls, all i'm tring to do is open a file on the
server and write text to it like this:

public class Create_Htmls{
   static String buf1=null;
   static PrintWriter output = null;
   static String in = "test.dat";

   public Create_Htmls() {
      System.out.println ("Now in Create_Htmls code");
      try {
        output = new PrintWriter(new FileWriter(in));
      } catch (Exception e) {
      System.out.println("Couldn't create output file");
      System.exit(1);
      }

      output.println("This is test.dat");

What happens is nothing, in the java console window
I get this:

Now in Create_Htmls code
# Security Exception: checkwrite:test.dat

Now if on the server, I say "java Create_Htmls" it
creates the test.dat file fine, but NOT when I call
it from "oracle_supply".

I have other code that I have written that does similiar
things, and it works fine. But I missing something
in this project. Any suggestions?
Basically, i'm running an applet, and from that applet,
i'm calling another piece of code that will create a
file on the server.  Hum... on further review, I have just
remembered that in my other code writing files on the
server, I used a socket. Is that what I need to do here?
I will try that (I know it works) while I wait for an answer.
So new question is can I create a file on my server from
an applet with out using sockets?

Thanx!
Don
0
Comment
Question by:afsac
[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
3 Comments
 

Author Comment

by:afsac
ID: 1222597
Edited text of question
0
 
LVL 8

Accepted Solution

by:
diakov earned 750 total points
ID: 1222598
Hi,

Let's first clear some basics that I sence may be are not very clear to you.
- First the applet is a piece of code, transported through the net via the HTTP protocol to the client machine and run there.

- The applet runs in the browser's JVM and is very restricted on usage of the local client machine resources.

- The only place it could contact without a security exception is the web server it originates from.

- Apparently, when you run your 'file creating code' from the applet, it loads in the local machine and tries to create a file on it. Which in case of applet come from a server, will lead to the described security exception.

- What you need to do is to write an apllication that runs on the server and anticipates calls from the applets on the client machines connected to the web server there.

- There are several ways to do this:
  - Using sockets. There again are several ways:
   . simple socket communication. the server program listens to a port on the server machine, and the client program (the applet) opens a socket to this port. There quite many examples on the net, I can send you a chat application if you want.
   . some middleware, like JavaRMI, that hides the socket communication from you and provides classes for doing this quite transparently. For example, on the applet, you can create an Java object, which actually is on the server, but your code uses it like it is in the applet itself.

Problem with sockets is that if you have a firewall, it disallows the direct socket communication except on some legal ports like the ftp - 21, web server - 80, telnet - 23, etc. And it is a big problem, because a lot of companies use corporate firewalls.

 - using HTTP/CGI tunneling. You can write a server application which is an extension of the web server. Some web servers allow scripting, like MSIIE, Oracle web server, etc. Some of them have extensions for Java, and you can write so called servlets.


I suggest the HTTP/CGI, which differs in form according to the scripting language or CGI programs that are used on the web server.

So the scenario is:

Your applet loads, and opens the URL where the server script processes the request for creating a file. After receiving the data for the file, the server object creates a file locally on the server, and returns result.

If you have more comments, please send them.

Cheers,
  Nikolay


0
 

Author Comment

by:afsac
ID: 1222599
Nikolay,
     I have it working now by using a socket.  At this time, we don't
have a firewall, but probably will in the future.  The Java code is loaded
from my server, and the file to be created is on the same server. So
the Socket thing is working for me for now.

     Thank you for your quick response.

Don
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This video teaches viewers about errors in exception handling.
Suggested Courses

722 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