Solved

Writing to file using Applet Problem

Posted on 2002-04-06
9
270 Views
Last Modified: 2010-03-31
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
Comment
Question by:q_bic
9 Comments
 
LVL 92

Accepted Solution

by:
objects earned 100 total points
ID: 6924265
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
 
LVL 3

Expert Comment

by:rjackman
ID: 6924648
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
 
LVL 92

Expert Comment

by:objects
ID: 6924652
> 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 
LVL 92

Expert Comment

by:objects
ID: 6924655
> pls refer to Question No: 4

That refers to writing files on the client, not the server.
As does the second link.
0
 
LVL 5

Expert Comment

by:LexZEUS
ID: 6925278
>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
 
LVL 5

Expert Comment

by:LexZEUS
ID: 6925287
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
 
LVL 1

Expert Comment

by:Moondancer
ID: 6956635
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
 
LVL 9

Expert Comment

by:Venci75
ID: 7933392
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
 

Expert Comment

by:SpideyMod
ID: 7984201
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 212
difference of if loops 23 60
String array comparison 4 38
eclipse console opening separately 2 29
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question