File handling with applets

I am trying to design am opinion poll applet in Java for my site. The poll consists of a CheckbokGroup and a "Submit" Button. On clicking "Submit" the proper percentage claculations are performed and written to an external file using byte streams. Now problem is that i get a security exception when the applet appempts to create the file. Please advice.
Source Code
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.io.*;
<applet code="Poll" width=144 height=500>
</applet>
public class Poll extends Applet implements ActionListener
Checkbox cpp,java,assembly,vb,perl,asp;
CheckboxGroup cbg;
Label l1,l2,blank;
Button submit;
String q1="Which is your favourite";
String q2="programming language?";
boolean visible=true;
public void init()
setLayout(new GridLayout(9,1));
l1=new Label(q1,Label.CENTER);
l2=new Label(q2,Label.CENTER);
blank=new Label("");
cbg=new CheckboxGroup();
cpp=new Checkbox("C/C++",cbg,false);
java=new Checkbox("Java",cbg,false);
assembly=new Checkbox("Assembly",cbg,false);
vb=new Checkbox("Visual Basic",cbg,false);
perl=new Checkbox("Perl",cbg,false);
asp=new Checkbox("ASP",cbg,false);
submit=new Button("Submit");
add(l1);
add(l2);
add(cpp);
add(java);
add(assembly);
add(vb);
add(perl);
add(asp);
add(submit);
submit.addActionListener(this);
public void actionPerformed(ActionEvent ae)
int index=-1;
Checkbox temp=cbg.getSelectedCheckbox();
if(temp==cpp) index=0;
if(temp==java) index=1;
if(temp==assembly) index=2;
if(temp==vb) index=3;
if(temp==perl) index=4;
if(temp==asp) index=5;
if(index!=-1)
displayResults(index);
void displayResults(int index)
int size=7;
byte buf[]=new byte[size];
int pcent[]=new int[size];
try
InputStream fi=new FileInputStream("polldata.txt");
fi.read(buf);
fi.close();
buf[index+1]++;
buf[0]++;
for(int i=0;i pcent[0]=buf*100/buf[0];
try
OutputStream fo=new FileOutputStream("polldata.txt");
fo.write(buf);
fo.close();
}catch(FileNotFoundException fe)
}catch(IOException ie)
}catch(FileNotFoundException e)
try
for(int i=0;i<7;i++)
buf[i]=0;
OutputStream fi=new FileOutputStream("polldata.txt");
fi.write(buf);
fi.close();
System.err.println("Here am I");
//displayResults(index);
}catch(FileNotFoundException ee)
catch(IOException ee)
}catch(IOException e)
void graphResult(byte b[])
//PLEASE IGNORE THE CODE IN THIS METHOD.
//I STILL HAVE TO WRITE THE CODE FOR GRAPHICALLY
//DIPLAYING THE RESULTS
remove(l1);
remove(l2);
remove(cpp);
remove(java);
remove(assembly);
remove(vb);
remove(perl);
remove(asp);
remove(submit);
submit.setLabel("O.K.");
for(int i=0;i<8;i++)
add(blank);
add(submit);
add(l1);
add(l2);
add(cpp);
add(java);
add(assembly);
add(vb);
add(perl);
add(asp);
add(submit);

Are we talking about a local intranet site or a site on the web?
If the answer is local, then it's a simple matter of mapping the drive.
If the answer is the web, then you will need a server-side software (be it a servlet, cgi, asp, php, or whatever) to accomplish what you wanted to do.
V.V.

