Solved

Accessing remote RandomAccessFile

Posted on 1998-11-08
5
447 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
[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
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

730 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