Solved

read zip file on Internet Server

Posted on 2001-09-09
11
264 Views
Last Modified: 2008-02-01
hi,

i wrote an applet ,and here is the part of the code:

 { ZipInputStream zin = new ZipInputStream(new FileInputStream(zipname));
      ZipEntry entry;
     while ((entry = zin.getNextEntry()) != null)
     {
        if (entry.getName().equals(filename))
          {   BufferedReader in = new BufferedReader(new InputStreamReader(zin));
               do something.......
          }
it runs well in my computer, but when i upload it the server and run, it says: the file access denied. what the possible problem for this?

i just read file on server, not write or update, why denied?

very urgent. 50pst

ws1999
0
Comment
Question by:ws1999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
11 Comments
 
LVL 3

Expert Comment

by:black
ID: 6469535
it seems like you don't have read access, is this a unix system or a windows system?
in unix, sometimes the server runs under a certain account and the file has been copied their under another account name and the account the server uses does not have read access for that file.
0
 
LVL 92

Expert Comment

by:objects
ID: 6469550
Unsigned applets are not permitted to access the local disk (for reading or writing).
You need to sign your applet to permit access to local disk.
0
 
LVL 3

Expert Comment

by:black
ID: 6469565
please disregard my comment I didn't read the applet part
sorry!
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!

 

Author Comment

by:ws1999
ID: 6469724
hello objects

the zip file is not in local disk,but in the server.

0
 
LVL 92

Expert Comment

by:objects
ID: 6469742
The you'll need to use a different technique to open it. Remember that the applet is running on the client, so accessing files directly will access files on the client disk.

If the zip file is visible on the web server then you can use URLConnection to open it. Otherwise you'll need to use some cgi, or a servlet.
0
 

Author Comment

by:ws1999
ID: 6469953
hello object

would you please elabrate more in detail about the URL connection?

ws1999
0
 
LVL 92

Expert Comment

by:objects
ID: 6469967
The URLConnection class is used to make connections to URL's.

// Make a connection to a URL

URLConnection conn = new URLConnection(url);

// Get a stream for the connection

InputStream in = conn.getInputStream();

// Process data

ZipInputStream zin = new ZipInputStream(in);
...
0
 

Author Comment

by:ws1999
ID: 6470529
hello objects

this code seems wrong:

URLConnection conn = new URLConnection(url);

the compiler said the URLConnection is abstract and cannot be instaniciated.

so how can i access this object?

ws1999
0
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 6472492
Oops, typing too fast again, try:

URLConnection conn = url.openConnection();

sorry :)

In fact if you just want to read the data then you can actually just do:

InputStream in = url.openStream();
0
 

Author Comment

by:ws1999
ID: 6472807
thanks Objects, hope to give you more points future
0
 
LVL 92

Expert Comment

by:objects
ID: 6472813
Not a problem.
Thanks for the points :)
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
hibernate example using maven 12 109
hibernate example issues from command prompt 10 85
difference between sorce folder and folder in eclipise 3 65
ejb entity bean example 2 57
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

751 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