Similar Messages

  • File handling in applets

    i am doing a project in applet.
    i want to open file from that applet
    but appletviewer told below error,
    java.security.Exception (Access is dinied )
    but
    that same problem is solved in ordinary java program(not in applet )
    if applet is not supported for file I/O then any other idea.

    Signed applets seldom a good solution, though. I agree. I suspect most people who have this sort of problem chose applets for one of two reasons:
    1. Applets were the first thing covered in the book they were reading.
    2. They hoped it would be a short way to deploy their code.
    The correct reason to choose an applet would be because it was a useful feature for your web site.

  • File Sharing with Applets

    I am new to Java and applets in general so bear with me. I am wondering if it is possible to share files files between two clients via applets running in their browsers. From what i understand the 2 applets cannot directly connect but would it be possible with help from some sort of servlet? I noticed a very intriguing applet called bitlet (www.bitlet.org) that allows for a java applet to become an agent for bit torrenting. I am looking for similar capabilities except more direct between 2 specific clients.
    Is this possible? And if so where should I begin?
    I have developed a model that routes all files through the server but i am looking to conserve bandwidth through the use of this peer to peer network.

    As you are running Swing, I assume your applet is using the JAVA2 plattform.
    You can easily set up a policy file which defines the appropriate permissions necessary for your applet requires to wok.
    When deploying your applet, you can offer the download of that policy file to your users so that they can put it in their home directory as .java.policy
    You can read about policy files and applet restrictions at
    http://java.sun.com/docs/books/tutorial/security1.2/tour2/
    This should answer most of your questions.
    Oliver

  • CS4- CS5: changed behavior in file handling with points (".")

    ... oh, no, it's horrible -- new version, new problems
    I have such file names: 1_xxx_26.08.10.jpg, 2_xxx_26.08.10.jpg, ...
    I am creating an action which saves this file in a specific directory (after several editing steps) by using e.g. the first file and "Save for web".
    I want to execute this action via batch processing on all these files.
    Now the changed behaviour in CS5: all the files were saved as "1_xxx_26.08.jpg" in my selected directory and not as several files with the "old" file name. Only files without "my points", e.g. "1_test.jpg" where saved correctly -- as it was in CS4.
    Example action:
    -> "save vor web" doesn't use only the target directory to save the file with their own names. Insted they were all saved as "xxx_22.08.jpg"
    I don't want to change the name of all my files... so, any ideas?
    Thanks a lot.
    Carlos (0:20 am -- only because of this bug; yes, it's a bug for me )

    Are you sure?
    Yes, with these default settings and with other settings the file name is always xxx_26.08.jpg
    -> the result is always the same:
    I got around "my" problem by using a harmless file name ("temp.jpg") during recording of the action. Now I have only the directory specified in this action command without a filename:
    Maybe the only solution
    Thanks again
    carlos

  • Javascript multiple file upload with progressbar does not work in firefox, please help

    I want to upload files using this javascript snipped as well as processing non file fields on the same form. This works beautiful in IE11, Chrome and Opera, but not in firefox (version 34).
    I fired the non file handler with the action attribute on the <form> like this:
    <form id="upload_form" enctype="multipart/form-data" method="POST" action="nonFile.php">
    and the javascript with:
    <input name="submit" type="submit" style="background: green" value="Submit" onclick="return uploadFiles()"/>
    When I change type="button" the file uploads work in FF but the I have no control over the non file fileds.
    Can someone gives me an indication of what is wrong?
    oXHR.upload.addEventListener("progress", function(e){
    var percent=(e.loaded/e.total) * 100;
    _(idProg).value = Math.round(percent);
    _(idstat).innerHTML = filename.name + " "+Math.round(percent)+"% --- Please Wait";
    }, false);
    // Upload finish, show the size of the file in Bytes, KBytes or MBytes
    oXHR.onreadystatechange = function(){
    if (oXHR.readyState == 4 && oXHR.status == 200){
    var iBytesTransfered = bytesToSize(filesize);
    _(idstat).innerHTML = filename.name + " Size: " + iBytesTransfered + " "+100+"%";
    _(idProg).value = 100;
    // Upload failed
    oXHR.addEventListener("error", function(e){
    _(idstat).innerHTML = "Upload Failed";
    }, false);
    // Upload aborted
    oXHR.addEventListener("abort", function(e){
    _(idstat).innerHTML = "Upload Aborted";
    }, false)

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0, 0,0" width="600" height="360">
    <param name=movie value="example.swf">
       <param name="allowScriptAccess" value="always" />
    <param name="quality" value="high">
    <param name="allowScript" value="opaque">
    <param name="wmode" value="opaque">
    <embed src="example.swf" quality="high" allowScriptAccess="always" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=Shockwave Flash" type="application/x-shockwave-flash" width="600" height="360"></embed></object>

  • How to Intergrate Policy with applet

    hi my name is easan. I created an applet which reads and writes to a file but i had problems accessing the file. I solved that by granting read and write permission to the file by creating a policy. I can run the applet in the appletviewer using this line
    c:\>appletviewer -J-Djava.security.policy=<policyname> applet.html
    I would like to know hw to intergrate this policy with my applet so that i can run my applet from a browser.
    I would appreciated any help from anyone..... thank you in advance.
    Easan

    It's not possible to integrate policy file together with applet. If you want to perform these dangerous operation (read,write) from applet, you have to sign applet's jar file. And in applet's code you have to use AccessController.doPrivileged(PrivilegedAction action) for possibly unsafe parts of code.
    tina

  • Transferring files from users mashines on the server. Uploading with applet

    I'm trying to create applet that would do uploading of user file on the server.
    I'm woundering, Is there any ways to use java applet to open a file on user mashine into a stream and transfer it thought socket into
    server? Is there any good solution that do uploading with java applet? (I can't use CGI or PHP)
    I just noticed that applets don't support FileInputStream. How could I in general get information from user file?
    Ok. Thanks for ideas that you gave me. But there are useless. All that I can use is only HTTP. Unfortunately no FTP, no Web Start application.
    looking for help

    well, i don't work a lot with applets because of their inherent limitations. but my guess would be that you have to somehow use a signed applet. of course that doesn't help with the FileInputStream problem you are talking about.
    if i were going to do it and i couldn't use FTP, i'd write a WebStart app that calls servlets (sending it byte arrays) and the servlets will construct the files on the server...
    i have no clue how you are going to do what you want...

  • Hi,  I've just purchased and installed an upgrade from Lightroom 4 to 5.  It doesn't seem to handle raw files authored with a new Nikon D750 camera.  I spoke to the sales rep about this and he gave me a link to the 8.6 DNG converter page with instructions

    Hi,  I've just purchased and installed an upgrade from Lightroom 4 to 5.  It doesn't seem to handle raw files authored with a new Nikon D750 camera.  I spoke to the sales rep about this and he gave me a link to the 8.6 DNG converter page with instructions to download.  8.6 only works with Mac OS 10.7-10.9, according to the page.  I'm running Yosemite, Mac 10.10.  Please can you tell me my options?  Lightroom 4 worked beautifully with my older cameras' raw files so I would like to continue using the application.  What should I do?  How soon will Lightroom 5 be able to deal with raw files from a D750.  Many thanks, Adam.

    Until the next version of Lightroom is released, you need to use the DNG Converter version 8.7RC to convert your RAW photos to DNG and then import the DNGs into Lightroom.

  • Problem with „Empty-File Handling" in PI 7.11

    Hi,
    Iu2019m working in PI 7.11 with file adapter, Sender CC, option: Empty-File Handling: Process Empty Files.
    What I want to do is giving target file the system-date, if the source file is empty.
    But I always get a mapping error in RTWB: Premature end of file.
    It seems that the payload is empty.
    Any idea?
    Thanks a lot in advance!
    Rene Dong
    Edited by: Rene Dong on Aug 31, 2010 4:20 PM

    What I want to do is giving target file the system-date, if the source file is empty.
    The error you are getting makes sense. You should do a check in the mapping, if the payload is empty then use brute force to pass the system date.

  • Where are jar files downloaded to with Applet?

    I have an Applet and am using archive attribute in my applet tag to specify jar files needed by the applet. eg: "archive=myclassfiles.jar, foo.jar". Assume that myclassesfiles.jar has classes needed by the Applet and Foo.jar has some text files or xml files. Assume that Applet is signed.
    My question: I am assuming that all jar files are downloaded to the client when the Applet is started. Is this correct? If so, how can I open and read Foo.jar file within the Applet? I dont know the path to that file, that is, I dont know where on the client that Jar file has been downloaded to. Would the following work:
    URL aUrl = (new File("Foo.jar")).toURL();
    String path = aUrl.toString();
    would path point to the correct location of Foo.jar?

    They are downloaded to the client, and stored in a cache. I'm not sure they are readable from within the applet, however. But there are 2 solutions, depending on what you are doing.
    1) You want to get some images or other resources from the Jar file. Then do this:
    URL url = appletClass.getClass().getResource("myimage.jpg");
    ImageIcon icon = new ImageIcon(url);
    where appletClass is the applet object, and the resource ("myimage.jpg" is the relative path to the image in the Jar file.
    2) You want to muck around with the Jar (read it). Well you can't write to it that easily in an applet, as you can't access the file system without a signed applet, or you would have to POST it back to the web server via HTTP file upload. But if you want to just read it and get stuff out of it, you can always just do this:
    URL url = new URL(getDocumentBase(), "foo.jar");
    and then open the URLConnection for that URL and read the Jar in.

  • NFS: server reboot - client problem with "file handle" - no unmont

    Hello,
    when I restart a NFS-server and a client has a NFS-share on it still mounted, that NFS-share becomes unusable on the client: everything causes the client complain about an old "file handle", even trying to unmount that share!
    So my question is: How to deal gracefully with a NFS-server reboot and avoiding this file handle problem?
    Apart from going to each client and unmount the NFS-share by hand?
    Thanks!

    Do I need to Give these values manually again as they are moved from Env to other?
    When we transport ID objects, the values stored in the channel get lost and have to be manually enetered......it happens even for DEV --> QA environment.
    Now your channel should reflect PROD-related data.
    2- Why my Receiver communiation channel coimg as
    Communication Channel | PRD_400 | RFC_QA3_Receiver:
    The channel name does not depend on the environment it is present....verify the name once again!
    Regards,
    Abhishek.

  • Invalid File Handle Windows 7 with Novell Client 2 SP1

    Hello!
    I have a user on Windows who gets "invalid file handle" when saving files in
    WordPerfect and possibly Adobe as well. He thinks it mostly occurs when he
    has multiple files open and has saved one open file to a different
    directory. Then if he goes to save another file in it's same directory, he
    gets the error. I hope this makes sense. Would anyone have any idea if it
    does make sense?
    Thanks!

    Maybe that was once the intention by novell, but I assure you that you
    will have no trouble finding a lot of people/exemples that proves the
    opposite...
    Yeah, you can set the server-side settings which do have an impact,
    on win7 stations = blue screen if ON. But to say that it overrules the
    client setting....No way....
    We have had every single server EVER setup with Netware with
    filecaching OFF and OpLocks2 off and changing the client side setting
    DO make a direct difference, mostly bad but in the case of Win7, file
    caching on seems to be a requirement since Win7 can't handle any open
    files in a good way withouth it. It simply states "file not found" if
    file caching = off. If file caching = on, then the client will receive
    the message that the file is busy and can be opened in read-only.
    And, again, have file caching = on AND changing the server also to ON
    is NOT a good idea, at least not for us, since we got blue screens all
    over within a couple of min's when testing that setting and those
    disapperad just a fast when setting it to off again on the server.
    On Wed, 10 Mar 2010 07:04:55 GMT, PetervdM
    <[email protected]> wrote:
    >maybe not necessary.
    >the client side setting of the file caching setting is overruled by the
    >server side setting: if the server setting is set to OFF, the client
    >will NOT cache files residing on THAT server.
    >the same holds for the file commit setting. if it is set to OFF on the
    >server, the setting on the client side will be irrelevant, it has to be
    >ON on both sides to work.
    >so i've set all servers file caching off, and file commit on, and all W7
    >clients file caching on, and file commit on.
    >
    >no pain here!
    >
    >please read anders' post dated sep 24th, 2007 for the official statement
    >from Novell:
    >http://forums.novell.com/novell-prod...le-commit.html
    >
    >
    >> You've come to the same conclusion as we have;
    >>
    >> Historicaly; File caching OFF was a MUST.
    >>
    >> With Windows 7, we find that more or less HAVE TO use file caching,
    >> despite it's problems.
    >>
    >>>
    >>> Any other suggestions?

  • Saving a file with applets

    Hello my name is Lino and I'm Portuguese (sorry the bad English)
    I have a problem, I want to know how do save a .jpg file with the FileChooser and FileWriter, that is in the Server and I want to save a copy in my computer, but it must with Applets!
    Please help me
    Tanks
    LP

    Hi,
    because of security resons with applets, it is not possible to store an .jpg on your hard drive.
    Bernd

  • How can i handle with event, when i close a file (notped or word,excel..)??

    How can i handle with event, when i close a file (notped or excel...). i want do something..
    Edited by: Legy on Apr 21, 2008 11:45 PM

    of course notepad.exe is closed again as soon as the operating system has completed the process of loading its content into memory...
    And no "event" is fired when that happens, except maybe internal to the process that loaded the application to indicate that it's been loaded successfully and can now be executed.
    But there's no way your Java process is ever going to receive that notification.

  • Problem with File Handler and log files

    I'm developing a polymorphic structure for file handling specially for the log file for a server based App... Its working fine except for one thing. The log file that goes into the File Handler comes as a parameter to the class, the problem is that when it writes de file, though it DOES know where it should go, it doesn't do it and it writes the message into some other Log file belonging to another process...
    Does someone know how to avoid this or fix it?? any ideas or tips would be great!!

    Immediately below the Tabs saying "Files" and Assets" is a small box 
    with arrow on the right to show the drop down list.        In the box 
    on the right there's an icon of two networked computers.  Then it 
    says, "ftp://Hill farm Web Site"  which is the name of my website.     
    If I click on the arrows to pull up the drop-down box,  I get four 
    options divided by a line.   Above the line the options are Computer, 
    HD and ftp://Hill farm Web Site.  Below the line it says manage sites.
    Below this is list of files that make up my website in a directory 
    structure.   The header for the first column reads, "Local Files",  
    which appears to be untrue, because the top line in the directory 
    structure below reads,  "ftp://Hill farm Web Site".
    Does this help?
    regards
    David

Maybe you are looking for

  • Remove space after text in table?

    Hello! I am hoping that someone can help me out with this issue. Basically I want the extra space in each row or the tabel to be gone. I cant seem to sort out how. Any ideas? http://www.glennbartley.com/photoworkshops/home.htm Thank you very much! Gl

  • Valuation field not updated in Profit Center view

    Good morning Gurus, I am facing a big problem in KE24 report. As I've checked here, one of my valuation fields related to Raw Materials (VVM01) is only being updated in Legal View from CO. Even I check it in CE1SA01 table (my table for CO documents),

  • Videos load slowly or not at all with Flash 10!

    Well here we go. I'm working on IE 8 128-bit for Windows XP SP3 32-bit. Flash Player 10.1.102.64. Two days ago I noticed that video playback on sites like Youtube, Veoh, Magavideo etc the load time was real choppy. A video say two or three minuted lo

  • DATA LOAD ISSUE /NO ROLL UP MEMORY

    Hello Team, I have this master data load failure for FIS_BELNR. The problem which I think that everytime it tries to load it runs out of internal table space in the backend. I really don't know what it means. This data is been failing everyday becaus

  • Problems (not responding) when monitor not connected

    Hi All, I have been having problems with certain applications when using my macbook without the LED Cinema display connected.  When the monitor is connected there are no problems at all, but if it is disconnected and I try to open Google Chrome it ju