• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Server side process Statements line by line display in JSP

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic