Solved

File browsing problem

Posted on 1998-09-03
4
177 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
  • 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JDeveloper 12c for 32 bit 4 84
github account with ecipse 1 47
oracle 11g 23 83
Java string replace 11 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…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

777 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