Solved

Accessing remote RandomAccessFile

Posted on 1998-11-08
5
425 Views
Last Modified: 2010-03-30
I should write a Servlet that should read from files on a remote host using RandomAccessFile.
Is it possible?  What naming conventions should I use?
0
Comment
Question by:Gadi031698
  • 3
  • 2
5 Comments
 
LVL 16

Accepted Solution

by:
heyhey_ earned 20 total points
ID: 1227089
servlets are (web)server extensions.
servlet can read and write file from the local disk (using RandomAccessFile),
but these are local files (for the servlet) not remote.

 Note: You can't read / write file on remote machine - its not a Java restriction :). you'll have to implement a server program that manages files and all clients should make queries to the server program which will 'serve' them

>> What naming conventions should I use?
just your favourite ones :)

hope this helps
0
 

Author Comment

by:Gadi031698
ID: 1227090
If I use a URL object, then I can read remote files using openStream, but I would like to read as randomAccess.
The question about the naming conventions was whether to use URLs or the \\host\dir convention.
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 1227091
accessing URL is not accesing file !!!
URL object is just a wrapper of some kind of remote protocol (HTTP / FTP etc.) and as you know the answer you receive can be just a "virtual" query result. (results from database query etc.)

so when you access URL, your computer sends the description of the object you need and the other computer sends the object - itself.
When using HTTP you just send the file name and receive the file (as a stream).

so if you want to have random access to this file you can
1. if the file is not very big - create a memory image of the file on the client computer (byte array) and maybe a "RandomAccessFile wrapper"
2. if the file is Very big and you can't keep it in memory - you should implement a server side CGI which can return parts of the file.

0
 

Author Comment

by:Gadi031698
ID: 1227092
Unfortunately the file is very big.
I understand that I have to write a CGI/Servlet for every server to be accessed.
Am I right?
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 1227093
yes you have to write a CGI / Servlet which can return part of the file (given name, offset and bytes to read).

this CGI/Servlet will extend the default web server beahviour.

of course, you can implement some sort of cache for the client, which will give the bytes immediately if it has a copy or send an HTTP request to the CGI if it has not.

Note: you write one script/servlet with the needed functionality and then you can use this script on every web-server that you work with. (but applets can send request only to their 'parent' server ...)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
IT Company 5 68
countAbc challenge 9 49
Eclipse Neon and jdk 1.8.0 11 65
Starting to learn JAVA, 7 47
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 video teaches viewers about errors in exception handling.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now