• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet processing termination

 
Antonino Lo Bue
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I've developed a servlet that do some process and create some file on output.
I need to know when the servlet has finished his work.

I need some listener?
If yes, how can I pass a "status attribute" or variable from the servlet listener to the calling page?
E.G. a status attribute that can assume values: "WAIT" - "RUNNING" - "FINISHED" and that can be readed by the calling page (a JSP page for example) changing dynamically a "download" button...

I need this due to enable a download button only when the servlet terminate...

I tried with ServletRequestListener but I don't know how to pass an attribute to the calling page
[ May 17, 2007: Message edited by: Antonino Lo Bue ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get the feeling you are not telling us the complete story. When the servlet terminates, it returns the response to the browser. That's how you know it's done.

Unless you are submitting the servlet to another window? an iframe? with Ajax? These are important pieces of information that you should incldue in your posts.
 
Antonino Lo Bue
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the html calling page... the servlet response goes to another window... but I want to enable, when servlet done, the download button


My servlet returns an HTML page with some results variables... this page is opened into another windows... and I need to update the main window...

thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only way for the displayed page to update itself when some asynchornous process completes is for it to poll the server. You could do this with a complete page refresh at specified intervals, or (miles better) an Ajax call that checks server status and modifies the page elements as appropriate.

Is this related to your other similar post?
 
Antonino Lo Bue
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes It is related, I think that is better to post in this section...

Ajax call that checks server status and modifies


what kind of call I have to made? Can you explain this better with an example?

thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Antonino Lo Bue:
Yes It is related, I think that is better to post in this section


In the future please do not cross-post in this way. It wastes people's time when multiple redundant conversations take place. Rather, ask a moderator to move the post for you.

I have closed the older post.

what kind of call I have to made? Can you explain this better with an example?


Since the remainder of the conversation is tobe about Ajax rather than servlets, I've moved this post to a more appropriate forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once you send of the secondary request, start a Javascript interval timer. When it triggers, send a request to the server that checks the status of the secondary request. The response of the Ajax request can return whether the secondary request has terminated or not.
 
Antonino Lo Bue
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you post an example?

thanks

(sorry for my duplicate post)
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Better idea: take a stab at it yourself and we'll take it from there. You've been given enough information to write most of this on your own.
 
Antonino Lo Bue
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When it triggers, send a request to the server that checks the status of the secondary request.


Why I have to instantiate the timer?

and,
How can I check the request status?
The secondary request will be submitted by Ajax PUT call or by form submit to the servlet with onSubmit call to the AJAX javascript function that start the timer?

sorry but I'm a bit confused....
[ May 18, 2007: Message edited by: Antonino Lo Bue ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Antonino Lo Bue:
Why I have to instantiate the timer?
Without it, how you would propose to poll the server for status at regular intervals?

How can I check the request status?


That depends on how you code you backend process. The secondary request (we'll call it worker request) can set a status flag in a database, in the session, in a file. It depends what makes the most sense for your server-side code.

The secondary request will be submitted by Ajax PUT call or by form submit to the servlet with onSubmit call to the AJAX javascript function that start the timer?
PUT? Not supported by most browsers.

It will just be a good old POST or GET like any other.
 
Antonino Lo Bue
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Now I can do that...

I wrote PUT but I was thinking POST....mismatch error on my mind

Thanks for all
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic