Solved

Applet data to TextFile

Posted on 2003-12-01
14
283 Views
Last Modified: 2013-11-23
Hai
  I am having an Applet.

import java.awt.*;
import java.io.*;
import java.applet.*;

public class FileTest extends Applet {

  public void paint(Graphics g) {
    String fileName = "MyTest.txt";
    try {
      FileOutputStream fos = new FileOutputStream(fileName);
      PrintStream outputFile = new PrintStream(fos);
      outputFile.println(" This is a test");
      outputFile.close();
      fos.close();
      g.drawString("The applet created the file " + fileName, 10, 20);
    }
    catch (Exception e) {
      g.drawString(e + "", 10, 20);
    }
  } // paint

}


If I execute this It shows error: access denied  java.FilePermission .....
How to send the output to txt file from Applet?

I want to save the Applet and Txt file in server and  clients want to write the information to the txt file through the Applet.
Is it possible ? If so How?

Thanks
Narayanaswamy
0
Comment
Question by:Narayanaswamy
  • 7
  • 5
14 Comments
 

Author Comment

by:Narayanaswamy
ID: 9856122
Can any one give me sample codes or links

Narayanaswamy
0
 
LVL 92

Expert Comment

by:objects
ID: 9856216
you need to sign your applet

And you shouldn't do the file writing in paint, this will get called every time the applet requires repainting.
0
 

Author Comment

by:Narayanaswamy
ID: 9856248
Thanks objects

I am not aware of "you need to sign your applet"

Can i get more details and any sample codes


Narayanaswamy
0
 
LVL 92

Expert Comment

by:objects
ID: 9856262
0
 

Author Comment

by:Narayanaswamy
ID: 9856752
Hai
I read that article.

I did the Signed Applet using JDK Plugin

It is working in my system. ( It is creating the txt file in desktop not in the same folder where the class file resides ) and also When I tried from another system this is not working....

When I try Signed Applet in Internet Explorer
makecert is not accepted by the command line

Can you help me in doing this....

Narayanaswamy
0
 

Author Comment

by:Narayanaswamy
ID: 9856857
Hai

I placed the jar file and the html file in the Server.

I opened the Url..
The txt file is created in my system but i want that to be created in the server....

How to to that..?

Thanks
Narayanaswamy
0
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.

 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 9861970
You need to write a server component (such as a servlet) to accept the data and write the file to server.
0
 

Author Comment

by:Narayanaswamy
ID: 9864106
Can I get more details about that please.....

Narayanaswamy
0
 

Author Comment

by:Narayanaswamy
ID: 9902361
Hai
May i know from where I can download the Microsoft SDK for Java
and how to install and include in my class path to sign my applet...

Thanks
Narayanaswamy
0
 
LVL 92

Expert Comment

by:objects
ID: 9902376
> where I can download the Microsoft SDK for Java

i don't believe it is available anymore.
0
 

Author Comment

by:Narayanaswamy
ID: 9902433
Then can you explain me
how to sign in  the applet to the system that doesn't have JDK plugin...?

When i tried to start My applet in the system that doesnt have JDK plugin but  Microsoft JVM is present I am not able to see the applet insted i can able to see only a blank space...

How to load my applet into that system.

Thanks
Narayanaswamy
0
 
LVL 92

Expert Comment

by:objects
ID: 9902436
Unfortunately I don't think you can.
Try searching the web for the tools required.
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
Non-recursive backtracking, using a stack 1 96
Problem to start Neon 20 83
rhino JavaScript import, load 25 66
more than one jdk and one jre 1 30
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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

929 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

11 Experts available now in Live!

Get 1:1 Help Now