Solved

File browsing problem

Posted on 1998-09-03
4
194 Views
Last Modified: 2010-03-30
I have to write a web application that enables browsing a huge server file on a client: Reading and displaying part of the file everytime, with some cache mechanism.
I would like to implement it using a servlet called by an HTML+JavaScript client.
I have two problems:
1. Keeping my current position in the server-file.
2. Managing a scrollbar on the client.
Any ideas?
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
4 Comments
 
LVL 8

Accepted Solution

by:
diakov earned 50 total points
ID: 1223378
You have to keep track of who is the client each time you receive a request for reading. For example, if one of the client applets calls with an ID (has to be unique, let say, given by the server at the first request), the server looks in a Hash table and reads the current position of the file for this particular client. Then open the file, seek the file, read the data, close the file, update the position in the Hash table, and return the data. And this for every client.
About the scrollbar, depends on what component you are using. The textfield component has some minor bug with the horizontal scrollbar (on windows JVM).
0
 
LVL 8

Expert Comment

by:diakov
ID: 1223379
Something else...
I suggested opening and closing the file with each operation. This is so, because the connection to the server could be broken any time. So you must not keep open connection on the server. The  HTTP connection is stateless by design so if you want to keep a state between two calls, you need to elaborate some more.
Btw, with the ID in the hash table we are keeping state already, so may be it is a good idea to make a garbage collect from time to time, let say each day. Just store a timestamp together with the ID, that show which is the last time the file was read by this client, and it is more than 1 day, just delete the ID. thsi way your servlet won't eat all the memory of the server for keeping IDs in the Hash table :-)
0
 

Author Comment

by:Gadi031698
ID: 1223380
Thanks, but not enough:
1. The problem of keeping state is that everytime, I'll have to read all the huge file sequentially until the current position.
2. Since I would like to use JavaScript on the client (and not Java) - the GUI problem still exist, isn't it? (Of course, if I have no choice - I will use Java. In that case - what control do you recommend me to use when implementing the scrolling?)

0
 
LVL 8

Expert Comment

by:diakov
ID: 1223381
- If you use the class RandomAccesFile you can seek the file randomly with constant time for positioning on any place of the file and do not need to read the beginning.
- besides IDs, you can use cookies sent back to the browser, so the client won't need to take care of his identification to the server.

You can use HTML. Let me explain.
You show the file in chunks of, let say, 20 rows of 32 bytes, and then there are two links for previous and next, or an input with a form, for going to exact location. The links of the left, right, etc, could look something like:
www.sdasdf.com/servlets/showfile?start=2000&size=32&showbuttons=left_right_absolute.
This HTML is generated by the servlet. So you don't even need the Javascript on the client side.
Another approach is to use list box, again from the HTML controls.
If you need help with the HTML, send a question there.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Desingning Refactoring existing code 2 46
String array comparison 4 57
collection output issue 9 94
Java regex 5 22
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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 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 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:

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