Solved

File browsing problem

Posted on 1998-09-03
4
156 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
- 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
scoresSpecial  challenge 13 40
changeXy challenge 13 56
wordlen challenge 3 46
Securing Jmx Console and web console 2 45
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
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:

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now