• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Security Errors

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);

}




}
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
You have to be odd to be #1 - Seuss. An odd little ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic