Solved

File browsing problem

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

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…
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…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This video teaches viewers about errors in exception handling.
Suggested Courses

630 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