Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

File browsing problem

Posted on 1998-09-03
4
Medium Priority
?
202 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 100 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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

721 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