• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 293
  • Last Modified:

Writing to file using Applet Problem

I managed to read a text file from the host where the applet originates using a URL, Now,I need to write to it again. How do I do it.
Here is code I used to read from the textfile. I used a vector to read from it to a List box.

public void readWords()
     //get path to data from parameter..
     String dataPath = getParameter("categfile");
     if (dataPath ==null){
          System.out.println("No data variable found");
     URL dtex;
     dtex =new URL(getDocumentBase(),dataPath);
     catch (MalformedURLException e) {
     System.out.println("Bad data URL");
     try {
          URLConnection d =dtex.openConnection();
          BufferedReader word = new BufferedReader(new InputStreamReader(d.getInputStream()));

//for(int i=0; i>2; i++)
     while ((inputLine = word.readLine()) != null){
catch (MalformedURLException e){//new URL() failed
     System.out.println("No data variable eeeeee found");
catch (IOException e){//openConnection() failed

 System.out.println("No data variablefffff found");

1 Solution
You can't write to a file on the server.
You need something on the server that you can post the file to, such as a servlet.
I think u can
Use the same procedure and get the outputstream for writing to file
then u have to give the permission to the applet for writing to file for that u have to create the policy file that give the prmission to applet for writting to file and place it in to directory from where u are running the applet for more info pls refer the following site

pls refer to Question No: 4

for giving permission refer to following

refer point No2


> Use the same procedure and get the outputstream for writing to file

And what is that output stream going to connect to on the server?
Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

> pls refer to Question No: 4

That refers to writing files on the client, not the server.
As does the second link.
>I think u can Use the same procedure and get the outputstream for writing to file

I don't think so.. it will cause big security hole, if it is doable, then I want to create java application to read and modify Microsoft.com's main page (index.html) .. :)
use ftp utility to upload the file...


as long as you upload/download the file to the same internet domain, I think ftp will works fine in applet (no security exception)...
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if still open in seven days.  Please post closing recommendations before that time.

Question(s) below appears to have been abandoned. Your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.

*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations if this item remains inactive another seven (7) days.  If you are interested in the cleanup effort, please click this link http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643 
POINTS FOR EXPERTS awaiting comments are listed here -> http://www.experts-exchange.com/commspt/Q.20277028.html
Moderators will finalize this question if in @7 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
Thank you everyone.
Moderator @ Experts Exchange
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Answered by: objects
Please leave any comments here within the next seven days.
EE Cleanup Volunteer
per recommendation

Community Support Moderator @Experts Exchange
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now