Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Accessing remote RandomAccessFile

Posted on 1998-11-08
5
Medium Priority
?
476 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 40 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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…
Suggested Courses

610 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