This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Server side process Statements line by line display in JSP

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All..


I have an requirement is like this, Servlet is processing some data for this it will take some time. For every second or minute i need display servlet process statements in jsp. Using AJAX it will appends total response at a time but i need append line by line message.

Thanks in Advance...

Regards
SreenivasReddy. T
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the easiest I can think of is that the client has a JavaScript event makes an Ajax call every X seconds and either
1) the server sends the full list every time and the client replaces the local display with the data from the server (easier but problems if the data becomes large)
2) the client sends the timestamp (as determined by the server) of the last message update, the server responds with an updated timestamp and any new messages since the last update. The client appends the updated info to the page.
 
Sreenivas Reddy.T
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,


When client side JavaScript event makes an Ajax call every X seconds to the same servlet, the same task should be executed repeatedly. But What i need exactly,,, call servlet only once,for this call servlet take few minutes.mean while i need to display message to user what ever process which is going in the servlet dynamically to jsp.

Example message in jsp:

File1 is processed successfully..........
File2 is processed successfully..........
File3 is processed successfully..........
..........................

..........................

File1000 is processed successfully..........


Thanks in Advance

Regards
Sreenivas Reddy. T
 
Marshal
Posts: 67295
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not going to happen easily. A single servlet invocation is not going to be able to have that sort of back-and-foth interaction.

What you can do is to have the first servlet kick off a back-ground thread to perform the lengthy operation, and then have Ajax kick off "progress check" requests that can synchronize with the working thread to determine what to report as done.

Otherwise, you'll have to make each "line" a separate serial request.
 
Sreenivas Reddy.T
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi


Can you write a sample code for your explanation. In my program am calling Servlet once Servlet is internally calling Thread class many times based on the files we are passed. Again this Thread class is calling another Thread class for dividing the records in the file.


Thanks in Advance

Regards
Sreenivas Reddy.T
 
You guys wanna see my fabulous new place? Or do you wanna look at this tiny ad?
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!