Writing to remote files using an applet.

I programmed a basic game as an applet for a web site, but it really needs some kind of high score functionality.
I plan to store the high scores in a file in the server. Reading information from the file is no problem at all, but updating the file with new highscores runs into security problems. Obviously I can't simple use a simle file writer to do that. What is the proper way to do this?
One possibility which came to my mind is to make the applet open a ftp connection to the server and upload the new highscores file to the server. but that would mean hardcoding my password into the applet code.
Please keep in mind using servlets or any other programs running on the server is out of question.
Any help greatly appreciated,thanks in advance.

Why not host this applet on another free server which supports mysql/postgresql/etc and store it in a database? Any hosts/tools needed, just ask - there are several good freeware.
/DanX

Similar Messages

  • Writing to a file using an applet?

    I'm trying to write to a .txt file using an applet. When I run the applet from JBuilder everything works perfectly, but when I run it from internet explorer I don't seem to be able to read or write from and to the file... Anyone has an idea? Is it possible to do that?

    Applets run on restricted security priveelege. Unless you sign your applet, you cant access the files from the applet.
    Go through this.. This might help you
    http://developer.java.sun.com/developer/technicalArticles/Security/Signed/

  • Writing into a remote file using URL.

         URL url = new URL("http://144.16.241.110:9090/b.txt");
         URLConnection connection = url.openConnection();
         connection.setDoOutput(true);
         PrintWriter out=new PrintWriter(new BufferedOutputStream(connection.getOutputStream()));
         Writer out =(new BufferedWriter(new OutputStreamWriter(connection.getOutputStream())));
         out.flush();
         out.write('d');
         out.close();
    I am using the following code to write into that file.
    This is compiled and no error comes while compiling.
    But while running I get the following.
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <HTML><HEAD>
    <TITLE>405 Method Not Allowed</TITLE>
    </HEAD><BODY>
    <H1>Method Not Allowed</H1>
    The requested method POST is not allowed for the URL /b.txt.<P>
    <HR>
    <ADDRESS>Apache/1.3.12 Server at 144.16.241.110 Port 9090</ADDRESS>
    </BODY></HTML>
    How to rectify this.Thanx in advance.
    I am able to read from the same file.

    Thanx
    Is it possible to set permission to a remote file
    using our program? If so give me some sample code.

  • Writing to a file using log4j

    Hi ,
    I am facing an issue in rolling out file on an hourly basis. I have a source file , say usagelog_date.log which records logging, then after an hour an hour I have to separate that file , give it a different name say usagelog_date.10.log , I copy the contents of the source file into the rolling file, and make that source file empty. But after making that file empty when I am writing to the file using some threads simultaneously, I get some blank characters first and only after that the logging starts, that increases the file size to a large extent.
    My java code which does this separation is as follows.
    package com.proquest.services.usage.helper;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.FileReader;
    import java.nio.channels.FileLock;
    import java.util.Calendar;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    public class UsageRotator {
         private Log scpLog = LogFactory.getLog("SCPLog");
         public String rotateAndReturnFilename(String rotationdate, String location) throws Exception {
              Calendar calendar = Calendar.getInstance();
              int hour_of_day = calendar.get(Calendar.HOUR_OF_DAY);
              String rotationalTime = ((hour_of_day < 10) == true) ? "0" + hour_of_day : "" + hour_of_day;
              String rotatedFileName = null;
              File usageLoggingLogFile = new File(location + "usagelogging." + rotationdate + ".log");
              if (usageLoggingLogFile != null && usageLoggingLogFile.exists()) {
                   File usageLoggingRotatedFile = new File(location + "usagelogging." + rotationdate + "." + rotationalTime + ".log");
                   copyFile(usageLoggingLogFile, usageLoggingRotatedFile);
    //copying the contents of source file to a rolling file
                   FileOutputStream fout = new FileOutputStream();
    // making the source file empty fout.flush();               
                   usageLoggingLogFile.setWritable(true);
                   boolean isEmpty = isFileEmpty(usageLoggingLogFile);
                   if(isEmpty)     
                        scpLog.info("Existing file has been empty so it's good to proceed for looging next occurances");
                   rotatedFileName = usageLoggingRotatedFile.getName();
                   scpLog.info("Log file has been rotated to "+rotatedFileName);
              } else {
                   throw new Exception("File rotation failed : UsageLogging file couldn't be found for the supplied date");
              return rotatedFileName;
         private void copyFile(File source, File destn) throws Exception {
              FileInputStream fis = new FileInputStream(source);
         FileOutputStream fos = new FileOutputStream(destn);
         try {
         byte[] buf = new byte[1024];
         int i = 0;
         while ((i = fis.read(buf)) != -1) {
         fos.write(buf, 0, i);
         catch (FileNotFoundException e) {
         throw new Exception("[ERROR] File copy failed");
         finally {
         if (fis != null) fis.close();
         if (fos != null) fos.close();
         private boolean isFileEmpty(File file) throws Exception {
              FileReader fr = new FileReader(file);
              BufferedReader br = new BufferedReader(fr);
              boolean isEmpty = true;
              while (br.readLine() != null) {
                   isEmpty = false;
              return isEmpty;
    And my log4j file with which I am writing is
    # Default is to send information messages and above to the console
    log4j.rootLogger = DEBUG, DailyLogFileAppender
    # Logger configurations
    #log4j.logger.com.proquest.services.usage=DEBUG, DailyLogFileAppender
    log4j.logger.com.proquest.services.UsageLog=INFO, UsageLogFileAppender
    # Appender configurations
    # Define an appender which writes to a file which is rolled over daily
    log4j.appender.DailyLogFileAppender = com.proquest.services.log.PqDailyRollingFileAppenderExt
    log4j.appender.DailyLogFileAppender.File = logs/usagelogging/usagelogging-error.log
    log4j.appender.DailyLogFileAppender.DatePattern = '.'yyyy-MM-dd
    log4j.appender.DailyLogFileAppender.Append = true
    log4j.appender.DailyLogFileAppender.layout = org.apache.log4j.PatternLayout
    log4j.appender.DailyLogFileAppender.layout.ConversionPattern=%d{ISO8601} %m%n
    log4j.additivity.com.proquest.services.usage = false
    log4j.additivity.com.proquest.services.UsageLog = false
    log4j.appender.UsageLogFileAppender = com.proquest.services.log.PqDailyRollingFileAppenderExt
    log4j.appender.UsageLogFileAppender.File = logs/usagelogging/usagelogging.log
    log4j.appender.UsageLogFileAppender.DatePattern = '.'yyyy-MM-dd
    log4j.appender.UsageLogFileAppender.Append = true
    log4j.appender.UsageLogFileAppender.layout=org.apache.log4j.PatternLayout
    log4j.appender.UsageLogFileAppender.layout.ConversionPattern=%d{ISO8601} %m%n
    Can somebody please suggest me what to do, as I have been badly deadlocked into the problem.
    Thanks
    Suman

    neoghy wrote:
    ... rolling out file on an hourly basis.
    And my log4j file with which I am writing is
    #  Default is to send information messages and above to the console
    log4j.rootLogger = DEBUG, DailyLogFileAppender
    # Logger configurations
    #log4j.logger.com.proquest.services.usage=DEBUG, DailyLogFileAppender
    log4j.logger.com.proquest.services.UsageLog=INFO, UsageLogFileAppender
    # Appender configurations
    #  Define an appender which writes to a file which is rolled over daily
    log4j.appender.DailyLogFileAppender = com.proquest.services.log.PqDailyRollingFileAppenderExt
    log4j.appender.DailyLogFileAppender.File = logs/usagelogging/usagelogging-error.log
    log4j.appender.DailyLogFileAppender.DatePattern = '.'yyyy-MM-dd
    log4j.appender.DailyLogFileAppender.Append = true
    log4j.appender.DailyLogFileAppender.layout = org.apache.log4j.PatternLayout
    log4j.appender.DailyLogFileAppender.layout.ConversionPattern=%d{ISO8601} %m%n
    log4j.additivity.com.proquest.services.usage = false
    log4j.additivity.com.proquest.services.UsageLog = false
    log4j.appender.UsageLogFileAppender = com.proquest.services.log.PqDailyRollingFileAppenderExt
    log4j.appender.UsageLogFileAppender.File = logs/usagelogging/usagelogging.log
    log4j.appender.UsageLogFileAppender.DatePattern = '.'yyyy-MM-dd
    log4j.appender.UsageLogFileAppender.Append = true
    log4j.appender.UsageLogFileAppender.layout=org.apache.log4j.PatternLayout
    log4j.appender.UsageLogFileAppender.layout.ConversionPattern=%d{ISO8601} %m%nCan somebody please suggest me what to do, as I have been badly deadlocked into the problem.I assume you mean [DailyRollingFileAppender ^apache^|http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/DailyRollingFileAppender.html]
    log4j.appender.DailyRollingFileAppender.DatePattern = '.'yyyy-MM-dd-HH

  • Writing into Excel file using PL/SQL and formatting the excel file

    Hi,
    I am writing into a excel file using PL/SQL and I want to make the first line bold on the excel. Also let me know if there are any other formatting options when writing into excel.
    Regards,
    -Anand

    I am writing into a excel file using PL/SQL
    Re: CSV into Oracle and Oracle into CSV
    check that thread or search in this forum...

  • How to attach files using an applet

    hi,
    i want to know how can i use an applet to upload or attach files in my application
    help me

    Hallo there,
    I am intrested on the same topic but I am not so good to modify the sound sdk demo. Is there anyone willing to share some code?
    Thanks
    Matteo

  • Reading and Writing large Excel file using JExcel API

    hi,
    I am using JExcelAPI for reading and writing excel file. My problem is when I read file with 10000 records and 95 columns (file size about 14MB), I got out of memory error and application is crashed. Can anyone tell me is there any way that I can read large file using JExcelAPI throug streams or in any other way. Jakarta POI is also showing this behaviour.
    Thanks and advance

    Sorry when out of memory error is occurred no stack trace is printed as application is crashed. But I will quote some lines taken from JProfiler where this problem is occurred:
              reader = new FileInputStream(new File(filePath));
              workbook = Workbook.getWorkbook(reader);
              *sheeet = workbook.getSheet(0);* // here out of memory error is occured
               JProfiler tree:
    jxl.Workbook.getWorkBook
          jxl.read.biff.File 
                 jxl.read.biff.CompoundFile.getStream
                       jxl.read.biff.CompoundFile.getBigBlockStream Thanks

  • Writing data into files using VHDL Textio

    Hi 
    I was trying to write nos. from 1 to 8 into a text file using the below program.
    process
    type IntegerFileType is file of integer;
    file data_out: IntegerFileType ;
    variable fstatus: FILE_OPEN_STATUS;
    variable coun: natural:= 1;
    begin
    file_open(fstatus,data_out,"myfile.txt",write_mode);
    for i in 1 to 8 loop
    write(data_out, coun);
    coun := coun + 1;
    end loop;
    file_close(data_out);
    wait; -- an artificial way to stop the process
    end process;
    But getting the below attached result..
    Can you please help me out what could be wrong with the program.
    Thanks & regards
    Madhur

    Do you want the numbers in the file to be human readable ASCII?
    Then you'll need to convert your coun to a string. 
    declare another variable of type line (type access to string).
    do a write() to the line, then a writeline() to the file.
    natural'image(coun) will convert coun to a string.
    Google should help you find example code that will help.

  • Getting remote file using FTP Server Issue in OSB

    Hi Guys,
    I have configured a FTP server on my local system and I created a proxy service to get file from ftp location to some other location but it fails . I used ftp protocol for getting file
    and my ftp location is D:\host\ftp and it has another folder called osb . I used ftp as protocol and EndPointURI is ftp://localhost/. It fails to get files and shows error message like
    com.bea.wli.sb.transports.TransportException: <user:osb>Unable to list files for
    directory: .
    at com.bea.wli.sb.transports.ftp.connector.FTPWorkPartitioningAgent.exec
    ute(FTPWorkPartitioningAgent.java:218)
    In case of Business Service, writing a file to ftp location (i.e ftp://localhost/ means D:\host\ftp\osb) working.
    I used service account for both proxy,BS to connect . osb is username and same as password.
    Can Any one please suggest me How to solve this issue?
    Thanks,
    Srinivas.
    Edited by: 863597 on May 22, 2012 1:06 AM

    Hi Vijay Thank you,
    Can we do the pooling directly using FTP protocol like JMS protocol in OSB with out using FTP JCA Adapter.I did in such a way but it fails. For pooling files the mentioned endpoint uri is as ftp://localhost/ and it actual path is D:\host\ftp and ftp has another folder called osb here i have to get the files from this osb Can any one suggest me if there is any problem with the ftp protocol end point.
    Thank You,
    Srinivas.

  • SSIS and Secured FTP Commands to GET a Remote File using wildcards

    So my biggest caveat here is dealing with wildcards! For the life of me I cannot find any good examples of SSIS and scripting that uses FTP wildcards to GET certain Files. In a nutshell, here's what I need to do...
    Query a SQL Server Database which has a parsed File Name, the first 50 characters of the file name.
    The Query "Result Set" is put into an Object Variable User::SQLServerFileList
    I then utilize a "Foreach Loop Container" which reads the User::SQLServerFileList and puts it into Variable User::SQLServerFileNm...which is again the first 50 characters of the File Name
    Within the "Foreach Loop Container", I then utilize an "Expression Task" which builds a variable User::RemoteFileLookup which is a concatenation of the User::RemoteFolderPath + User::SQLServerFileNm + the wildcard *(Variable
    User::RemoteWildCard)
    I then try and utilize a "FTP Task" to use that concatenated Variable to go and GET the Filename but every time I try, it does not like what I'm sending via the "FTP Task"
    Error: 0x0 at TF Secure FTP Task, ExecuteTask Failed:: Illegal characters in path.
    I realize I might have to do something like this via C#.
    My biggest challenge is providing the GET Command via the Remote FTP Site with a parsed Filename and utilizing a wildcard.
    mc7i1231_20140227_050114_27_05_02_09*.999
    And the Filename that exists on the FTP Server is...
    mc7i1231_20140227_050114_27_05_02_09_x12_a43419452ca844a9b8a00f61e655dca3.x12-20140303180032.999
    Can any gurus out there PLEASE help me out???
    Thanks in advance for your review and am hopeful for a reply.
    PSULionRP

    Hi PSULionRP,
    According to the document
    FTP Task, we can read that:
    The FTP task supports the ? and * wildcard characters in paths. This lets the task access multiple files. However, you can use wildcard characters only in the part of the path that specifies the file name. For example, C:\MyDirectory\*.txt is a valid
    path, but C:\*\MyText.txt is not.
    So, when you use expression tobuild the variable RemoteFolderPath, make sure the evaluated value of the expression conforms to the above rule. 
    Regards,
    Mike Yin
    TechNet Community Support

  • How to read client's home directory files using  signed applets

    hi
    i want to konw the exact procedure for the creation of signed applets . using that i want to read my client files....
    Thanks
    Dileep

    google: http://www.google.com/search?q=how+to+sign+an+applet

  • Writing to a file using labview

    hello,
    so i wrote this vi to write some data to a text file and that part works correctly.
    the problem i'm having is that, it doesn't append to the file. so for each data point that it writes it requires a new file.
    in otherwords, if i need to write 10 data points the program prompts each time for 10 different file names.
    how do i resolve this so that the program will write all the 10 data points to one file, by appending each time.
    e.g. data points: 29.5, 34.2, 21.34, 543.2 ... etc
    i want something like this:
    29.5
    34.2
    21.34
    543.2
    etc
    thanks
    -r

    If the path is correctly wired, it should not prompt you for another file. Make sure you wire the path to a shift register so it is available the next time the "write charaters ..." is called.
    You can do the "exception" in many ways. Some examples:
    --Check if the file exists, and if so, append.
    --Use a shift register initialized by "false", then wire it to the append terminal. Feed a "true" to the shift register on the right.
    However, you should consider using some of the lower level file I/O and open the file only once, then keep writing data and close it only at the end. The high-level "write characters to file" would need to do a lot of extra work because whenever it is called it opens the file, writes/appends data, then
    closes the file again.
    LabVIEW Champion . Do more with less code and in less time .

  • Writing to a file using url

    Hi all,
    I have build an applet which I am going to put in a web. Right now I am working locally and I'm able to read file's using this code:
    url = new URL("http://localhost/file.txt");
                is = url.openStream();
                BufferedReader bufRdr  = new BufferedReader(new InputStreamReader(is));
                while((line = bufRdr.readLine()) != null)
                  //do things
                bufRdr.close();
                is.close();
            }Now I would like to be able to write in this file. How could I do it?
    Thanks!

    Using HTTP to open a local file will only work if you have a web server running locally, and if that server happens to know how to find and deal with that file.
    If you want to use that same web server to write files locally, then your local web server will need to have functionality to write files.
    So your first issue is dealing with that. How you do this will depend on what web server you're currently running.
    Using a web server might not be the best approach, by the way.

  • Problem writing to excel file using report generation toolkit

    hello everyone, i have this report generation toolkit... and i want to output DAQmx Analog I/P data on to an excel sheet. the DAQmx is programmed to collect 
    data at 3samples/sec. however, when i see the excel file that Report Generation Toolkit generates, the time stamp is updated every second instead of every 0.33sec. 
    can anyone please help me?  i am using the MS Office Report Express VI. 
    Now on LabVIEW 10.0 on Win7

    @All, I got rid of the express VI, decided to work on the custom low level VIs instead. however, i have a new problem now... 
    I have a case statement wherein, the user selects if he wants to start generating a report. once the program enters tat loop, the program speed reduces! 
    can anyone please tell me why is it happening? i ahve attached the vi... also another question.. in this VI, i am capturing the unwanted data into the graph as I am indexin the graph input. how can i make a logic 
    that the graph captures the data only when I am switching the CREATE REPORT button (which is in the while loop). is there a way that I can append the data to the graph without creating a new graph every iteration? please let me know
    thanks
    Now on LabVIEW 10.0 on Win7
    Attachments:
    Untitled 7.vi ‏75 KB
    Untitled 7.JPG ‏99 KB

  • Writing an XML file using a Servlet

    Hello, I'm trying to code a servlet that receives a POST from a HTTP and output its data to a XML file, the problem is that I get the following error:
    The XML page cannot be displayed
    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
    XML document must have a top level element. Error processing resource 'http://localhost:8080/XMLSender/xmlsend'.
    I don't know what happens, because I'm NOT trying to show the content, just to save it, I post my code here so anyone can help me, please. Thanks in advance.
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class xmlsender extends HttpServlet
    public void service(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    ServletOutputStream salida = res.getOutputStream();
    res.setContentType("text/xml");
    String cadenanumero = req.getParameter("numero");
    String cadenaoperadora = req.getParameter("operadora");
    String cadenabody = req.getParameter("mensaje");
    String cadenashortcode = req.getParameter("shortcode");
    File f1 = new File("salida.xml");
    FileWriter writer = new FileWriter(f1);
    writer.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
    writer.write("<root>");
    writer.write("<tlf>" + cadenanumero + "</tlf>");
    writer.write("<op>" + cadenaoperadora + "</op>");
    writer.write("<sc>" + cadenashortcode + "</sc>");
    writer.write("<body>" + cadenabody + "</body>");
    writer.write("</root>");
    writer.close();
    }

    Yes, in fact what I want is the file to be in the server, now, I modificated my code to the following:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class xmlsender extends HttpServlet
    public void service(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    ServletOutputStream salida = res.getOutputStream();
    res.setContentType("text/HTML");
    String cadenanumero = req.getParameter("numero");
    String cadenaoperadora = req.getParameter("operadora");
    String cadenabody = req.getParameter("mensaje");
    String cadenashortcode = req.getParameter("shortcode");
    File f1 = new File ("salida.xml");
    FileWriter writer = new FileWriter(f1);
    /*salida.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
    salida.println("<root>");
    salida.println("<tlf>" + cadenanumero + "</tlf>");
    salida.println("<op>" + cadenaoperadora + "</op>");
    salida.println("<sc>" + cadenashortcode + "</sc>");
    salida.println("<body>" + cadenabody + "</body>");
    salida.println("</root>"); */
    salida.println("Finalizado");
    f1.createNewFile();
    writer.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
    writer.write("<root>");
    writer.write("<tlf>" + cadenanumero + "</tlf>");
    writer.write("<op>" + cadenaoperadora + "</op>");
    writer.write("<sc>" + cadenashortcode + "</sc>");
    writer.write("<body>" + cadenabody + "</body>");
    writer.write("</root>");
    writer.close();
    It still do not create my file "salida.xml", still don't know why. Any help is welcome.

Maybe you are looking for