Solved

Accessing remote RandomAccessFile

Posted on 1998-11-08
5
453 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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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…
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…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

726 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