File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Servlet processing termination Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Servlet processing termination" Watch "Servlet processing termination" New topic
Author

Servlet processing termination

Antonino Lo Bue
Greenhorn

Joined: Feb 08, 2007
Posts: 15
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 ]

Antonino Lo Bue<br />Research Fellow<br />ICAR-CNR Palermo<br />Phone: 091-6809256<br />Web: <a href="http://medialab.pa.icar.cnr.it/sito/Personali/LoBue/index.html" target="_blank" rel="nofollow">http://medialab.pa.icar.cnr.it/sito/Personali/LoBue/index.html</A>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61006
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Antonino Lo Bue
Greenhorn

Joined: Feb 08, 2007
Posts: 15
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

Joined: Jan 10, 2002
Posts: 61006
    
  65

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

Joined: Feb 08, 2007
Posts: 15
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

Joined: Jan 10, 2002
Posts: 61006
    
  65

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

Joined: Jan 10, 2002
Posts: 61006
    
  65

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

Joined: Feb 08, 2007
Posts: 15
Could you post an example?

thanks

(sorry for my duplicate post)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61006
    
  65

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

Joined: Feb 08, 2007
Posts: 15
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

Joined: Jan 10, 2002
Posts: 61006
    
  65

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

Joined: Feb 08, 2007
Posts: 15
Thanks. Now I can do that...

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

Thanks for all
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet processing termination