permaculture playing cards*
The moose likes Applets and the fly likes Security Errors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Security Errors" Watch "Security Errors" New topic
Author

Security Errors

rahul karwal
Ranch Hand

Joined: Oct 26, 2001
Posts: 73
Hi ppl,
i am having problem when i run this applet its giving me a security Errors and saying errors such as permision denied to write to a file. What i am actually trying to here get user's name, last name, email address and write that to a file and want to send the file to the server... but connecting to server is still needed to be coded but i am having problem with creating a fils i dont know so can anyone please help me...
thanks

import java.io.*;
import java.io.File;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.util.*;
public class myapplet extends Applet implements ActionListener,TextListener {
TextField fname;
Panel dpanal;
Label fnamelabel;
Label lnamelabel;
TextField lname ;
Label emaillabel;
TextField email;
Label space;
Label note;
Label fevent;
Checkbox firstevent;
Label sevent;
Checkbox secondevent;
Label tevent;
Checkbox thirdevent;
Label foevent;
Checkbox forthevent;
Label submitlabel;
Button submmitbutton;
String firstNameText="";
String secondNametext="";
String emailtext ="dumb";
public void init(){

dpanal = new Panel();
fnamelabel = new Label("Please Enter Your First Name");
fname = new TextField(10);
fname.addTextListener(this);
lnamelabel = new Label("Please Enter Your Last Name");
lname = new TextField(10);
lname.addTextListener(this);
emaillabel = new Label("Please Enter Your E-mail Address");
email = new TextField(10);
email.addTextListener(this);
space = new Label();
note = new Label("Please Click As Many Events You Are Interested In");
fevent = new Label("");
firstevent = new Checkbox("Baseball");
sevent = new Label("");
secondevent = new Checkbox("Cricket");
tevent = new Label("");
thirdevent = new Checkbox("Football");
foevent = new Label("");
forthevent = new Checkbox("Tennis");
submitlabel = new Label("");
Button submmitbutton = new Button("Submit");
submmitbutton.addActionListener(this);

dpanal.setLayout(new GridLayout(9,9));
dpanal.add(fnamelabel);
dpanal.add(fname);
dpanal.add(lnamelabel);
dpanal.add(lname);
dpanal.add(emaillabel);
dpanal.add(email);
dpanal.add(space);
dpanal.add(note);
dpanal.add(fevent);
dpanal.add(firstevent);
dpanal.add(sevent);
dpanal.add(secondevent);
dpanal.add(tevent);
dpanal.add(thirdevent);
dpanal.add(foevent);
dpanal.add(forthevent);
dpanal.add(submitlabel);
dpanal.add(submmitbutton);
submmitbutton.setBackground(Color.lightGray);
setBackground(Color.white);
add(dpanal);

}


public void actionPerformed(ActionEvent e) {

print();
clearTextfield();
createFile();


}

public void textValueChanged(TextEvent e){

firstNameText = fname.getText();
secondNametext = lname.getText();
emailtext = email.getText();
}

public void print(){

System.out.println(firstNameText);
System.out.println(secondNametext);
System.out.println(emailtext);
}

public void clearTextfield(){

fname.setText("");
lname.setText("");
email.setText("");
System.out.println("Text fields cleared");
}

public void createFile() {

File file = new File(emailtext);

try{

file.createNewFile();
}
catch(IOException e1){
System.out.println("error occured"+e1);
}


System.out.println("after create method");
boolean cheak= file.exists();
System.out.println(cheak);

}




}
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15657
    
  15

The Java sandbox rules forbid unsigned applets from reading or writing files on the local computer - which is why the Nimda virus wasn't written in Java.
From what I've seen, in 99% of the cases, trying to produce a signed applet isn't worth the trouble. It's a LOT of trouble - especially since you have to do it 2 different ways. Do you REALLY need a local file? Especially when you're dealing with sensitive data like user names and passwords? You can create an HttpURLConnection, open an output stream and write to the server directly.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Security Errors
 
Similar Threads
security errors in Applets
Help please.
How to embed JavaFX 2.0 application with jsp (to deploy it on server)
swing applet help
security problem in applets