473,806 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access a servlets data in a non-servlet, threading?

25 New Member
Hello,

I am looking for a solution to update a .jsp page (kind of progress bar) which shows current progress in a huge simulation when users have to wait for longer periods and the way to do it was have the jsp page refresh often and the page data update by a bean containing the properties file details. The main servlet class continously running on the server regularly updates the properties file.

I am currently using a properties file, which is updated by property IO methods load() and store() which is then accessed by a non-servlet class to read and perform specific actions. Potential problems could be when reading and writing into properties file by two different sources at the same time. Another bigger problem is this works only for one user. This cannot be used by multi-user as the properties file cannot be instantiated/shared unlike a servlet.

The problem is that there cannot be a session or application scoped variable that can be shared between a servlet and non-servlet easily and hence a lack of easier way of communicating with each other.

Any other good solutions to such problems?? Can we add a thread in a servlet which allows us to access a particular variable value in the servlet anywhere else?

Thanks in advance.

Subject: How do we share data between a servlet and a non-servlet when you want to access data that changes in time?
Feb 19 '08 #1
3 1567
chaarmann
785 Recognized Expert Contributor
If more than one program access the properties file at the same time, (and especially if these programs do not run inside the same JVM, but are independent as in your case), you can use file-locks for synchronization .

(If they run inside the same JVM, you could simply declare the static methods "synchroniz ed" or use a semaphore)

How to synchronize access with file-locks:
The writer process first creates an empty file "writeLock" (preferably in a temp directory) and flushes the write-cache. Then it iteratively reads the temp directory until it cannot find any "reading*" files there anymore.Then it modifies the desired properties file. After that it deletes the "writeLock" file.
Each one of the reader processes first searches for the "writeLock" file and waits until it's not there anymore. Then this reader process X creates an empty file "readingX" and starts reading this file. before it finishes, it deletes this file "readingX".

By the way,
you should consider using Ajax instead of a jsp-page-refresh; it's much faster and user-friendly.
Feb 19 '08 #2
krishna81m
25 New Member
Thanks you for your suggestion,

Unfortunately, this becomes a single user solution. I am unable to find a way to implement this in a multi-user application. Obviously, I cannot create a temporary file for each new user (new session but same JVM?) and have that new file also synchronized between a servlet and a non-servlet.

I am still looking at other solutions as I know many have already implemented this and I am eager to explore an alternative intuitive approach to this problem of multiple users.

Cheers
Krishna
Mar 24 '08 #3
krishna81m
25 New Member
Thanks you for your suggestion,

Unfortunately, this becomes a single user solution. I am unable to find a way to implement this in a multi-user application. Obviously, I cannot create a temporary file for each new user (new session but same JVM?) and have that new file also synchronized between a servlet and a non-servlet.

I am still looking at other solutions as I know many have already implemented this and I am eager to explore an alternative intuitive approach to this problem of multiple users.

All I need to display is the status of the current process, lets say there are a million records of five different files to be processed by a servlet, I have to show the user atleast as a percentage of records processed for each file every couple of seconds while the process is continuing at the server side.


Cheers
Krishna
Mar 24 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3172
by: Yoandy Rodriguez | last post by:
I'm developing a J2EE aplication and the project leader told me to investigate about the Data Access Object design pattern. I did some research at Sun's blueprints for the enterprise site but there are some things that I seem to be missing... My main problem is... If I'm using classes to access data why do I still need to use EJB's?? Would anyone please point me to some source code about it??? Thanks in advance and sorry if I misspelled...
1
1466
by: Don Khan | last post by:
Hi, I am relatively new to JAVA but I am trying to build contact management system which would allow users to create their list of contacts. The contact data would be in database and security is important issue. I was initially thinking of using servlets/jsp but than it occurred to me that there might be other technologies in JAVA which could be better suited to what I need to accomplish. The application should allow user to search...
11
4630
by: Roger Leigh | last post by:
The C++ book I have to hand (Liberty and Horvath, Teach yourself C++ for Linux in 21 Days--I know there are better) states that "static member functions cannot access any non-static member variables". However, this doesn't seem entirely correct. It also doesn't mention whether static member functions can access protected and private member data and methods (and I couldn't spot this in the FAQ). I have a class row<Row> which derives from...
49
14366
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The application is relatively big: around 200 tables, 200 forms and sub-forms, 150 queries and 150 repports, 5GB of data (SQL Server 2000), 40 users. I'm wondering what are the disadvantages of using Access as front-end? Other that it's not...
5
1333
by: deko | last post by:
I have a number of users with the same Access app on each of their laptops. When users have internet access, they want to be able to synchronize records in their individual databases with a main server so they can share or update particular "public" records. So I want to create a web service that gives them this "sometimes connected" functionality and the ability to designate "public" and "private" records. Can Access do this? Do I...
17
4425
by: Mell via AccessMonster.com | last post by:
Is there a way to find out where an application was created from? i.e. - work or home i.e. - if application sits on a (work) server/network, the IT people know the application is sitting there, but is there a way they can find out if that application was put there from a CD or email or created at work? Hint: It's not on a client/server database, just native jet database mdb created on Access 2003 (default 2000)...
3
5616
by: AaronMason | last post by:
Hi, Is it possible to use SQL to get a database's structure, like SHOW TABLES in MySQL? I'd like to create a database access interface for MS Access databases in JSP/Java Servlets and I need to be able to access the database structure. Of course, I would port this to other languages as well, but since I'm learning JSP/Servlets I'd like to start with that for the time being. Thanks in advance
8
4467
by: Sid | last post by:
I hope someone could help me with this. I am trying to setup a criteria to decide when to allow/not allow user to click on the check box. logically it looks simple but I am not able to incorporate in my data access page. I have a numerical field called tier status and right next to it I have a checkbox. I would like to allow user to check and uncheck the checkbox as long as the tier
1
1176
by: harithagowd | last post by:
how to access the immage in servlets which is stored in the same root directory
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3853
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.