• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • 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.
Thanx...

public void readWords()
     {
     //get path to data from parameter..
     String dataPath = getParameter("categfile");
     if (dataPath ==null){
          System.out.println("No data variable found");
          return;
     }
     URL dtex;
     try{
     dtex =new URL(getDocumentBase(),dataPath);
     }
     catch (MalformedURLException e) {
     System.out.println("Bad data URL");
     return;
     }
         
     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){
     System.out.println(inputLine);
     wordVec.addElement(inputLine);
     }
     word.close();
     }
catch (MalformedURLException e){//new URL() failed
     System.out.println("No data variable eeeeee found");
     
     return;
}
catch (IOException e){//openConnection() failed

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

     return;
     }
}
0
q_bic
Asked:
q_bic
1 Solution
 
objectsCommented:
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.
0
 
rjackmanCommented:
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
http://java.sun.com/sfaq/#read

for giving permission refer to following

refer point No2

http://java.sun.com/docs/books/tutorial/security1.2/tour1/index.html

cheers
RJ
0
 
objectsCommented:
> 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?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
objectsCommented:
> pls refer to Question No: 4

That refers to writing files on the client, not the server.
As does the second link.
0
 
LexZEUSCommented:
>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) .. :)
0
 
LexZEUSCommented:
use ftp utility to upload the file...

http://sourceforge.net/projects/j-ftp/
http://www.enterprisedt.com/downloads/ftp.html
http://www.kcmultimedia.com/jftp/download.html

as long as you upload/download the file to the same internet domain, I think ftp will works fine in applet (no security exception)...
0
 
MoondancerCommented:
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.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
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.
http://www.experts-exchange.com/questions/Q.20282927.html
http://www.experts-exchange.com/questions/Q.20285583.html
http://www.experts-exchange.com/questions/Q.20286912.html
http://www.experts-exchange.com/questions/Q.20286982.html




*****  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.
 
Moondancer
Moderator @ Experts Exchange
0
 
Venci75Commented:
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.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venci75
EE Cleanup Volunteer
0
 
SpideyModCommented:
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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