wood burning stoves 2.0*
The moose likes Servlets and the fly likes stop executing of a servlet by another servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "stop executing of a servlet by another servlet" Watch "stop executing of a servlet by another servlet" New topic
Author

stop executing of a servlet by another servlet

ketaki gujarathi
Greenhorn

Joined: Sep 09, 2009
Posts: 6
hi,

Is there a way in which I can stop the executing of a function in servlet by settling some attribute in session using another servlet.
For eg:
In jsp < %session.setAttribute('cancel',"") %> On submit button I am calling a servlet which has following code
servlet1 -->(String str = session.getAttribute(cancel) ){ if (str.equals(somevalue) break;}

Now tht 'someValue' is set in session using servlet2 which is invoked on some button Click of jsp
servlet2 -->session.setAttribute('cancel',someValue)
Howver I am getting str as null always in servlet1 even after invoking servlet2.

Please note that I am using encodeURL to maintain the session.

Regards,
Ketaki
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684

Hi ketaki,

welcome to java ranch !!

I think No.

Once you send request to your Servlet after finish the request and clients get response you get control for another process.


Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
ketaki gujarathi
Greenhorn

Joined: Sep 09, 2009
Posts: 6
.. is there no way where i can stop executing the function of a servlet on some external action (For Eg on Cancel button click )...
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12759
    
    5
What exactly is the function that you want to stop?

Is it being executed by the Thread that called the servlet originally or has a new Thread been created?

Are both servlets in the same web application?

Bill
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Without knowing the answers to the questions asked by William, it is hard to provide answers.

As Nishan states, the normal processing through a web application is a request generates a response, which does not allow the possibility of user canceling the operation.

This might be bypassed in the cases of a lengthy server side process by utilizing Ajax requests. In which case, as long as you develop something server side to handle this, the client browser would still be responding to user interactions, so it could send some another request to the server to tell it to cancel the job. You would have to ensure that interrupting the server process did not result in invalid data on the server side.


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

William Brogden wrote:What exactly is the function that you want to stop?

My guess - the report process that Manisha is also asking about - apparently it is taking some time for the report to be built on the server before it gets sent to the client.
 
Consider Paul's rocket mass heater.
 
subject: stop executing of a servlet by another servlet
 
Similar Threads
Form Variables
Sending data to popup window
URL rewriting
Servlet - doGet - doPost - parameter
Issue with request.setAttribute(String,obj)