GeeCON Prague 2014*
The moose likes Java in General and the fly likes security problem in applets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "security problem in applets" Watch "security problem in applets" New topic
Author

security problem in applets

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);

}




}
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Welcome to the applet sandbox. It's warm and safe in here, you can play to your heart's content but you won't be able to escape to the outside world. You can only go back to where you came from.
Oh, there's a gate if you know how to open it - but sly Mr Gates has put a different lock on the gate, as has stern Mr Andreessen. Keys to these gates are only sold for big money by merchants like VeriSign Key Shoppe. Besides, Mr Gates has decided to demolish his sandbox because all kids can play in there. He is a selfish father who wants a sandbox where only his own children can play.
Seriously, you're entering a morass, and there are only two reasonably ways out. First, junk the applet and use a HTML form and JavaScript. Or, second, send back your data in the form of a HTTP request made by the applet (without first saving it in a file).
- Peter
 
GeeCON Prague 2014
 
subject: security problem in applets